diff --git a/code/lib/cli/src/link.ts b/code/lib/cli/src/link.ts index f6da58c1d6c9..99af176a9638 100644 --- a/code/lib/cli/src/link.ts +++ b/code/lib/cli/src/link.ts @@ -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'; @@ -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 }); @@ -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 }); diff --git a/scripts/utils/yarn.ts b/scripts/utils/yarn.ts index 1b264f28a3da..b5f4ab35274b 100644 --- a/scripts/utils/yarn.ts +++ b/scripts/utils/yarn.ts @@ -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 }); };