Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sandboxes: Pin @vitejs/plugin-react to avoid conflict #22501

Merged
merged 2 commits into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion scripts/tasks/sandbox-parts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ import { join, resolve, sep } from 'path';
import slash from 'slash';
import type { Task } from '../task';
import { executeCLIStep, steps } from '../utils/cli-step';
import { installYarn2, configureYarn2ForVerdaccio, addPackageResolutions } from '../utils/yarn';
import {
installYarn2,
configureYarn2ForVerdaccio,
addPackageResolutions,
addWorkaroundResolutions,
} from '../utils/yarn';
import { exec } from '../utils/exec';
import type { ConfigFile } from '../../code/lib/csf-tools';
import { writeConfig } from '../../code/lib/csf-tools';
Expand Down Expand Up @@ -81,6 +86,7 @@ export const install: Task['run'] = async (
dryRun,
debug,
});
await addWorkaroundResolutions({ cwd, dryRun, debug });
} else {
// We need to add package resolutions to ensure that we only ever install the latest version
// of any storybook packages as verdaccio is not able to both proxy to npm and publish over
Expand Down
13 changes: 13 additions & 0 deletions scripts/utils/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ export const installYarn2 = async ({ cwd, dryRun, debug }: YarnOptions) => {
);
};

export const addWorkaroundResolutions = async ({ cwd, dryRun }: YarnOptions) => {
logger.info(`🔢 Adding resolutions for workarounds`);
if (dryRun) return;

const packageJsonPath = path.join(cwd, 'package.json');
const packageJson = await readJSON(packageJsonPath);
packageJson.resolutions = {
...packageJson.resolutions,
'@vitejs/plugin-react': '^4.0.0', // due to conflicting version in @storybook/vite-react
};
await writeJSON(packageJsonPath, packageJson, { spaces: 2 });
};

export const configureYarn2ForVerdaccio = async ({ cwd, dryRun, debug }: YarnOptions) => {
const command = [
// We don't want to use the cache or we might get older copies of our built packages
Expand Down