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

Error when tsconfig.compilerOptions.module is unsupported by Node #1069

Open
Tracked by #1504
alcuadrado opened this issue Jun 24, 2020 · 2 comments
Open
Tracked by #1504

Error when tsconfig.compilerOptions.module is unsupported by Node #1069

alcuadrado opened this issue Jun 24, 2020 · 2 comments
Labels
enhancement you can do this Good candidate for a pull request.

Comments

@alcuadrado
Copy link

Desired Behavior

Throw an error if tsconfig.compilerOptions.module is other than "commonjs".

Is this request related to a problem?

I have a command-line application that loads ts-node if it's installed. Users can use typescript for almost everything in that case.

The problem is that some users may accidentally set the tsconfig.compilerOptions.module to incompatible values. If this happens, the errors they get are pretty hard to understand.

Alternatives you've considered

We could validate this ourselves, but that would mean reimplementing how ts-node chooses which tsconfig.json to use.

Additional context

This request should be updated if ts-node were to support the new native ESM mode of node.

@cspotcode
Copy link
Collaborator

Some relevant info:

ts-node already supports native ESM. See #1007 for discussion.

We default to CommonJS if the user does not specify the module option.
https://github.com/TypeStrong/ts-node/blob/master/src/index.ts#L912-L915
But we respect the user's choice if they configure it.

@cspotcode cspotcode added this to the next milestone May 15, 2021
@cspotcode cspotcode modified the milestones: 10.2.0, next Aug 8, 2021
@cspotcode cspotcode removed this from the 10.5.0 milestone Feb 2, 2022
@cspotcode cspotcode added the you can do this Good candidate for a pull request. label Feb 2, 2022
@nicolas377
Copy link

Should this be a warning? While we know that node will probably throw when running whatever unsupported module type, we can't be 100% future proof with that. IMHO, it's a better idea to warn the user of the upcoming error than completely cut them off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement you can do this Good candidate for a pull request.
Projects
None yet
Development

No branches or pull requests

3 participants