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
ignored()
bug: ESM loader will try to compile .cjs, .mjs, and other unexpected file extensions
#1098
Comments
Is it fine if I author a pull request for this? I was thinking of reusing the conditions from the exported function const ignored = (fileName: string) => {
if (!active) return true
const ext = extname(fileName)
const extensions = getExtensions(config)
if (extensions.tsExtensions.includes(ext) || extensions.jsExtensions.includes(ext)) {
const relname = relative(cwd, fileName)
return !isScoped(relname) || shouldIgnore(relname)
}
return true
} Would this change be acceptable? |
Absolutely, we're happy for the help.
I'm not sure if extname will handle Other than that, looks good to me. |
My thought process was to invoke
|
#1103) * Fix #1098: `ignored()` bug: ESM loader will try to compile .cjs, .mjs, and other unexpected file extensions * tests: Add test matrix for ignored() to ensure only specific extensions are sent to TypeScript compiler * feat: Changed ESM getFormat to use a Register.ignored() lookup * Add .d.ts extension to tests Co-authored-by: Andrew Bradley <cspotcode@gmail.com>
ESM loader uses our current
ignored()
implementation to determine if it should transform a file. This only excludes the .js and .jsx file extensions as needed. This worked fine with our CommonJS loader, because we knew we were only registered for the .ts, .tsx, and maybe .js and .jsx extensions.The ESM loader is different, so it's asking
ignore()
about .mjs files. (maybe other extensions too?)We need to update the
ignored()
implementation to include rather than exclude file extensions so that we only transform the same files thattsc
can transform.ts-node/src/index.ts
Lines 837 to 845 in ce7c323
The text was updated successfully, but these errors were encountered: