From f70f0508f182b475c65a5b9d87444421ef8790eb Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 18 Jul 2023 20:37:17 +0200 Subject: [PATCH 1/2] remove react as peerDep of builder-webpack --- code/builders/builder-webpack5/package.json | 12 --------- .../src/preview/iframe-webpack.config.ts | 26 +++++++++++++------ code/yarn.lock | 5 +--- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/code/builders/builder-webpack5/package.json b/code/builders/builder-webpack5/package.json index 98f8b8f259a1..68ce2dfb95b9 100644 --- a/code/builders/builder-webpack5/package.json +++ b/code/builders/builder-webpack5/package.json @@ -56,22 +56,14 @@ }, "dependencies": { "@babel/core": "^7.22.0", - "@storybook/addons": "7.1.0", "@storybook/channels": "7.1.0", - "@storybook/client-api": "7.1.0", "@storybook/client-logger": "7.1.0", - "@storybook/components": "7.1.0", "@storybook/core-common": "7.1.0", "@storybook/core-events": "7.1.0", "@storybook/core-webpack": "7.1.0", - "@storybook/global": "^5.0.0", - "@storybook/manager-api": "7.1.0", "@storybook/node-logger": "7.1.0", "@storybook/preview": "7.1.0", "@storybook/preview-api": "7.1.0", - "@storybook/router": "7.1.0", - "@storybook/store": "7.1.0", - "@storybook/theming": "7.1.0", "@swc/core": "^1.3.49", "@types/node": "^16.0.0", "@types/semver": "^7.3.4", @@ -109,10 +101,6 @@ "slash": "^5.0.0", "typescript": "~4.9.3" }, - "peerDependencies": { - "react": "^16.8.0 || ^17.0.0 || ^18.0.0", - "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" - }, "peerDependenciesMeta": { "typescript": { "optional": true diff --git a/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts b/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts index 44ec4e92c8e5..a29d936975bc 100644 --- a/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts +++ b/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts @@ -31,19 +31,29 @@ const wrapForPnP = (input: string) => dirname(require.resolve(join(input, 'packa const storybookPaths: Record = { ...[ - // these packages are not pre-bundled because of react dependencies + // these packages are not pre-bundled because of react dependencies. + // these are not dependencies of the builder anymore, thus resolving them can fail. + // we should remove the aliases in 8.0, I'm not sure why they are here in the first place. 'components', 'global', 'manager-api', 'router', 'theming', - ].reduce( - (acc, sbPackage) => ({ - ...acc, - [`@storybook/${sbPackage}`]: wrapForPnP(`@storybook/${sbPackage}`), - }), - {} - ), + ].reduce((acc, sbPackage) => { + let packagePath; + try { + packagePath = wrapForPnP(`@storybook/${sbPackage}`); + } catch (e) { + // ignore + } + if (packagePath) { + return { + ...acc, + [`@storybook/${sbPackage}`]: wrapForPnP(`@storybook/${sbPackage}`), + }; + } + return acc; + }, {}), // deprecated, remove in 8.0 [`@storybook/api`]: wrapForPnP(`@storybook/manager-api`), }; diff --git a/code/yarn.lock b/code/yarn.lock index 6a0f2faeaca2..350350432e4e 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6312,9 +6312,7 @@ __metadata: resolution: "@storybook/builder-webpack5@workspace:builders/builder-webpack5" dependencies: "@babel/core": ^7.22.0 - "@storybook/addons": 7.1.0 "@storybook/channels": 7.1.0 - "@storybook/client-api": 7.1.0 "@storybook/client-logger": 7.1.0 "@storybook/components": 7.1.0 "@storybook/core-common": 7.1.0 @@ -6326,7 +6324,6 @@ __metadata: "@storybook/preview": 7.1.0 "@storybook/preview-api": 7.1.0 "@storybook/router": 7.1.0 - "@storybook/store": 7.1.0 "@storybook/theming": 7.1.0 "@swc/core": ^1.3.49 "@types/node": ^16.0.0 @@ -7729,7 +7726,7 @@ __metadata: languageName: unknown linkType: soft -"@storybook/store@7.1.0, @storybook/store@workspace:*, @storybook/store@workspace:deprecated/store": +"@storybook/store@workspace:*, @storybook/store@workspace:deprecated/store": version: 0.0.0-use.local resolution: "@storybook/store@workspace:deprecated/store" dependencies: From fb22d76043559df2b23864626ff88bfa5cb5f2a3 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 18 Jul 2023 20:47:02 +0200 Subject: [PATCH 2/2] fix lockfile --- code/yarn.lock | 8 -------- 1 file changed, 8 deletions(-) diff --git a/code/yarn.lock b/code/yarn.lock index 350350432e4e..2d2ab615b72f 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6314,17 +6314,12 @@ __metadata: "@babel/core": ^7.22.0 "@storybook/channels": 7.1.0 "@storybook/client-logger": 7.1.0 - "@storybook/components": 7.1.0 "@storybook/core-common": 7.1.0 "@storybook/core-events": 7.1.0 "@storybook/core-webpack": 7.1.0 - "@storybook/global": ^5.0.0 - "@storybook/manager-api": 7.1.0 "@storybook/node-logger": 7.1.0 "@storybook/preview": 7.1.0 "@storybook/preview-api": 7.1.0 - "@storybook/router": 7.1.0 - "@storybook/theming": 7.1.0 "@swc/core": ^1.3.49 "@types/node": ^16.0.0 "@types/pretty-hrtime": ^1.0.0 @@ -6359,9 +6354,6 @@ __metadata: webpack-dev-middleware: ^6.1.1 webpack-hot-middleware: ^2.25.1 webpack-virtual-modules: ^0.5.0 - peerDependencies: - react: ^16.8.0 || ^17.0.0 || ^18.0.0 - react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 peerDependenciesMeta: typescript: optional: true