-
-
Notifications
You must be signed in to change notification settings - Fork 169
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 for using alias paths in the package #348
Comments
You're on the right path. If you want to use aliases within a package then you need to configure those aliases for all its consumers as well. Either you do it per package like in the commit you linked, or you centralize them in the monorepo root. The above is necessary if you want "live types" e.g. Go to definition and type errors work as expected without first having to build the projects. If you're fine with building [some] packages first, then you can define the aliases just once and then use a toolchain that rewrites those aliases when building e.g. webpack. For me, the possibility of not getting the intended outcome because I forgot to build some package first outweighs the alternative of some duplication in the configs. |
Yes, but the toolchains can also read the same configs and rewrite the aliases. If a package is using aliases it can have downstream effects.
If you remove them from
It goes beyond the scope of this project, which is providing a good DX for navigating between packages in a monorepo. Using aliases inside a package can improve the DX for that package specifically (by shortening imports), but it will have downstream effects, by forcing the consumers to duplicate the aliases (or hoisting them in the root). The same would apply if a package imported non-TS files e.g. I just remembered that there's an open discussion #322 about this same topic, so I'll close this issue and pin it to help others find the discussion. Feel free to keep the linked discussion going. |
Hi, sorry to bother you again.
I have been using your solution to build my project and encountered a challenge that I need some assistance with. Specifically, I am trying to create alias paths in a package shared by multiple apps.
I reviewed your
apps/cra
folder and noticed the@hooks/
alias example. However, this approach did not work for me, as the alias paths are located in the apps folder. I searched through the issues using the keyword alias but could not find a solution that addresses my problem.I attempted to modify the tsconfig.json file in the package/foo example to include an alias path, and while the IDE did not raise any alerts, the alias paths were not recognized by webpack during packaging. To resolve this, I had to add the alias @foo/ to the apps/webpack/tsconfig.json file.
Here is the change I made: Commit Link.
I am wondering if there is a better way to create alias paths in the package folder. It feels unusual to write alias paths in the apps' tsconfig.json, but I am unsure of a better approach.
Thank you for your time.
Best regards
The text was updated successfully, but these errors were encountered: