mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 07:21:17 +08:00
feat(cli): make CLI works with Yarn 2 for React scripts projects
Before, it was assumed that "When working with `create-react-app@>=2.0.0`, we know `babel-loader` is installed." But `babel` is a peer dependency of `@storybook/core` (itself dep of `@storybook/react`) and so it must be added to the project's `package.json`
This commit is contained in:
parent
e46fecfc05
commit
febe9e7204
@ -1,6 +1,5 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import semver from 'semver';
|
|
||||||
import {
|
import {
|
||||||
retrievePackageJson,
|
retrievePackageJson,
|
||||||
getVersionedPackages,
|
getVersionedPackages,
|
||||||
@ -44,14 +43,7 @@ export default async (npmOptions, { storyFormat = 'csf' }) => {
|
|||||||
|
|
||||||
writePackageJson(packageJson);
|
writePackageJson(packageJson);
|
||||||
|
|
||||||
// When working with `create-react-app@>=2.0.0`, we know `babel-loader` is installed.
|
const babelDependencies = await getBabelDependencies(npmOptions, packageJson);
|
||||||
let babelDependencies = [];
|
|
||||||
const reactScriptsDep =
|
|
||||||
packageJson.dependencies['react-scripts'] || packageJson.devDependencies['react-scripts'];
|
|
||||||
|
|
||||||
if (reactScriptsDep && semver.gtr('2.0.0', reactScriptsDep)) {
|
|
||||||
babelDependencies = await getBabelDependencies(npmOptions, packageJson);
|
|
||||||
}
|
|
||||||
|
|
||||||
installDependencies({ ...npmOptions, packageJson }, [...versionedPackages, ...babelDependencies]);
|
installDependencies({ ...npmOptions, packageJson }, [...versionedPackages, ...babelDependencies]);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user