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

Fix bug where REPL inputs were compiled as ESM in ESM projects #1959

Merged
merged 4 commits into from
Feb 14, 2023

Conversation

cspotcode
Copy link
Collaborator

@cspotcode cspotcode commented Feb 13, 2023

Changed the virtual filename <repl>.ts to <repl>.cts, but only on TS >= 4.5 which is the first version to support cts files. Then added a test.

Fixes #1902
Fixes #1924

@codecov
Copy link

codecov bot commented Feb 13, 2023

Codecov Report

Merging #1959 (8259e9a) into main (ba741fa) will increase coverage by 0.54%.
The diff coverage is 96.15%.

Impacted Files Coverage Δ
src/repl.ts 84.25% <94.44%> (+4.16%) ⬆️
src/bin.ts 90.16% <100.00%> (+2.87%) ⬆️
src/file-extensions.ts 94.87% <100.00%> (-5.13%) ⬇️
src/child/spawn-child.ts 81.25% <0.00%> (-6.25%) ⬇️
src/configuration.ts 86.71% <0.00%> (+0.42%) ⬆️

@cspotcode
Copy link
Collaborator Author

Failure is because TS 4.2 does not understand .cts file extension. Fix for that is probably change REPL_FILENAME into a fn that accepts TS version number, so can detect if TS >= 4.5.0.

May have to conditionally disable the new "repl executes input as cjs even in esm projects" test on older TS that doesn't understand NodeNext. Test locally first.

Also split test/repl/helpers into multiple files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

REPL with ES modules for ES6+ module settings, REPL error on first command: Unexpected token 'export'
1 participant