-
-
Notifications
You must be signed in to change notification settings - Fork 539
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
Test REPL in nodenext type=module projects; may need a tweak to ensure REPL is CJS #1752
Comments
The fix here might be as simple as either: A) naming the repl's "virtual file" to end in the .cts file extension Internally, the repl is a virtual .ts file that exists solely in memory. This allows us to typecheck it like any other file. Since it already has a name, we can give it the cts file extension and get the same benefits. If we go the cts route, we will need to be sure this works even without module=nodenext. We will also need to confirm which TSC versions support cts. It may be acceptable to use cts when the user's TSC version is new enough, and gracefully fallback to legacy repl behavior otherwise. Users with ESM projects are likely already on a new TS version, so we solve the problem for most users who would encounter it. |
Not sure, if I understand the solution correctly. But, if you are recommending to always used CommonJS, then shouldn't that be wrong? If my project is in ESM, then the REPL should be ESM too? |
The question is: what does node's REPL do? We'll match that. |
REPL doesn't support ESM: |
While working on #1694, stumbled upon a possible REPL issue:
if package.json type = module, and you fire up the REPL, how is the REPL being compiled? Should make sure it's treated as CJS.
Should also check
ts-node -pe "is this code ESM or CJS? What should it be?"
The text was updated successfully, but these errors were encountered: