New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin transform-runtime generates incorrect commonjs wrapper #1011
Comments
problems in It should correct the prediction of the actual module type and then injects requires instead of imports |
By default, Babel assumes users are authoring ES Modules, where accessing Please specify require('webpack')({
mode : 'development',
devtool : false,
module : {
rules : [{
test : /\.js$/,
use : {
loader : 'babel-loader',
options : {
+ sourceType: "script",
presets : [['@babel/env', {loose : true}]],
plugins : ['@babel/transform-runtime'],
},
},
}],
},
}, (err, stats) => {
console.log(stats.toString({colors : true}));
}); |
Webpack Version: 5.89.0
Babel Core Version: 7.23.3
Babel Loader Version: 9.1.3
Configuration / minimal case
package.json
build.js (webpack.config)
src.js
foo.js
Current behavior (corrupted)
after running
node build.js
, the outputdist/main.js
do not translate cjsexports
correctlyWe will have
ReferencError: Can't find variable: exports
while running.Expected / analysing
The
exports
in output modulefoo.js
is badly referenced as__webpack_exports__
.Either remove
@babel/preser-env
or@babel/plugin-transform-runtime
from babel options can resolvethis problem.
The text was updated successfully, but these errors were encountered: