feat(build): support copying library assets in monorepo builds#3423
Open
maruthang wants to merge 1 commit into
Open
feat(build): support copying library assets in monorepo builds#3423maruthang wants to merge 1 commit into
maruthang wants to merge 1 commit into
Conversation
add a new opt-in flag (compileroptions.includelibraryassets and --include-library-assets cli flag) that, when enabled, copies assets from sibling library projects in a nest monorepo to the app's outdir. default behavior is unchanged. closes nestjs#681
| .option( | ||
| '--include-library-assets', | ||
| 'Also copy assets from library projects when building an app in a monorepo.', | ||
| ) |
Member
There was a problem hiding this comment.
any chance we could remove this flag and just rely only on the nest-cli configuration?
Member
|
Just checking if you're still interested in working on this PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
Please check if your PR fulfills the following requirements:
nestjs/docs.nestjs.comrepo and can be updated there once the API is finalized.PR Type
What kind of change does this PR introduce?
Note: while this is shipped as an opt-in feature flag, it addresses a long-standing reported bug (#681, open since 2020) where library
assetsare silently dropped during monorepo app builds.What is the current behavior?
Issue Number: 681
In a Nest monorepo, when you build an application project (
nest build my-app), anyassetsconfigured on sibling library projects innest-cli.jsonare silently dropped — only the app's own assets get copied tooutDir. This forces consumers to either duplicate asset declarations on every app or work around it with custom build scripts.What is the new behavior?
A new opt-in flag is introduced. When enabled, assets configured on library projects in the monorepo are copied to the building app's
outDiralongside that app's own assets.Two equivalent ways to enable it:
Per-project / global config in
nest-cli.json:{ "compilerOptions": { "includeLibraryAssets": true } }CLI flag:
Default behavior is unchanged — the flag is off by default, so existing monorepos see no difference.
Files changed
actions/build.action.ts— read the new flag, merge library assets into the assets list passed toAssetsManagerwhen enabled.commands/build.command.ts— register the--include-library-assetsCLI option.lib/configuration/configuration.ts— addincludeLibraryAssets?: booleantoCompilerOptions.lib/compiler/helpers/get-value-or-default.ts— recognize the new option for the standard config-resolution chain (CLI > project > root > default).test/actions/build.action.spec.ts— 7 new tests covering: flag off (default, no library assets copied), flag on via config, flag on via CLI, CLI override, no libraries case, multiple libraries, and library with no assets.test/lib/compiler/assets-manager.spec.ts— 3 new tests covering merging behavior inAssetsManageritself.Does this PR introduce a breaking change?
The flag defaults to
false, preserving the existing (broken-but-stable) behavior for everyone who hasn't explicitly opted in.Other information
This implementation follows the proposal by
@yogeshwaran-cin the #681 thread (April 2026). The proposal has not been explicitly acknowledged by maintainers in the thread, so the design is open for redirection — happy to rework if maintainers prefer a different approach, e.g.:Closes #681