Skip to content

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

@cspotcode

Description

@cspotcode

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions