-
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
Project References Wildcards #56279
Comments
Projects must be acyclic; how would that work if one globs over every project in the dependencies of every project? Even if cycles were legal, it seems like a bad idea to allow configuration that makes it easy for every project to depend on every other project; at that point it's back to a monolith that all has to be recompiled. Though, I suppose with the potential for alternative config options, at least. |
I would agree with @jakebailey. If you want to build only If you ware using pnpm/yarn/npm workspaces you still need to specify the exact dependencies in I would of course be nice if this functionality was built into |
I'll note that if you're using declaration maps and a package manager with monorepo support (with explicit deps), it may be entirely possible to not use references at all, and just build each project individually. There are downsides, of course, but at that point with say pnpm's dependency aware script running, you're basically just using packages as they'd be viewed when published (but locally). |
Yes, in this small example building each package separately may be feasible. However having to restart |
You guys all make great points. What if we had one of the following options to reduce the repetitiveness? {
"extends": ["../../../tsconfig.base.json"],
"references": "inherit" ^^ This leads to the same problems you're all talking about, but it might be nice to have the option to inherit. Especially in cases where (in my project) I have a The other option would be basically a shorthand for the {
"extends": "../../../tsconfig.base.json",
"references": ["../../libs/lib-1", "../../libs/lib-2", ...]
} But we could make it a dual typed field. It's an array of either string, or an options object with |
What in what situation do you need both of these? I can only think of a situation where you have a tsconfig to load all workspace code to avoid project reference overhead, but that only helps when you have a significantly large number of packages. |
|
I have personally more often seen tests in separate projects (what we do in TS, dt-tools), or one project that always builds tests with exclusions elsewhere (e.g., npmignore, what I do in my packages). But, I of course have my own narrow lens. |
My thinking was that this is useful (only) for the top-level "solution" tsconfig
so that you don't have to list out all the |
We co-locate the tests with the other code which I think is quite common in the javascript community. If you change the application code you may break the compile of the test code and vice versa so IMO it does not make sense to compile them separately. It does make sense to not distribute the test files in production builds, but I see compile and distribution are separate things. However as mentioned all these points are personal preferences. |
Instead of having to specify the references param, could it instead infer it from the package.json dependencies which use the workspace syntax? Right now I'm basically copying both lists back and forth to keep them in sync. |
@Qrokqt If you are manually keeping tsconfig references and package.json in sync you may be interested in automating that with meta-updater or workspaces-to-typescript-project-references |
π Search Terms
"project references" "glob" "wildcard" "repetitive" "monorepo"
β Viability Checklist
β Suggestion
Project References currently have to be written out explicitly. It would be super nice if we could use a wildcard/glob like this, where I could simply have all of my
tsconfig.json
files look like this:Or, even something like this:
We can discuss below whether supporting globstars (
**
) is prudent or not.π Motivating Example
I've got a project with 8 libs and 3 apps using project references. It follows this basic structure:
There's a little more complexity, but that's the basic idea. However, I have a ton of repetition between all my
tsconfig.json
files that basically all look like this:I can't rely on the
extends
functionality fromtsconfig.base.json
because of things like @RyanCavanaugh's explanation here: #27098 (comment).π» Use Cases
"references"
portion for every single app/lib that needs to be able to import shared libraries.The text was updated successfully, but these errors were encountered: