Detect .cts and .mts files in loader utils#7131
Detect .cts and .mts files in loader utils#7131htunnicliff wants to merge 2 commits intoyarnpkg:masterfrom
.cts and .mts files in loader utils#7131Conversation
clemyan
left a comment
There was a problem hiding this comment.
You need to run yarn update:pnp:hook to compile and use the hook.
This change enables loading .cts and .mts files, but disables type-stripping entirely for them. You need the commonjs-typescript and module-typescript formats for that.
Please note that not all Node versions we support has type-stripping (and the aforementioned formats), and I don't fully understand how those formats interact with the --experimental-type-stripping and --no-experimental-type-stripping flags across Node versions. You need to factor those into determining what format to use here to match Node's default behavior, and add tests to test for those behavior.
| @@ -0,0 +1,2 @@ | |||
| releases: | |||
| "@yarnpkg/pnp": minor | |||
There was a problem hiding this comment.
plugin-pnp and cli also need releases
What's the problem this PR addresses?
Fixes #6595.
This change lets Yarn's ESM loader correctly detect TypeScript files that use
.mtsor.ctsextensions.How did you fix it?
I updated
getFileFormat()in loaderUtils.ts to treat.mtsas having a "module" format and.ctsas having a "commonjs" format.Checklist