The js-config-webpack-plugin does not work with @babel/core 7.8.4
anthonkendel opened this issue · 4 comments
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
[ ] Other... Please describe:
Current behavior
The js-config-webpack-plugin does not work with @babel/core 7.8.4 but works with 7.2.2 as specified in devDependencies.
If using a newer version of @babel/core the following stack trace is thrown:
TypeError: Cannot read property 'push' of undefined
at JsConfigWebpackPlugin.resolveBabelConfigFilePath (/home/anthon/development/test-webpack-stuff/test-lib/node_modules/js-config-webpack-plugin/src/JsConfigWebpackPlugin.js:36:27)
at JsConfigWebpackPlugin.apply (/home/anthon/development/test-webpack-stuff/test-lib/node_modules/js-config-webpack-plugin/src/JsConfigWebpackPlugin.js:67:10)
at webpack (/home/anthon/development/test-webpack-stuff/test-lib/node_modules/webpack/lib/webpack.js:51:13)
at processOptions (/home/anthon/development/test-webpack-stuff/test-lib/node_modules/webpack-cli/bin/cli.js:272:16)
at yargs.parse (/home/anthon/development/test-webpack-stuff/test-lib/node_modules/webpack-cli/bin/cli.js:364:3)
at Object.parse (/home/anthon/development/test-webpack-stuff/test-lib/node_modules/yargs/yargs.js:567:18)
at /home/anthon/development/test-webpack-stuff/test-lib/node_modules/webpack-cli/bin/cli.js:49:8
at Object.<anonymous> (/home/anthon/development/test-webpack-stuff/test-lib/node_modules/webpack-cli/bin/cli.js:366:3)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/home/anthon/development/test-webpack-stuff/test-lib/node_modules/webpack/bin/webpack.js:156:2)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
Looking into @babel/core it seems like the findPackageData
function was rewritten as a generator function in the following commit 282f81bd676d09c1d8c48b08a7254b961eb41bed. This is probably why the plugin does not work with a later version of @babel/core.
Expected behavior
The plugin should work within the range that is specified for the peerDependencies requirement.
Minimal reproduction of the problem with instructions
Create a new npm project
npm init -y
Install dependencies
npm install --save-dev webpack webpack-cli @babel/core @babel/preset-env @babel/preset-react js-config-webpack-plugin
Create webpack.config.js
# webpack.config.js
const JsConfigWebpackPlugin = require('js-config-webpack-plugin');
module.exports = {
mode: 'development',
entry: './src/index.js',
plugins: [new JsConfigWebpackPlugin()],
}
Create src/index.js
/**
* @param {string} name - the name to say hello to
*/
export function hello(name = 'anon') {
console.log('hello ' + name);
}
Build with webpack
npx webpack
Stack trace should be thrown.
What is the motivation / use case for changing the behavior?
Environment
Plugin version: 1.4.0
- Node version: v10.18.1
- Platform: Windows, Ubuntu Subsystem
Others:
Looks like the bug can be worked around by providing the babelConfigFile
option to JsConfigWebpackPlugin
.
Wow nice find - would you like to create a pull request?
Released in 2.0.1
seems to be ok ;-)