I need help diagnosing and fixing this error:
"Error: only one instance of babel-polyfill is allowed"
I have the following in my package.json:
"devDependencies": {
"babel-core": "^6.23.1",
"babel-jest": "^19.0.0",
"babel-loader": "^6.3.2",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-es2015": "^6.22.0",
"babel-preset-react": "^6.23.0" ...
"dependencies": {
"babel-polyfill": "^6.23.0" ...
And this and this entry line in my webpack config:
entry: ["babel-polyfill", path.resolve(APP_PATH, 'index')],
...
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
// specify that we will be dealing with React code
presets: ['react', 'es2015']
}
}
]}
Idempotent Babel Polyfill can be imported multiple times
Install from NPM
npm install --save idempotent-babel-polyfill
Then import it
import 'idempotent-babel-polyfill';
If the culprit is HtmlWebpackPlugin, you need to add the option inject: false
when instancing the plugin. Certain configurations without this option causes your built javascript code to be loaded twice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With