Skip to content

Commit

Permalink
Fixes #3410
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Sep 4, 2024
1 parent 8dbab69 commit f194a74
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
9 changes: 9 additions & 0 deletions src/GlobalDependencyMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,22 @@ 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;
}

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.
Expand Down
4 changes: 2 additions & 2 deletions src/Template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 5 additions & 1 deletion src/TemplateWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ class TemplateWriter {

_createTemplate(path, to = "fs") {
let tmpl = this._templatePathCache.get(path);

let wasCached = false;
if (tmpl) {
wasCached = true;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f194a74

Please sign in to comment.