-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: babel-loader not working with node 16.20.1 #15960
Comments
Hey @bhargavtenali! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly. If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite. |
Are you trying to bundle Babel itself? Something is trying to parse that file where you see the error (which is a Babel file), but it's not properly set up to parse CommonJS with top-level return. |
Looks like the issue #15950 has also same root cause |
Hi @nicolo-ribaudo I am using babel in React app as webpack loader |
I tried adding the exclude node_modules and allowing topLevelReturn in parser option but no use webpack {
test: /\.js$/,
use: [
{
loader: 'babel-loader',
options: {
extends: path.join(paths.root, 'tools/config/babel.config.js'),
},
},
{
loader: 'eslint-loader',
options: {
failOnError: false,
quiet: false,
fix: true,
configFile: path.join(paths.root, 'tools/config/.eslintrc.json'),
},
},
],
exclude: /node_modules/,
include: [paths.app, paths.admin, paths.suez, paths.styleguide, paths.packages, paths.worldbank],
}, babel-config.js module.exports = {
parserOpts: { allowReturnOutsideFunction: true },
presets: ['@babel/preset-env', '@babel/preset-react'],
plugins: [
'@babel/plugin-proposal-function-bind',
'@babel/plugin-proposal-export-default-from',
'@babel/plugin-proposal-logical-assignment-operators',
['@babel/plugin-proposal-optional-chaining', { loose: false }],
['@babel/plugin-proposal-pipeline-operator', { proposal: 'minimal' }],
['@babel/plugin-proposal-nullish-coalescing-operator', { loose: false }],
'@babel/plugin-proposal-do-expressions',
['@babel/plugin-proposal-decorators', { legacy: true }],
'@babel/plugin-proposal-function-sent',
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-numeric-separator',
'@babel/plugin-proposal-throw-expressions',
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-syntax-import-meta',
['@babel/plugin-proposal-class-properties', { loose: false }],
'@babel/plugin-proposal-json-strings',
],
env: {
production: {
plugins: ['transform-react-remove-prop-types'],
},
},
} |
Hi,
|
Thanks @nicolo-ribaudo for the hint in #15960 (comment) |
馃捇
How are you using Babel?
babel-loader (webpack)
Input code
webpack config
babel-config.js
Configuration file name
babel.config.js
Configuration
Current and expected behavior
Current:
npm run build is failing with node 16.20.1
Getting this error
It is working fine with node 14
Environment
Possible solution
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: