'"inputSourceMap must be a boolean, object, or undefined" error
I'm trying to use swc with rails' webpacker. I've created a rails app from scratch, upgraded webpacker to 6.0.0.beta.7, added swc with swc-loader package, added custom configuration like below:
// config/webpack/swc.js
module.exports = {
module: {
rules: [
{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'swc-loader',
options: {
sync: true,
sourceMaps: true,
}
}
}
]
}
}
Next, I merged this config like below:
// config/webpack/base.js
const { webpackConfig } = require('@rails/webpacker')
// https://github.com/rails/webpacker/issues/2984#issuecomment-857010732
const { merge } = require('webpack-merge')
const swcConfig = require('./swc')
module.exports = merge(
webpackConfig,
swcConfig
)
Then I got the error below when I run rails s:
...
12:25:20 wp.1 | <s> [webpack.Progress] 99% cache store build dependencies
12:25:20 wp.1 | <s> [webpack.Progress] 99% cache store build dependencies
12:25:20 wp.1 | <s> [webpack.Progress] 99% cache begin idle
12:25:20 wp.1 | <s> [webpack.Progress] 99% cache begin idle
12:25:20 wp.1 | <s> [webpack.Progress] 100%
12:25:20 wp.1 |
12:25:20 wp.1 | ✖ 「wdm」: asset js/runtime-application-0f80ea22b0fcc0ff124e.js 5.11 KiB [emitted] [immutable] (name: runtime-application) 1 related asset
12:25:20 wp.1 | asset js/application-f75235474b9936dcdd9f.js 1.5 KiB [emitted] [immutable] (name: application)
12:25:20 wp.1 | asset manifest.json 501 bytes [emitted]
12:25:20 wp.1 |
12:25:20 wp.1 | ERROR in ./app/packs/entrypoints/application.js
12:25:20 wp.1 | Module build failed (from ./node_modules/babel-loader/lib/index.js):
12:25:20 wp.1 | Error: .inputSourceMap must be a boolean, object, or undefined
12:25:20 wp.1 | at assertInputSourceMap (/tmp/swcapp/node_modules/@babel/core/lib/config/validation/option-assertions.js:124:11)
12:25:20 wp.1 | at /tmp/swcapp/node_modules/@babel/core/lib/config/validation/options.js:118:5
12:25:20 wp.1 | at Array.forEach (<anonymous>)
12:25:20 wp.1 | at validateNested (/tmp/swcapp/node_modules/@babel/core/lib/config/validation/options.js:94:21)
12:25:20 wp.1 | at validate (/tmp/swcapp/node_modules/@babel/core/lib/config/validation/options.js:85:10)
12:25:20 wp.1 | at loadPrivatePartialConfig (/tmp/swcapp/node_modules/@babel/core/lib/config/partial.js:80:50)
12:25:20 wp.1 | at loadPrivatePartialConfig.next (<anonymous>)
12:25:20 wp.1 | at /tmp/swcapp/node_modules/@babel/core/lib/config/partial.js:149:25
12:25:20 wp.1 | at Generator.next (<anonymous>)
12:25:20 wp.1 | at step (/tmp/swcapp/node_modules/gensync/index.js:261:32)
12:25:20 wp.1 |
12:25:20 wp.1 | webpack 5.50.0 compiled with 1 error in 369 ms
...
How can I fix the error?
Solution 1:[1]
Add option to your swc-loader:
options: {
parseMap: true,
},
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Hamanovich |
