webpack-contrib / imports-loader

Imports Loader
MIT License
520 stars 63 forks source link

This line `toString` should be `toJSON` #141

Closed MXXXXXS closed 2 years ago

MXXXXXS commented 2 years ago

https://github.com/webpack-contrib/imports-loader/blob/1d8f8c3ce401ac7b415863e0e658ebdb8ec489fb/src/index.js#L106

https://github.com/babel/babel/pull/14658

It will cause error when using with babel-loader like

Error: .inputSourceMap must be a boolean, object, or undefined
    at assertInputSourceMap (/home/aqua/coding/atri/node_modules/@babel/core/lib/config/validation/option-assertions.js:124:11)
alexander-akait commented 2 years ago

toString and toJSON returns string, don't think you are right here

MXXXXXS commented 2 years ago

image

@alexander-akait Strange... toJSON actually returns an object

And babel-loader not recognise string, it should be an object

alexander-akait commented 2 years ago

Please create reproducible test repo, babel-loader should handle string source maps (as minimum it worker early)

MXXXXXS commented 2 years ago

@alexander-akait Here is: https://github.com/MXXXXXS/imports-loader-bug

Run npm i && npm run build, and it will output like:

ERROR in ./src/app.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: .inputSourceMap must be a boolean, object, or undefined
    at assertInputSourceMap (/home/aqua/coding/import-loader-bug/node_modules/@babel/core/lib/config/validation/option-assertions.js:124:11)
rectalogic commented 2 years ago

Confirmed the above patch fixes this issue for us.