lukeed / tsm

TypeScript Module Loader
MIT License
1.18k stars 19 forks source link

Resolve .tsx files from .js extensions #33

Closed karlhorky closed 1 year ago

karlhorky commented 2 years ago

Ref: https://github.com/lukeed/tsm/issues/1#issuecomment-1079169934

lukeed commented 2 years ago

TypeScript doesn't allow imports to *.jsx files right?

karlhorky commented 2 years ago

tsc allows both:

edit: oh wait, did you mean .js resolving to .jsx? ...that doesn't work.

karlhorky commented 2 years ago

Should we add the other transforms for .jsx import paths too?

lukeed commented 2 years ago

No @ jsx updates – that's ridiculous

Please check out the CI results for the test-tsx branch – it replicates your original issue and yet the jsx and tsx files are loaded correctly regardless of the sourcefile's extension and ESM-vs-CJS format.

Edit: It doesn't replicate your issue at all πŸ™ˆ lol 😴

lukeed commented 2 years ago

Can you actually send over a reproduction using ts-node? I can get tsc to not throw errors, but ts-node never actually works or applies any of the resolutions described here or in my updated test files

karlhorky commented 2 years ago

Can you actually send over a reproduction using ts-node?

Sure, here's a Replit: https://replit.com/@karlhorky/SuperbLivelyEditor#index.ts

The start script runs ts-node-esm index.ts

Screen Shot 2022-03-25 at 19 00 17

karlhorky commented 2 years ago

@lukeed just circling back around to this since I noticed a new version of tsm was released.

What do you think about getting a fix in for the inconsistency with the .js fully-specified ESM import paths?

karlhorky commented 1 year ago

Did some more research on what tsc and esbuild supports for extensions over here, also including the latest nodenext options in tsconfig.json:

https://github.com/esbuild-kit/tsx/issues/112#issuecomment-1272577698

karlhorky commented 1 year ago

Nice, tsm@2.3.0 (PR #43) is working, thanks! πŸ™Œ