Skip to content

Commit

Permalink
Merge pull request #19936 from storybookjs/fix/sandbox-script-bypass-…
Browse files Browse the repository at this point in the history
…ehanced-resolve-fire

fix the CI by adding a resolution for the broken release of enhanced resolve, and also overriding the dep version of types/node on sandboxes so that they may be linked
  • Loading branch information
ndelangen authored Nov 23, 2022
2 parents d2297f5 + b986f55 commit 53af8af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion code/lib/cli/src/link.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import fse from 'fs-extra';
import fse, { readJSON, writeJSON } from 'fs-extra';
import path from 'path';
import { sync as spawnSync } from 'cross-spawn';
import { logger } from '@storybook/node-logger';
Expand Down Expand Up @@ -51,6 +51,12 @@ export const link = async ({ target, local, start }: LinkOptions) => {
logger.info(`Linking ${reproDir}`);
await exec(`yarn link --all ${storybookDir}`, { cwd: reproDir });

// TODO remove this once https://github.com/webpack/enhanced-resolve/issues/362 is resolved
const packageJsonPath = path.join(reproDir, 'package.json');
const packageJson = await readJSON(packageJsonPath);
packageJson.resolutions = { ...packageJson.resolutions, 'enhanced-resolve': '~5.10.0' };
await writeJSON(packageJsonPath, packageJson, { spaces: 2 });

logger.info(`Installing ${reproName}`);
await exec(`yarn install`, { cwd: reproDir });

Expand All @@ -60,6 +66,9 @@ export const link = async ({ target, local, start }: LinkOptions) => {
);
await exec(`yarn add -D webpack-hot-middleware`, { cwd: reproDir });

// ensure that linking is possible
await exec(`yarn add @types/node@16`, { cwd: reproDir });

if (start) {
logger.info(`Running ${reproName} storybook`);
await exec(`yarn run storybook`, { cwd: reproDir });
Expand Down
2 changes: 1 addition & 1 deletion scripts/utils/yarn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const addPackageResolutions = async ({ cwd, dryRun }: YarnOptions) => {

const packageJsonPath = path.join(cwd, 'package.json');
const packageJson = await readJSON(packageJsonPath);
packageJson.resolutions = storybookVersions;
packageJson.resolutions = { ...storybookVersions, 'enhanced-resolve': '~5.10.0' };
await writeJSON(packageJsonPath, packageJson, { spaces: 2 });
};

Expand Down

0 comments on commit 53af8af

Please sign in to comment.