Have you used AI?
None
Feature Proposal
This is the mechanism of require(esm) implemented in Node.js1: if the imported module has a named export with the string name "module.exports", then the value corresponding to that export is returned.
In Webpack, the equivalent would be: if an ES Module is imported by require and it has a named export with the string name "module.exports", then the value corresponding to that export should be returned.
Feature Use Case
This makes Webpack compatible with Node.js.
This can help authors convert libraries to ESM-Only, which currently provides dual ESM/CJS modules and depends on using module.exports = ... in CommonJS.
Additional Context
Underscore related issues:
Currently, among various bundlers, I only found rolldown to have implemented this feature2.
Have you used AI?
None
Feature Proposal
This is the mechanism of
require(esm)implemented in Node.js1: if the imported module has a named export with the string name "module.exports", then the value corresponding to that export is returned.In Webpack, the equivalent would be: if an ES Module is imported by
requireand it has a named export with the string name "module.exports", then the value corresponding to that export should be returned.Feature Use Case
This makes Webpack compatible with Node.js.
This can help authors convert libraries to ESM-Only, which currently provides dual ESM/CJS modules and depends on using
module.exports = ...in CommonJS.Additional Context
Underscore related issues:
Currently, among various bundlers, I only found rolldown to have implemented this feature2.
Footnotes
https://nodejs.org/docs/latest-v24.x/api/modules.html#loading-ecmascript-modules-using-require ↩
https://github.com/rolldown/rolldown/issues/4997 ↩