From 3aaafd61e8a81798e462c37cd3627b0bcabd2b16 Mon Sep 17 00:00:00 2001 From: PaulGMardling Date: Fri, 10 Jul 2026 16:45:57 +0200 Subject: [PATCH 1/2] fix(storybook): remove custom-babel-loader workaround --- .../src/custom-babel-loader.ts | 13 ------------- .../src/webpack.spec.ts | 6 +++--- .../src/webpack.ts | 6 +----- scripts/storybook/src/rules.js | 4 ++++ 4 files changed, 8 insertions(+), 21 deletions(-) delete mode 100644 packages/react-components/react-storybook-addon-export-to-sandbox/src/custom-babel-loader.ts diff --git a/packages/react-components/react-storybook-addon-export-to-sandbox/src/custom-babel-loader.ts b/packages/react-components/react-storybook-addon-export-to-sandbox/src/custom-babel-loader.ts deleted file mode 100644 index 5a4789359c8d43..00000000000000 --- a/packages/react-components/react-storybook-addon-export-to-sandbox/src/custom-babel-loader.ts +++ /dev/null @@ -1,13 +0,0 @@ -const babelLoader = require('babel-loader'); - -/** - * Custom loader wraps the original babel-loader and fixes the incorrect `inputSourceMap` that - * is passed from a loader that uses the `sourceMap` option. - */ -module.exports = function (source: string, inputSourceMap?: object | boolean | string) { - return babelLoader.call( - this, - source, - typeof inputSourceMap === 'string' ? JSON.parse(inputSourceMap) : inputSourceMap, - ); -}; diff --git a/packages/react-components/react-storybook-addon-export-to-sandbox/src/webpack.spec.ts b/packages/react-components/react-storybook-addon-export-to-sandbox/src/webpack.spec.ts index 07327204e7246c..db5e79d61d5e1a 100644 --- a/packages/react-components/react-storybook-addon-export-to-sandbox/src/webpack.spec.ts +++ b/packages/react-components/react-storybook-addon-export-to-sandbox/src/webpack.spec.ts @@ -17,7 +17,7 @@ describe(`webpack`, () => { enforce: 'post', test: /\.stories\.(jsx?$|tsx?$)/, use: { - loader: expect.stringContaining('custom-babel-loader'), + loader: expect.stringContaining('babel-loader'), options: { plugins: [ [ @@ -56,7 +56,7 @@ describe(`webpack`, () => { test: /\.stories\.tsx?/, include: /foo-stories/, use: { - loader: expect.stringContaining('custom-babel-loader'), + loader: expect.stringContaining('babel-loader'), options: { plugins: [ [ @@ -93,7 +93,7 @@ describe(`webpack`, () => { enforce: 'post', test: /\.stories\.(jsx?$|tsx?$)/, use: { - loader: expect.stringContaining('custom-babel-loader'), + loader: expect.stringContaining('babel-loader'), options: { plugins: [ [ diff --git a/packages/react-components/react-storybook-addon-export-to-sandbox/src/webpack.ts b/packages/react-components/react-storybook-addon-export-to-sandbox/src/webpack.ts index b6d7cabf57e09f..b030d71a17451c 100644 --- a/packages/react-components/react-storybook-addon-export-to-sandbox/src/webpack.ts +++ b/packages/react-components/react-storybook-addon-export-to-sandbox/src/webpack.ts @@ -39,11 +39,7 @@ function createBabelLoaderRule(config: Required): import('webpack' */ enforce: 'post', use: { - /** - * Custom babel loader wraps the original babel-loader and fixes the incorrect `inputSourceMap` parameter - * that is passed to babel-loader. - **/ - loader: require.resolve('./custom-babel-loader'), + loader: require.resolve('babel-loader'), options: babelLoaderOptionsUpdater({ plugins: [plugin], }), diff --git a/scripts/storybook/src/rules.js b/scripts/storybook/src/rules.js index cca1cb3c906644..933369800e6150 100644 --- a/scripts/storybook/src/rules.js +++ b/scripts/storybook/src/rules.js @@ -100,6 +100,10 @@ const swcRule = { { loader: 'swc-loader', options: { + // Parse the source map to an object so subsequent loaders (e.g. babel-loader) receive + // an object rather than the raw JSON string that @swc/core outputs. + // Without this, babel-loader throws: "Error: .inputSourceMap must be a boolean, object, or undefined" + parseMap: true, jsc: { target: 'es2019', parser: { From 40f3976b379369c35e6568e259444c2c8d4f973b Mon Sep 17 00:00:00 2001 From: PaulGMardling Date: Fri, 10 Jul 2026 16:51:36 +0200 Subject: [PATCH 2/2] fix(storybook): add change file --- ...rt-to-sandbox-055ab233-3768-4a82-b636-fbd44c7644a0.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/@fluentui-react-storybook-addon-export-to-sandbox-055ab233-3768-4a82-b636-fbd44c7644a0.json diff --git a/change/@fluentui-react-storybook-addon-export-to-sandbox-055ab233-3768-4a82-b636-fbd44c7644a0.json b/change/@fluentui-react-storybook-addon-export-to-sandbox-055ab233-3768-4a82-b636-fbd44c7644a0.json new file mode 100644 index 00000000000000..4f75af1734c92c --- /dev/null +++ b/change/@fluentui-react-storybook-addon-export-to-sandbox-055ab233-3768-4a82-b636-fbd44c7644a0.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "remove custom-babel-loader", + "packageName": "@fluentui/react-storybook-addon-export-to-sandbox", + "email": "paulmardling@microsoft.com", + "dependentChangeType": "patch" +}