-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
If a custom SWC config file contains multiple entries, the custom and default SWC config are not merged together correctly. Instead of an array containing multiple SWC configs, the config becomes an object with keys '0' and '1', resulting in the error:
Module build failed (from ./node_modules/swc-loader/src/index.js):
Error: unknown field `0` at line 1 column 713
Steps to reproduce the behavior
- Create a
.swcrcfile with multiple entries, such as different configuration for .js(x) versus .ts(x) - Attempt to build Storybook
- Observe that the build fails with the above error
Here is the .swcrc file I started with:
[
{
"test": ".*\\.jsx?$",
"env": {
"mode": "usage",
"loose": true,
"corejs": "3"
},
"jsc": {
"loose": true,
"parser": {
"syntax": "ecmascript",
"jsx": true
}
}
},
{
"test": ".*\\.tsx?$",
"env": {
"mode": "usage",
"loose": true,
"corejs": "3"
},
"jsc": {
"loose": true,
"parser": {
"syntax": "typescript",
"tsx": true
}
}
}
]
I console.logged the config to try to see what was going on and saw
{
'0': {
test: '.*\\.jsx?$',
env: { mode: 'usage', loose: true, corejs: '3' },
jsc: { loose: true, parser: [Object] }
},
'1': {
test: '.*\\.tsx?$',
env: { mode: 'usage', loose: true, corejs: '3' },
jsc: { loose: true, parser: [Object] }
},
env: { bugfixes: true },
jsc: {
transform: { react: [Object] },
parser: { tsx: true, dynamicImport: true, syntax: 'typescript' }
}
}
Expected behavior
I suspect that for multiple entries, the default config values need to be merged into each config item in the array rather than the array converted to an object?
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working