-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Module resolution strategy for libraries created in Typescript #11809
Comments
why is that? what is write |
You mean that you just should not use absolute paths for code that is going to be published somewhere? |
UMD declaration files allow relative imports. It is only global/ambient ones that do not. All of our (@dojo) distributable packages have relative mids in their |
How is your library going to be used? |
Compiled with TSC as |
then do not use if you are using node packages, use relative imports for files within your package, and non-relative (i.e. do not start with |
Alright then, thank you very much. |
It would be great if you could use absolute paths when creating reusable Typescript libraries, but as of now it looks like Typescript code with absolute paths is not easily reusable by other projects as every consumer would have to map the absolute paths to relative ones.
TypeScript Version: 2.0.3
Say you have a tsconfig as follows:
The project is structure like this:
tsconfig.json
src/
Inside your library you can now import modules as follows:
Actual behavior:
Compiled with
tsc
your commonjs modules now reference "core/X" and consumers of your library don't know where to find "core/X", the same is true for declaration files.Expected behavior:
You can either let tsc convert absolute paths to relative ones or provide an exportable path mapping.
From issue 5039:
That means rewriting to relative paths is no option, what is the option then?
The text was updated successfully, but these errors were encountered: