-
-
Notifications
You must be signed in to change notification settings - Fork 160
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
Resolve .tsx + other extensions when importing .js / .jsx files #112
Comments
I'm hitting the same issue. I suspect this will be solved when #344 is. |
To fix this, you will need to patch the resolveTsPath and related mapper. And change it's usage to handle the returned array in a loop at https://github.com/esbuild-kit/cjs-loader/blob/e7ba7caf42cb1bdceacb0bcafd2db3fd747931c0/src/index.ts#L179 |
#344 could be refactored to use this new resolveTsPath |
@mshima I have to confess I didn't try too hard to get into the details, but my use case is with ESM. I patched |
@jraoult great, just saying the reproduction case is commonjs:
For esm, the PR change should fix the issue. |
What extension resolutions do
|
This affects our codebase too, with |
The problem you're describing is different from what the issue is reporting. Please open a new issue with reproduction if it doesn't work for you. |
|
Also hitting this issue. Migrating a codebase to TypeScript and I'm importing a
Using using |
This sounds similar, but not really the same issue that I described above - I am not using any Probably deserves a new issue for this, maybe also good to report one for |
Yep, it's this: #135 |
All TypeScript extensions should be supported now in https://github.com/privatenumber/tsx/releases/tag/v4.0.0 Tests: https://github.com/privatenumber/tsx/blob/v4.0.0/tests/specs/smoke.ts#L515-L533 Hope this new release works well for you! |
@privatenumber Thanks! Can confirm that |
im doing import x from "sample.js" the read file is sample.ts i get Cannot find module. i have TSX version 4.6.2 on node 16.14.2 |
Bug description
Hi there, thanks for
tsx
, looks like a great project! 🙌It would be great if
tsx
could also support the same module resolution thattsc
does - specifically, resolving*.tsx
files when a fully-specified.js
ESM-style import is used.tsc
allows:.js
to resolve.ts
(supported bytsx
).js
to resolve.tsx
(unsupported bytsx
).jsx
to resolve.ts
(unsupported bytsx
).jsx
to resolve.tsx
(unsupported bytsx
)Ref: microsoft/TypeScript#41887 (comment)
More details on what
tsc
andesbuild
currently supportReproduction
However, importing
*.ts
files using a fully-specified.js
path works:Replit demo (use the "Shell" tab): https://replit.com/@karlhorky/JuicySphericalDistributedcomputing#index.ts
Environment
System: OS: Linux 5.15 Ubuntu 20.04.2 LTS (Focal Fossa) CPU: (8) x64 AMD EPYC 7B12 Memory: 51.31 GB / 62.80 GB Container: Yes Shell: 5.0.17 - /bin/bash Binaries: Node: 16.15.0 - /nix/store/amm5j0ag985nh49n096a78q1dfs2xsfn-nodejs-16.15.0/bin/node Yarn: 1.22.18 - /nix/store/lccjrdddvk1bvd8zl29bd09df2z7d5p3-yarn-1.22.18/bin/yarn npm: 8.5.5 - /nix/store/amm5j0ag985nh49n096a78q1dfs2xsfn-nodejs-16.15.0/bin/npm npmPackages: tsx: ^3.9.0 => 3.9.0
Related issues
This is a superset of esbuild-kit/esm-loader#74
Can you contribute a fix?
The text was updated successfully, but these errors were encountered: