-
-
Notifications
You must be signed in to change notification settings - Fork 431
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
Add Tests and Remarks Concerning the New .cts
And .mts
File Extensions
#1508
Conversation
This is great! Would you be able to contribute an execution test as well please? It's likely just a matter of copy/pasting this test: https://github.com/TypeStrong/ts-loader/tree/main/test/execution-tests/basic And doing some tweaking to cater for |
@johnnyreilly in order to work with the new file extensions Could I update |
.cts
And .mts
to Example Configurations.cts
And .mts
File Extensions
Do it. You'll probably need to regenerate comparison tests and update the |
@johnnyreilly I had quite a little a struggle As you can see, according to the test case, Files are detected as Furthermore, File with a |
Looks good! Do you want to regenerate the comparison tests snapshots? With a new webpack version output will have changed somewhat |
@johnnyreilly I'm done refactoring the tests. |
@johnnyreilly The Comparison Tests don't work.
instead of
on Windows |
That is weird. We have (slightly hacky) code in place to handle platform differences:
Wonder if that isn't working |
BTW you might find this to be an interesting proposal: microsoft/TypeScript#50152 Somewhat related to the work you've been tackling here. @andrewbranch is looking specifically at how TypeScript can relate to bundlers for module resolution |
I can’t even begin to understand what “the proper .cts and .mts experience” is supposed to be in a bundler 😅 Once |
Fascinating! Because |
Because most bundlers will violate the semantics that .cts files are supposed to have. A .cts file emits to CommonJS, which means imports are transformed into requires in the output JS when you use tsc. But bundlers with built-in TypeScript support like esbuild don’t do that transformation to |
I meant to add, interestingly, ts-loader + Webpack is possibly the only major bundler combination that would just get this right by default since it uses tsc’s emit. But especially given that it also depends on the tsconfig settings, it’s much simpler to say, “it’s too confusing to reason about what this means, so just don’t do it.” |
Excellent! Totally planned it that way 😉 |
Oh I see - in this case it's probably because during the Gonna have a look at it now! |
@johnnyreilly Turns out it's been because of the use of the Should be working now 😄 |
Well done! |
Changes made in this PR will add settings for enabling support for
.cts
and.mts
files to both the webpack config files in the examples and theREADME
file now contain.This is supposed to help users to get the proper
.cts
and.mts
experience out-of-the-box.