Skip to content

feat(cli): defer bundler builds for stacks not targeted by cli commands - #617

Open
eduardomourar wants to merge 2 commits into
open-constructs:mainfrom
eduardomourar:feat/cli-defer-bundler
Open

eduardomourar wants to merge 2 commits into
open-constructs:mainfrom
eduardomourar:feat/cli-defer-bundler

Conversation

@eduardomourar

@eduardomourar eduardomourar commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Related issue

Fixes #583

Description

diff, deploy, destroy, and output now pass their stack selector into synth, so the app knows which stacks this run will actually use.

TerraformAsset skips its (deferred, SOURCE-hashed) bundler build for a stack outside that selector, instead of bundling every stack's assets on every run. It still writes that stack's manifest entry, and leaves its existing staged output as is.

The CLI forwards the selector through a new BUNDLING_STACKS_CONTEXT_KEY context value. stackRequiresBundling() matches a stack name against it using the same glob patterns the CLI's own --stack selectors accept (minimatch, now a dependency of cdktn).

Dependency stacks are not auto-included — only the stacks named on the command line are bundled. Resolving dependencies needs the manifest this synth produces, so it is not available yet.

Checklist

  • I have updated the PR title to match CDKTN's style guide
  • I have run the linter on my code locally
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation if applicable
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works if applicable
  • New and existing unit tests pass locally with my changes

@eduardomourar
eduardomourar requested a review from a team as a code owner November 14, 2026 18:14
Adding it as a bundled dependency broke `npm pack` during the cdktn
package step in CI ("Exit handler never called!"). Stack selectors
only need `*`/`?` wildcards, so match them with a small inline regex
translator instead of a new dependency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lib, cli: cdktn synth <stack> runs the bundlers of every stack

1 participant