-
Notifications
You must be signed in to change notification settings - Fork 6
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
Do you plan to support glob, alias & index imports? #1
Comments
Thanks for the suggestion. The current design require a entry file to start the fixing. I just known esm will/has support index import, will try to implement it. I'm not sure if it worth to implement glob, you may use an index file as the entry file. |
I seldom use alias import, but would be interested to implement it as well. PR is also welcomed :) |
In browser importmaps are not supported globs yet. That's why we forced to hardcode all aliased esm imports! =( |
For TypeScript I use tsconfig paths, and there no need for your module. I'm looking solution for js-project only (without bundlers & their plugins, nodejs script utilites only). |
Also you can read my translated gist (original gist) |
Why would you need glob matching the files? I'm thinking use case requiring that need to scan the js files that are not imported directly or indirectly by the entry file. |
Globs for matching alias-imports strings to solve them with mapping, like eslint does or webpack. |
I've encountered a use case that glob may help: when publishing a npm package that as multiple bin files, each file may need to be fixed. |
Workaround for above use case is to write an index js that imports each cli js files, then use this index js as the entry point for fix-esm-import-path to fix the files, but do not publish this index js, otherwise it will invoke all the cli. This is a sub-optimal solution. I want to avoid direct support on glob to reduce the complexity. Maybe allow to use a directory as entry point will be enough for most use case? e.g. |
Just published fix-esm-import-path@1.2.0 which allows using directory as entry point, it recursively scan and fix all js and ts files under the given directory. Will look into tsconfig alias support |
For tsconfig alias you can investigate tsconfig-paths. |
You can also see tsc-alias which generates relative paths |
@beenotung Thanks for this great package, do you plan on supporting index imports? Or would you be able to point in the direction for me look into adding support to it in the current codebase? |
@nicholasio index imports support is discussed in #11 and released in fix-esm-import-path@1.8.0 🚀 |
For example: "fixpaths":
"fix-esm-import-path dist/**/*.js"
or with file structure:
GreeterUse/use.js has code with alias:
import * from '@common/Greeter'
The text was updated successfully, but these errors were encountered: