-
Notifications
You must be signed in to change notification settings - Fork 4
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
Doesn't handle dynamic imports #100
Comments
@amannn sorry for replying after 1 week, been busy, and yes you are right, dynamic imports should be handled. Again apologise that u had to use explicit file extensions everywhere |
Absolutely not your fault! Thanks anyway for building this tool, I was a bit surprised that this tooling gap in tsc actually exists … Feel free to close this issue if you don’t intend to support this! |
@amannn dynamic import case is handled, but is only limited to dynamic import with static string literal/template literal. Meaning - any dynamic import with path value that can only be obtained through runtime will not be handled, which is intended and AST alone can't resolve those kinds of stuffs however, I do need help in making sure that I only alter dynamic import with string literal/template literal, if u can help me break the existing test b4 I publish it, that would be really helpful -> https://github.com/GervinFung/ts-add-js-extension/blob/fix/dynamic-imports/test/process/source/js/util/invalid-dynamic-import.js |
My apologies, what would you like me to do? 😄 My original use case was static imports, so that should be covered then as far as I understand. However, as mentioned above, I've anyway migrated to explicit file extensions now … |
I understand that u've manually added file extensions, I need help as in, are there any other ways to do "dynamic" value with static string? Without using variable/array The 3 ways u've seen above are the only few ways I can come up with, if u can come up with more ways that i couldn't think of, that would be really helpful. Cos im trying to make sure i dont alter the wrong dynamic imports |
I guess there can be some more: // All kinds of string methods
import(str.substr(…));
import(['./module', 'c'].join(''))
// Completely dynamic
import(getPath());
import(path); |
Thanks for coming up with other variations, but variable/function/array can ve safely ignored. I only handle the case if the token after the |
First of all, thanks a bunch for this package! I just realized today that apparently neither
tsc
nor@rollup/plugin-typescript
are capable of outputting correct declaration files for an ESM package.While trying
ts-add-js-extension
out on a project, I noticed one error though: Dynamic imports aren't rewritten correctly (reproduction).Do you think that's in scope for this project?
EDIT: I think I'll just bite the bullet and use explicit file extensions everywhere 😔
The text was updated successfully, but these errors were encountered: