Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make attempts to require() ESM *always* throw error #1229

Closed
cspotcode opened this issue Feb 21, 2021 · 0 comments · Fixed by #1232
Closed

Make attempts to require() ESM *always* throw error #1229

cspotcode opened this issue Feb 21, 2021 · 0 comments · Fixed by #1232
Milestone

Comments

@cspotcode
Copy link
Collaborator

Follow-up to #1031

Node will throw an error if you try to require() an ESM file.
To preserve backwards-compatibility, this error-throwing was enabled conditionally in ts-node's require hook. It would only throw if you had opted-in to the ESM loader.

https://github.com/TypeStrong/ts-node/pull/1031/files#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80R880

However, node behavior for .js files is to always throw, and we need to match that. So as a breaking change, we should do the same.

cspotcode added a commit that referenced this issue Feb 22, 2021
…empting to execute ESM as CJS, even when ESM loader is not loaded (#1232)

* always throw ERR_REQUIRE_ESM when attempting to execute ESM as CJS, even when ESM loader is not loaded

* cleanup

* Fix #1235

* fix bug
@cspotcode cspotcode added this to the 10.0.0 milestone May 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant