-
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: Option to bundle dependencies with multi-file output #26565
Comments
This could use some more specification. What does "bundle" mean in this context? Copy over? Roll into a single file? Something else? Should .d.ts files come along for the ride?
Ship the minimum viable product, add more cruft later as feedback appears 😉
|
Creating individual ts bundles for microservices in a monorepo has become a little bit of a nightmare due to recent improvements in dependency management, ironically. It had been as simple as copying node_modules into dist, zipping, and deploying to aws lambda. Yarn workspaces, project references, and lerna all bring useful tooling but move dependencies into hard-to-reach places via hoisting or other magic. I expect a lot of people to be confused about how to build -> bundle w/ dependencies. Project references and workspaces are alluring but come with some possibly surprising hazards |
Any updates on whether outDir based projects can be prepended? |
Any update on this? |
+1 Would love to see this. |
i would also appreciate this getting a bit more of attention, especially in monorepo scenarios. here's my setup:
now i want to publish packageBTypes to an internal npm repo, but not packageShared. it has only types but also re-exports some types of packageShared. however, i don't want to publish packageShared, which in the end causes issues because of the dependency. so when i install packageBTypes in some third party project, i get an error because packageShared cannot be resolved (of course, i didn't publish it). it would be great if i could move packageShared to devDependencies and use imho it would be best if |
|
Search Terms
"project references" bundle copy dependencies
Suggestion
When using project references, add an option to bundle a project's dependencies when using
outDir
. This would be the analogue ofprepend
, which only works withoutFile
. This would be useful when targeting a module format that doesn't work withoutFile
, such ascommonjs
.Use Cases
Two Stack Overflow questions today:
https://stackoverflow.com/questions/51938528
https://stackoverflow.com/questions/51939395
For the specific case of CommonJS output, I had the idea to generate single-file AMD output and then use
amdefine
to wrap the result as a CommonJS module. This sort of works but is extremely ugly.Edit: I realized that both the
prepend
option and the suggested option are of limited use for composite projects with external dependencies, because a separate tool is needed to aggregate the external dependencies, and that tool may be able to aggregate the components too. Concretely, if the components have external dependencies innode_modules
, then the inter-component dependencies can be added topackage.json
using relative paths andnpm install
will make symlinks undernode_modules
, so if the packaging tool is capable of following those symlinks, it will pack everything up. (A similar technique to make symlinks is possible using yarn workspaces instead of dependencies with relative paths, and has in fact been used to solve https://stackoverflow.com/questions/51939395 .) However, symlink support is still uneven on Windows, as pointed out here.I'm still interested in the rationale for offering
prepend
and not the analogous thing for multi-file output. Was it just thatprepend
was designed to suit the needs of the TypeScript compiler?Examples
Straw-man proposal:
Copies the
outDir
of the referenced project tosome/path
. By specifyingcopyOutDirTo
and the project's ownoutDir
in the correct relationship, one can produce a single output tree in which modules will be able to find each other.Checklist
My suggestion meets these guidelines:
Possibly related
#17611
The text was updated successfully, but these errors were encountered: