-
Notifications
You must be signed in to change notification settings - Fork 2
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
Support tsconfig paths #89
Comments
Hi @prescottprue, I happy to hear that you find my tool valuable. 🙂 I actually implemented support for I also haven't tested TS configs that extend TS configs. I was hoping that https://github.com/dsherret/ts-morph handles this for me under the hood when calling |
Hey @prescottprue, I just tested a few cases... Simple Exportsrc/libs/some-lib.ts export const someLib = {}; src/main.ts Before: import { someLib } from '@libs/some-lib';
console.log(someLib); After running import { someLib } from '@libs/some-lib.js';
console.log(someLib); 👍 - Test Passed Index Exportsrc/libs/some-lib/index.ts export const someLib = {}; src/main.ts Before: import { someLib } from '@libs/some-lib';
console.log(someLib); After running import { someLib } from '@libs/some-lib/index.js';
console.log(someLib); 👍 - Test Passed An import just from Paths in
|
Thanks for the quick response and testing! Maybe I am doing something wrong then? Here is a zip of the repro: Currently I have been doing the transform via |
Thank you for providing the example! The You've raised a valid point, and I'll use it to prepare a fix. ✨ |
Oh awesome, glad to hear! In meantime I'll see if doing that in the existing projects I'm converting fixes it |
Hey @prescottprue, I just released a new minor version. Can you please try again using ts2esm v2.2.0? I've also created a snapshot test for your use case. While doing so, I noticed a bug in the VS Code extension for Vitest. It's always fun to see how everything connects and how software improves with each use case. 🙂 |
Amazing thanks! Oh nice - wasn't aware of that extension for Vitest, I'll for sure start using that. Totally agree on the on improving with each use case and that only happens by OSS maintainers spending the time to checkout issues and replicate exactly like you did - bravo 👏 From the looks of it in my test repo I uploaded in the zip above, I'm still not seeing |
Hi @prescottprue, I just published a lot of improvements with ts2esm v2.2.4 - Can you please run it with the |
Huge thanks for the lib - it has saved countless hours
When a path alias is used via
paths
setting in tsconfig it seems that ts2esm is not converting the import to have.js
suffixIt would be awesome if we could check tsconfig (and even an extends file if one exists - i.e. tsconfig.paths.json referenced in "extends" setting of tsconfig) for
paths
settings - if they are found, make sure to apply suffix to imports using those aliasesExample
tsconfig.json
Would convert the following import:
to
Preferably also handling if the import is pointing to a folder that contains an
index.js
as is currently handled for import conversionsThe text was updated successfully, but these errors were encountered: