From f194a746ad41c908a9d9e2ad65117ec47e4b408d Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Wed, 4 Sep 2024 14:04:28 -0500 Subject: [PATCH] Fixes #3410 --- src/GlobalDependencyMap.js | 9 +++++++++ src/Template.js | 4 ++-- src/TemplateWriter.js | 6 +++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/GlobalDependencyMap.js b/src/GlobalDependencyMap.js index f66af2f81..caeff6232 100644 --- a/src/GlobalDependencyMap.js +++ b/src/GlobalDependencyMap.js @@ -373,6 +373,7 @@ class GlobalDependencyMap { } // The file that changed is a dependency of the template + // comparisonFile is used by fullTemplateInputPath if (this.hasDependency(fullTemplateInputPath, comparisonFile, includeLayouts)) { return true; } @@ -380,6 +381,14 @@ class GlobalDependencyMap { return false; } + isFileUsedBy(parent, child, includeLayouts) { + if (this.hasDependency(parent, child, includeLayouts)) { + // child is used by parent + return true; + } + return false; + } + stringify() { return JSON.stringify(this.map, function replacer(key, value) { // Serialize internal Map objects. diff --git a/src/Template.js b/src/Template.js index ae3058c05..04d4bbfcf 100755 --- a/src/Template.js +++ b/src/Template.js @@ -889,7 +889,7 @@ class Template extends TemplateContent { let content; // Note that behavior.render is overridden when using json or ndjson output - if (page.template.behavior.isRenderable()) { + if (page.template.isRenderable()) { // this reuses page.templateContent, it doesn’t render it content = await page.template.renderPageEntry(page); } @@ -918,7 +918,7 @@ class Template extends TemplateContent { continue; } - if (!page.template.behavior.isRenderable()) { + if (!page.template.isRenderable()) { debug("Template not written %o from %o.", page.outputPath, page.template.inputPath); continue; } diff --git a/src/TemplateWriter.js b/src/TemplateWriter.js index c747ad042..7b596188e 100755 --- a/src/TemplateWriter.js +++ b/src/TemplateWriter.js @@ -142,7 +142,6 @@ class TemplateWriter { _createTemplate(path, to = "fs") { let tmpl = this._templatePathCache.get(path); - let wasCached = false; if (tmpl) { wasCached = true; @@ -233,8 +232,13 @@ class TemplateWriter { isFullTemplate: incrementalFileShape === "template", }) ) { + // changed file is used by template + // template uses the changed file tmpl.setRenderableOverride(undefined); // unset, probably render secondOrderRelevantLookup[tmpl.inputPath] = true; + } else if (this.config.uses.isFileUsedBy(this.incrementalFile, tmpl.inputPath)) { + // changed file uses this template + tmpl.setRenderableOverride("optional"); } else { // For incremental, always disable render on irrelevant templates tmpl.setRenderableOverride(false); // disable render