-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
💻
- Would you like to work on a fix?
How are you using Babel?
babel-loader (webpack)
Input code
webpack --config webpack.config.js is the command that triggers this. I have no idea what part of the code is actually involved. The error message tells me which source file is the problem, but not which line so I don't know how to give you any input code.
Configuration file name
babel.config.js
Configuration
module.exports = function(api) {
var validEnv = ['development', 'test', 'production']
var currentEnv = api.env()
var isDevelopmentEnv = api.env('development')
var isProductionEnv = api.env('production')
var isTestEnv = api.env('test')
if (!validEnv.includes(currentEnv)) {
throw new Error(
'Please specify a valid `NODE_ENV` or ' +
'`BABEL_ENV` environment variables. Valid values are "development", ' +
'"test", and "production". Instead, received: ' +
JSON.stringify(currentEnv) +
'.'
)
}
return {
presets: [
isTestEnv && [
'@babel/preset-env',
{
targets: {
node: 'current'
},
modules: 'commonjs'
},
'@babel/preset-react',
{
runtime: "automatic"
}
],
(isProductionEnv || isDevelopmentEnv) && [
'@babel/preset-env',
{
forceAllTransforms: true,
useBuiltIns: 'entry',
corejs: 3,
modules: false,
exclude: ['transform-typeof-symbol']
}
],
[
'@babel/preset-react',
{
development: isDevelopmentEnv || isTestEnv,
useBuiltIns: true,
runtime: "automatic"
}
]
].filter(Boolean),
plugins: [
'@babel/plugin-syntax-dynamic-import',
isTestEnv && 'babel-plugin-dynamic-import-node',
'@babel/plugin-transform-destructuring',
'@babel/plugin-transform-class-properties',
[
'@babel/plugin-transform-object-rest-spread',
{
useBuiltIns: true
}
],
[
'@babel/plugin-transform-runtime',
{
helpers: false,
regenerator: true,
corejs: false
}
],
[
'@babel/plugin-transform-regenerator',
{
async: false
}
],
isProductionEnv && [
'babel-plugin-transform-react-remove-prop-types',
{
removeImport: true
}
]
].filter(Boolean)
}
}
Current and expected behavior
webpack builds started failing on updating to preset-env 7.25.0. I would expect them to continue building properly.
Environment
System:
OS: macOS 14.5
Binaries:
Node: 20.14.0 - ~/.nvm/versions/node/v20.14.0/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 10.7.0 - ~/.nvm/versions/node/v20.14.0/bin/npm
npmPackages:
@babel/core: ^7.24.9 => 7.24.9
@babel/plugin-transform-runtime: ^7.23.9 => 7.24.7
@babel/preset-env: ^7.25.0 => 7.25.0
@babel/preset-react: ^7.18.6 => 7.24.7
babel-loader: ^9.1.3 => 9.1.3
babel-plugin-transform-react-remove-prop-types: ^0.4.24 => 0.4.24
webpack: ^5.92.1 => 5.93.0
Possible solution
Changing
| path.ensureFunctionName ??= |
value.ensureFuctionName instead of path.ensureFunctionName seems to do the trick, but I don't know enough about the full build pipeline to be sure that's what is intended.
Additional context
No response