Skip to content

Commit

Permalink
WIP - cache after running synth
Browse files Browse the repository at this point in the history
Signed-off-by: Sumu <[email protected]>
  • Loading branch information
sumupitchayan committed Oct 28, 2024
1 parent 31afea1 commit e9cbc48
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions packages/aws-cdk-lib/core/lib/stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,16 @@ export class Stage extends Construct {
const newConstructPaths = new Set<string>();
recurseAndlistAllConstructPaths(this);

// If the assembly cache is uninitiazed, run synthesize and re-run list all construvt paths
if (this.constructPathsCache.size == 0 || !this.assembly || options.force) {
this.assembly = synthesize(this, {
skipValidation: options.skipValidation,
validateOnSynthesis: options.validateOnSynthesis,
});
recurseAndlistAllConstructPaths(this);
this.constructPathsCache = newConstructPaths;
}

// Lists all construct paths
function recurseAndlistAllConstructPaths(construct: IConstruct) {
newConstructPaths.add(construct.node.path);
Expand All @@ -231,15 +241,6 @@ export class Stage extends Construct {
}
}

// If the assembly cache is uninitiazed, run synthesize.
if (this.constructPathsCache.size == 0 || !this.assembly || options.force) {
this.constructPathsCache = newConstructPaths;
this.assembly = synthesize(this, {
skipValidation: options.skipValidation,
validateOnSynthesis: options.validateOnSynthesis,
});
}

// If the construct paths set has changed
if (!constructPathSetsAreEqual(this.constructPathsCache, newConstructPaths)) {
if (options.warnInsteadOfError) {
Expand All @@ -259,6 +260,9 @@ export class Stage extends Construct {
return true;
}

// Reset construct paths
this.constructPathsCache = newConstructPaths;

return this.assembly;
}

Expand Down

0 comments on commit e9cbc48

Please sign in to comment.