Skip to content

Commit 5588294

Browse files
committed
fix(storybook): remove custom-babel-loader workaround
1 parent 4aa1084 commit 5588294

4 files changed

Lines changed: 8 additions & 21 deletions

File tree

packages/react-components/react-storybook-addon-export-to-sandbox/src/custom-babel-loader.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/react-components/react-storybook-addon-export-to-sandbox/src/webpack.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe(`webpack`, () => {
1717
enforce: 'post',
1818
test: /\.stories\.(jsx?$|tsx?$)/,
1919
use: {
20-
loader: expect.stringContaining('custom-babel-loader'),
20+
loader: expect.stringContaining('babel-loader'),
2121
options: {
2222
plugins: [
2323
[
@@ -56,7 +56,7 @@ describe(`webpack`, () => {
5656
test: /\.stories\.tsx?/,
5757
include: /foo-stories/,
5858
use: {
59-
loader: expect.stringContaining('custom-babel-loader'),
59+
loader: expect.stringContaining('babel-loader'),
6060
options: {
6161
plugins: [
6262
[
@@ -93,7 +93,7 @@ describe(`webpack`, () => {
9393
enforce: 'post',
9494
test: /\.stories\.(jsx?$|tsx?$)/,
9595
use: {
96-
loader: expect.stringContaining('custom-babel-loader'),
96+
loader: expect.stringContaining('babel-loader'),
9797
options: {
9898
plugins: [
9999
[

packages/react-components/react-storybook-addon-export-to-sandbox/src/webpack.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ function createBabelLoaderRule(config: Required<PresetConfig>): import('webpack'
3939
*/
4040
enforce: 'post',
4141
use: {
42-
/**
43-
* Custom babel loader wraps the original babel-loader and fixes the incorrect `inputSourceMap` parameter
44-
* that is passed to babel-loader.
45-
**/
46-
loader: require.resolve('./custom-babel-loader'),
42+
loader: require.resolve('babel-loader'),
4743
options: babelLoaderOptionsUpdater({
4844
plugins: [plugin],
4945
}),

scripts/storybook/src/rules.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ const swcRule = {
100100
{
101101
loader: 'swc-loader',
102102
options: {
103+
// Parse the source map to an object so subsequent loaders (e.g. babel-loader) receive
104+
// an object rather than the raw JSON string that @swc/core outputs.
105+
// Without this, babel-loader throws: "Error: .inputSourceMap must be a boolean, object, or undefined"
106+
parseMap: true,
103107
jsc: {
104108
target: 'es2019',
105109
parser: {

0 commit comments

Comments
 (0)