I am using a webpack on a project with webpack.config.babel.js so I can use esm systax
I have this babel config
"babel": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"browsers": [">1%", "last 4 versions", "not ie < 9"]
},
"useBuiltIns": "usage",
"debug": false,
"corejs": 3
}
],
"@babel/preset-react"
]
}
I do not have "type": "modules" anywhere on the package.json
Using this script on `package.json
"dev": "webpack serve --env --mode=development --config webpack/webpack.config.babel.js",
And have anong others this packages:
"@babel/core": "~7.12.3",
"@babel/eslint-parser": "^7.21.3",
"@babel/preset-env": "~7.12.1",
"@babel/preset-react": "~7.12.1",
"@babel/register": "~7.12.1",
"webpack": "^5.75.0",
"webpack-bundle-analyzer": "~4.1.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "~3.11.0",
"webpack-merge": "~5.3.0",
I am using node v21.6.2
And all works fine I am able to use import on webpack.
But If I try to upgrade webpack to higher version all breaks up and it becomes unable to read ESM syntax no matter what I do, adding "type": "modules" ... following instructions on babel and updating those too...nothing works, and starts to become a mess as there's not a single article on the internet it works for me, so I end up mixing all. But it never works.
In reply to @Bogdan Gishka:
Old version:
Usign webpack.config.babel.js and no "type": "module" and no .js
"webpack": "^5.75.0",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "~3.11.0",
"webpack-merge": "~5.3.0"
New version:
Usign webpack.config.js with "type": "module" and with .js
"webpack": "^5.90.3", "webpack-cli": "^5.1.4", "webpack-dev-server": "^5.0.2", "webpack-merge": "^5.10.0",