One of the things I’ve noticed while writing ESM code is that I reach for it all the time, even when writing webpack.config.js
files. It would be rad if webpack 4 used something like @std/esm
behind the scenes to load its config files. In addition to CJS, this would enable support for ESM import
, export
, dynamic import
, and import.meta
with config files across Node versions. Thoughts?
5 thoughts on “Support ESM import/export in config files.”
Comments are closed.
Ideally it would work with
.js
without the need to register a handler withjs-interpret
.It should probably also “just work” with
.mjs
, because that’s where Node is likely going, without the need to register a handler as well.Update:
Clarified per @bmeck‘s comment.
Standards are great. User-land is also great because it has the freedom to try things out, like JSON5 or ESM in configs, giving wins to devs today while influencing the standards of tomorrow independently and organically.
As a compromise we can add
--config-register
to the CLI which is similar to-r
in node.webpack --config-register @std/esm
would allow to use import/export in configuration. This would also be great for babel users which can choose to use ES201X in webpack.config.js with--config-register babel-register
…@ev1stensberg this is a task for the webpack-cli.
--config-register
(+ alias-r
)it’s available in the webpack-cli, and soon in webpack after beta has been released