You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.
First of all, thanks to all of you for your efforts! I am currently playing around with Node.js 12.0.0 and the new ESM implementation. One thing I have come across is that require('some-es-package') does not fail as expected if some-es-package has a package.json file containing these properties:
"type": "module","main": "index.js"
The call to require() fails with a syntax error whereas it becomes ERR_REQUIRE_ESM if I rename index.js to index.mjs. Is this behavior intended?
The text was updated successfully, but these errors were encountered:
The call to require() fails with a syntax error whereas it becomes ERR_REQUIRE_ESM if I rename index.js to index.mjs. Is this behavior intended?
Slightly more full answer: Yes and no. The behavior will likely change. It should ideally be ERR_REQUIRE_ESM in both cases, or not an error in either case. Moving from the (likely) parse error to the much nicer and more explainative ERR_REQUIRE_ESM error (or to not an error) hasn't really been seen as a semver breaking change, so fixing that up one way or another (which entails closing in on our final cjs interop strategy) hasn't been looked at much (sicne we're either just changing the text of a (likely) error to a better one or removing the errors entirely). In both cases, our logic for package-scoped configuration (for recognition of the type field) needs to get baked into the cjs resolver (as right now it is not) - our current implementation pretty much doesn't touch the cjs resolver, which is also why we just had to emergency patch in throwing on .mjsrequire's without the flag set.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
First of all, thanks to all of you for your efforts! I am currently playing around with Node.js 12.0.0 and the new ESM implementation. One thing I have come across is that
require('some-es-package')
does not fail as expected ifsome-es-package
has apackage.json
file containing these properties:The call to
require()
fails with a syntax error whereas it becomesERR_REQUIRE_ESM
if I renameindex.js
toindex.mjs
. Is this behavior intended?The text was updated successfully, but these errors were encountered: