privatenumber / tsx

⚡️ TypeScript Execute | The easiest way to run TypeScript in Node.js
https://tsx.is
MIT License
8.61k stars 132 forks source link

ERR_UNKNOWN_FILE_EXTENSION with `import 'tsx'`, but `--import tsx` works #572

Closed SystemParadox closed 3 weeks ago

SystemParadox commented 3 weeks ago

Acknowledgements

Minimal reproduction URL

https://stackblitz.com/edit/node-57nwqh?file=index.mjs

Problem & expected behavior (under 200 words)

Bugs are expected to be fixed by those affected by it

Compensating engineering work financially will speed up resolution

privatenumber commented 3 weeks ago

Your minimal repro doesn't use tsx.

SystemParadox commented 3 weeks ago

Oops sorry, looks like that got removed while I was testing. I have put the import 'tsx' back in but the result is exactly the same.

privatenumber commented 3 weeks ago

Addressed via https://github.com/privatenumber/tsx/commit/9f04dae4167bfeadf7f69920958bb19f86572a08

SystemParadox commented 3 weeks ago

Ok thanks. I did wonder if this might be the answer but I'm not entirely clear on the reason for it. My understanding was that all of import 'tsx' should execute first (which would include the register call) before we try to import './foo.ts'.

Possibly something to do with parallelisation? Or is it just that node doesn't want to complicate things by allowing hooks to be added within the loading of a file?