From 4e1782d3e295936ce4bfd4e64f5b62698fec90e3 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Thu, 6 Oct 2022 22:56:28 -0400 Subject: [PATCH 1/3] Build: Make babel-loader optional --- code/addons/docs/package.json | 6 +++++- code/renderers/vue/package.json | 5 +++++ code/renderers/vue3/package.json | 5 +++++ code/yarn.lock | 9 +++++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/code/addons/docs/package.json b/code/addons/docs/package.json index 3b0993c42c35..25b5395e4c2f 100644 --- a/code/addons/docs/package.json +++ b/code/addons/docs/package.json @@ -69,7 +69,6 @@ "@storybook/source-loader": "7.0.0-alpha.35", "@storybook/store": "7.0.0-alpha.35", "@storybook/theming": "7.0.0-alpha.35", - "babel-loader": "^8.2.5", "dequal": "^2.0.2", "global": "^4.4.0", "lodash": "^4.17.21", @@ -82,10 +81,12 @@ "@babel/core": "^7.12.10", "@storybook/mdx2-csf": "0.0.4-canary.14.04ffbe8.0", "@types/util-deprecate": "^1.0.0", + "babel-loader": "^8.2.5", "typescript": "~4.6.3" }, "peerDependencies": { "@storybook/mdx2-csf": "0.0.4-canary.14.04ffbe8.0", + "babel-loader": "^8.2.5", "react": "^16.8.0 || ^17.0.0 || ^18.0.0", "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" }, @@ -93,6 +94,9 @@ "@storybook/mdx2-csf": { "optional": true }, + "babel-loader": { + "optional": true + }, "react": { "optional": true }, diff --git a/code/renderers/vue/package.json b/code/renderers/vue/package.json index b00facaaa4d0..6715a2caeba4 100644 --- a/code/renderers/vue/package.json +++ b/code/renderers/vue/package.json @@ -71,6 +71,11 @@ "css-loader": "*", "vue": "^2.6.8" }, + "peerDependenciesMeta": { + "babel-loader": { + "optional": true + } + }, "engines": { "node": ">=10.13.0" }, diff --git a/code/renderers/vue3/package.json b/code/renderers/vue3/package.json index 776b9f50d8a6..2072ccb6e724 100644 --- a/code/renderers/vue3/package.json +++ b/code/renderers/vue3/package.json @@ -70,6 +70,11 @@ "babel-loader": "^7.0.0 || ^8.0.0", "vue": "^3.0.0" }, + "peerDependenciesMeta": { + "babel-loader": { + "optional": true + } + }, "engines": { "node": ">=10.13.0" }, diff --git a/code/yarn.lock b/code/yarn.lock index c69f79916ee1..9618adeae1e0 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6597,11 +6597,14 @@ __metadata: util-deprecate: ^1.0.2 peerDependencies: "@storybook/mdx2-csf": 0.0.4-canary.14.04ffbe8.0 + babel-loader: ^8.2.5 react: ^16.8.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 peerDependenciesMeta: "@storybook/mdx2-csf": optional: true + babel-loader: + optional: true react: optional: true react-dom: @@ -9168,6 +9171,9 @@ __metadata: "@babel/core": "*" babel-loader: ^7.0.0 || ^8.0.0 vue: ^3.0.0 + peerDependenciesMeta: + babel-loader: + optional: true languageName: unknown linkType: soft @@ -9192,6 +9198,9 @@ __metadata: babel-loader: ^7.0.0 || ^8.0.0 css-loader: "*" vue: ^2.6.8 + peerDependenciesMeta: + babel-loader: + optional: true languageName: unknown linkType: soft From bf16c57510067e74407255d7bbcb041e4f2ad421 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Tue, 18 Oct 2022 09:38:53 -0400 Subject: [PATCH 2/3] Provide location of babel-loader from builder-webpack5 --- code/addons/docs/package.json | 5 ----- code/addons/docs/src/preset.ts | 2 +- code/lib/builder-webpack5/src/presets/preview-preset.ts | 2 ++ code/yarn.lock | 4 ---- 4 files changed, 3 insertions(+), 10 deletions(-) diff --git a/code/addons/docs/package.json b/code/addons/docs/package.json index b794e1ff27ac..cf2732bd283d 100644 --- a/code/addons/docs/package.json +++ b/code/addons/docs/package.json @@ -82,12 +82,10 @@ "@babel/core": "^7.12.10", "@storybook/mdx2-csf": "0.0.4-canary.14.04ffbe8.0", "@types/util-deprecate": "^1.0.0", - "babel-loader": "^8.2.5", "typescript": "~4.6.3" }, "peerDependencies": { "@storybook/mdx2-csf": "0.0.4-canary.14.04ffbe8.0", - "babel-loader": "^8.2.5", "react": "^16.8.0 || ^17.0.0 || ^18.0.0", "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" }, @@ -95,9 +93,6 @@ "@storybook/mdx2-csf": { "optional": true }, - "babel-loader": { - "optional": true - }, "react": { "optional": true }, diff --git a/code/addons/docs/src/preset.ts b/code/addons/docs/src/preset.ts index b824eadabc2b..63eb97d0269a 100644 --- a/code/addons/docs/src/preset.ts +++ b/code/addons/docs/src/preset.ts @@ -48,7 +48,7 @@ export async function webpack( typeof createCompiler >[0] */ ) { - const resolvedBabelLoader = require.resolve('babel-loader'); + const resolvedBabelLoader = await options.presets.apply('babelLoaderRef'); const { module = {} } = webpackConfig; diff --git a/code/lib/builder-webpack5/src/presets/preview-preset.ts b/code/lib/builder-webpack5/src/presets/preview-preset.ts index eb608d16687c..4d8daace20ad 100644 --- a/code/lib/builder-webpack5/src/presets/preview-preset.ts +++ b/code/lib/builder-webpack5/src/presets/preview-preset.ts @@ -28,3 +28,5 @@ export const babel = async (config: any, options: any) => ({ }, ], }); + +export const babelLoaderRef = () => require.resolve('babel-loader'); diff --git a/code/yarn.lock b/code/yarn.lock index 7d98931990d6..cbe16dfa8443 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6478,7 +6478,6 @@ __metadata: "@storybook/store": 7.0.0-alpha.38 "@storybook/theming": 7.0.0-alpha.38 "@types/util-deprecate": ^1.0.0 - babel-loader: ^8.2.5 dequal: ^2.0.2 fs-extra: ^9.0.1 global: ^4.4.0 @@ -6490,14 +6489,11 @@ __metadata: util-deprecate: ^1.0.2 peerDependencies: "@storybook/mdx2-csf": 0.0.4-canary.14.04ffbe8.0 - babel-loader: ^8.2.5 react: ^16.8.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 peerDependenciesMeta: "@storybook/mdx2-csf": optional: true - babel-loader: - optional: true react: optional: true react-dom: From f587314de663924d06bb9d7d9cd2d34367d00335 Mon Sep 17 00:00:00 2001 From: Ian VanSchooten Date: Tue, 18 Oct 2022 09:41:17 -0400 Subject: [PATCH 3/3] Remove some other unused dependencies --- code/addons/docs/package.json | 2 -- code/yarn.lock | 2 -- 2 files changed, 4 deletions(-) diff --git a/code/addons/docs/package.json b/code/addons/docs/package.json index cf2732bd283d..91d72fc74027 100644 --- a/code/addons/docs/package.json +++ b/code/addons/docs/package.json @@ -50,7 +50,6 @@ }, "dependencies": { "@babel/plugin-transform-react-jsx": "^7.12.12", - "@babel/preset-env": "^7.12.11", "@jest/transform": "^26.6.2", "@mdx-js/react": "^1.6.22", "@storybook/addons": "7.0.0-alpha.38", @@ -72,7 +71,6 @@ "dequal": "^2.0.2", "fs-extra": "^9.0.1", "global": "^4.4.0", - "lodash": "^4.17.21", "remark-external-links": "^8.0.0", "remark-slug": "^6.0.0", "ts-dedent": "^2.0.0", diff --git a/code/yarn.lock b/code/yarn.lock index cbe16dfa8443..b38f79d81262 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6457,7 +6457,6 @@ __metadata: dependencies: "@babel/core": ^7.12.10 "@babel/plugin-transform-react-jsx": ^7.12.12 - "@babel/preset-env": ^7.12.11 "@jest/transform": ^26.6.2 "@mdx-js/react": ^1.6.22 "@storybook/addons": 7.0.0-alpha.38 @@ -6481,7 +6480,6 @@ __metadata: dequal: ^2.0.2 fs-extra: ^9.0.1 global: ^4.4.0 - lodash: ^4.17.21 remark-external-links: ^8.0.0 remark-slug: ^6.0.0 ts-dedent: ^2.0.0