Open
Description
More and more npm packages are shipping as ESM. In node, the compatibility between ESM and CommonJS has some limitation:
- an ES module can import a CommonJS module
- an ES module can dynamically import a CommonJS module
- a CommonJS module cannot import an ES module (Node 22 has an experimental feature allowing it for synchronous object graphs, i.e. ES modules that don't use top-level await)
- a CommonJS module can dynamically import an ES module through
await import(...)
(but this can only be used in an async context)
Shipping Encore as a CommonJS module means that we cannot upgrade our dependencies to versions that have migrated to ESM (as Encore.getConfig()
is a synchronous API, any solution requiring an async context is a no-go).
Migrating to ESM needs to be done in a new major version as it is a BC break for downstream projects. This will require writing the webpack.config.js
file in ESM, either by using type=module
in the package.json or by using webpack.config.mjs
instead (which is supported by webpack)
Metadata
Metadata
Assignees
Labels
No labels