-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add support for multiple tsconfig paths #79
Add support for multiple tsconfig paths #79
Conversation
This seems pretty useful! I was going to ask if this plugin could support an array of @jonaskello, any thoughts on this? |
This is a very good addition to the plugin for monorepo scenarios. 👏 I have a situation where a have different alias in different packages and I want to resolve all in the storybook based on the I like the idea that @jgornick gave about adding an array of Also, any reason why this PR is not merged yet? I am very interested in helping add this feature to the plugin if somebody needs help to do it 😁 @jonaskello any thoughts on this PR? |
I see TypeScript But could be nice to have support array of tsconfig for these use cases:
Is just an idea, if that make sense, we could add this as well. If not, it is okay to leave as it is right now. 👍🏻 |
The 2nd should already be handled. Extending tsconfigs is a common pattern.
Id love to hear about your use case for item 1 though. Do references not
meet your needs?
On Sat, Jan 15, 2022 at 9:59 PM Jonathan Célio ***@***.***> wrote:
I see TypeScript reference config as the official solution to the
problem, and it looks like this PR is solving it. That is awesome, if we
could merge it would be great!
But could be nice to have support array of tsconfig for these use cases:
1. In situations where you don't have references configured. (I am
working in a project where references are not necessary)
2. To override or extend the tsconfig files paths (as baseUrl do in
this plugin, for example, is changing the behavior from tsconfig)
Is just an idea, if that make sense, we could add this as well. If not, is
okay to leave as it is right now. 👍🏻
—
Reply to this email directly, view it on GitHub
<#79 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA3BDWCKF4IU4R3IR6RXRB3UWIX7PANCNFSM46XZTF2A>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Will Lynch
***@***.***
925-330-1622
President and Treasurer
Manchester Makerspace
***@***.***
Software Developer
Oracle + Dyn
***@***.***
|
TLDR: I could use it, but in my case is not necessary and doesn't solve any problem in my project Use case exampleI can give some context. The project looks like this:
The idea is that all packages have their own alias. That is fine if you think them isolated, but I am also using Storybook in the root to show all Vue components of both packages. Since all of them have their own alias, storybook (with webpack) is struggling to resolve the alias. So there is the need of this plugin. About the referencesI am neither using I think that I can use reference in this case too, just to make this plugin work, but could be nice if this PR support other tsconfig files in situations like this, since not every monorepo setup uses TypeScript docs
|
@jonyw4 Why not use references though? Using reference isn't just for build and watch. You'll see the speed improvements using those commands, but more generally, references enforce logical grouping of TS applications. Your project structure seems appropriately suited to references. I cant really see a reason to create a new pattern of arrays of tsconfig files rather than using the existing reference pattern. |
I think I cover all the reasons why I am not using the references in the last comment and also a situation where that is not necessary. This is one case, but I am sure that must be other cases as well. In my situation, I don't mind changing my project to use Also, personally, I think that this PR is good to be merged. This feature that I am describing, is an idea to cover those situations. We could do it in the future by the need of other developers. |
Seems like the consensus is that this is a good feature to add. I'm planning to make a new major release because of #90. @lynch16 Could you add information in the README file about this new option? If possible some tests to cover this feature would be nice too. After that I think we could merge it for release in next major. |
I think that it is very necessary feature when you have several tsconfig files in separate folders and each of them defines its own paths rules. |
3590935
to
f4e42e9
Compare
@jonaskello Sorry for the long wait. Updated readme and added a test. LMK what you think |
No need to apologize @lynch16! It's open-source software 😄 Even though it's not my project/PR, thank you for the contribution though! |
Is there any way to move this PR forward? Can I help? 🙏 |
When bundling a monorepo, webpack doesn't know how to resolve conflicting tsconfig paths
package1
package2
In the above example, if package2.folderA.file2 calls import { foo } from "folderA/file1", tsconfig-paths will resolve the path to package1.folderA.file. The tsc command succeeds b/c TS supports "references" which will bundle projects in a specific order using their respective tsconfig.
tsconfig-paths does not support references
#44
dividab/tsconfig-paths#163
This adds an option for defining "references" so that paths relative to other tsconfig files will be resolved correctly.