mirror of
https://github.com/storybookjs/storybook.git
synced 2025-04-07 22:11:47 +08:00
Add tmp workaround to fix CRA repro in PnP mode
This commit is contained in:
parent
4cfc80c379
commit
f517d56aad
@ -6,6 +6,11 @@ nodeLinker: node-modules
|
||||
|
||||
npmRegistryServer: "https://registry.yarnpkg.com"
|
||||
|
||||
packageExtensions:
|
||||
babel-preset-react-app@10.0.x:
|
||||
dependencies:
|
||||
"@babel/plugin-proposal-private-property-in-object": ^7.16.0
|
||||
|
||||
plugins:
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
|
||||
spec: "@yarnpkg/plugin-typescript"
|
||||
|
@ -2,6 +2,7 @@ import path from 'path';
|
||||
import { writeJSON } from 'fs-extra';
|
||||
import shell, { ExecOptions } from 'shelljs';
|
||||
import chalk from 'chalk';
|
||||
import { cra, cra_typescript } from './configs';
|
||||
|
||||
const logger = console;
|
||||
|
||||
@ -69,15 +70,24 @@ export const exec = async (
|
||||
});
|
||||
};
|
||||
|
||||
const installYarn2 = async ({ cwd, pnp }: Options) => {
|
||||
const installYarn2 = async ({ cwd, pnp, name }: Options) => {
|
||||
const command = [
|
||||
`yarn set version berry`,
|
||||
`yarn config set enableGlobalCache true`,
|
||||
`yarn config set nodeLinker ${pnp ? 'pnp' : 'node-modules'}`,
|
||||
].join(' && ');
|
||||
];
|
||||
|
||||
// FIXME: Some dependencies used by CRA aren't listed in its package.json
|
||||
// Next line is a hack to remove as soon as CRA will have added these missing deps
|
||||
// for details see https://github.com/facebook/create-react-app/pull/11751
|
||||
if ([cra.name, cra_typescript.name].includes(name)) {
|
||||
command.push(
|
||||
`yarn config set packageExtensions --json '{ "babel-preset-react-app@10.0.x": { "dependencies": { "@babel/plugin-proposal-private-property-in-object": "^7.16.0" } } }'`
|
||||
);
|
||||
}
|
||||
|
||||
await exec(
|
||||
command,
|
||||
command.join(' && '),
|
||||
{ cwd },
|
||||
{ startMessage: `🧶 Installing Yarn 2`, errorMessage: `🚨 Installing Yarn 2 failed` }
|
||||
);
|
||||
@ -107,8 +117,6 @@ const configureYarn2ForE2E = async ({ cwd }: Options) => {
|
||||
const generate = async ({ cwd, name, appName, version, generator }: Options) => {
|
||||
const command = generator.replace(/{{appName}}/g, appName).replace(/{{version}}/g, version);
|
||||
|
||||
console.log('generate', { command, generator });
|
||||
|
||||
await exec(
|
||||
command,
|
||||
{ cwd },
|
||||
|
Loading…
x
Reference in New Issue
Block a user