Skip to content

module: proxy require('esm') to import('esm')

This PR changes the behavior when someone attempts to require and ESM module.

Rather than throwing, which we currently do, the module that was attempted to be required will be proxied to dynamic import and require will return the promise to resolve the module (the same behavior as dynamic import).

This works for both packages and standalone files.

This is an alternative to https://github.com/nodejs/node/pull/30891

One thing worth mentioning is that it would appear that the majority of folks that are wrapping this error right now are doing so for the exact behavior that this PR implements

https://github.com/search?q=err.code+%3D%3D+ERR_REQUIRE_ESM&type=code

There are currently no docs, assuming we are open to landing this PR I'll update documentation

Merge request reports

Loading