'Is it possible to setup eslint on webpack.config.babel.js without CommonJS warning/error?
As title. I want to use ES6 modules syntax on my webpack config file. Currently, I got:
Diagnostics:
Cannot use import declarations in modules that export using CommonJS (module.exports = 'foo' or exports.bar = 'hi') [import/no-import-module-exports]
Solution 1:[1]
To use ES6 modules syntax in your webpack.config.js(and you don't need the .babel. in the middle), do the following:
package.jsonadd"type": "module"- In
webpack.config.jschange Node.jsmodule.exportstoexport default. - In
webpack.config.jschange CJS__dirname,__filenametopath.dirname(),import.meta.urlwith some modifications.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | VimNing |
