是否可以在没有CommonJS警告/错误的情况下在webpack.config.bel.js上设置esint



作为标题。我想在我的webpack配置文件中使用ES6模块语法。目前,我得到了:

Diagnostics:
Cannot use import declarations in modules that export using CommonJS (module.exports = 'foo' or exports.bar = 'hi') [import/no-import-module-exports]

要在webpack.config.js中使用ES6模块语法(中间不需要.babel.(,请执行以下操作:

  1. package.json添加"type": "module"
  2. webpack.config.js中,将Node.jsmodule.exports更改为export default
  3. webpack.config.js中,将CJS__dirname__filename更改为path.dirname()import.meta.url,并进行了一些修改

最新更新