Skip to content

Commit

Permalink
Fixes #2147
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Apr 14, 2022
1 parent 2b18aab commit 0d2171e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/TemplateConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const UserConfig = require("./UserConfig");
const debug = require("debug")("Eleventy:TemplateConfig");
const debugDev = require("debug")("Dev:Eleventy:TemplateConfig");
const deleteRequireCache = require("./Util/DeleteRequireCache");
const eventBus = require("./EventBus");

/**
* @module 11ty/eleventy/TemplateConfig
Expand Down Expand Up @@ -98,8 +99,10 @@ class TemplateConfig {
debugDev("Resetting configuration: TemplateConfig and UserConfig.");
this.userConfig.reset();
this.initializeRootConfig();
this.forceReloadConfig();

this.config = this.mergeConfig();
// Clear the compile cache
eventBus.emit("eleventy.compileCacheReset");
}

/**
Expand All @@ -111,6 +114,14 @@ class TemplateConfig {
// nothing yet
}

/**
* Force a reload of the configuration object.
*/
forceReloadConfig() {
this.hasConfigMerged = false;
this.getConfig();
}

/**
* Returns the config object.
*
Expand Down Expand Up @@ -138,8 +149,7 @@ class TemplateConfig {
debugDev(
"Merging in getConfig again after setting the local project config path."
);
this.hasConfigMerged = false;
this.getConfig();
this.forceReloadConfig();
}
}

Expand All @@ -153,7 +163,7 @@ class TemplateConfig {
this.overrides.pathPrefix = pathPrefix;

if (!this.hasConfigMerged) {
this.getConfig();
this.forceReloadConfig();
}
this.config.pathPrefix = pathPrefix;
}
Expand Down
6 changes: 6 additions & 0 deletions src/TemplateContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ class TemplateContent {
str,
bypassMarkdown
);

if (cacheable && key) {
if (cache.has(key)) {
this.bench.get("Template Compile Cache Hit").incrementCount();
Expand Down Expand Up @@ -514,4 +515,9 @@ eventBus.on("eleventy.resourceModified", (path) => {
TemplateContent.deleteCached(path);
});

// Used when the configuration file reset https://github.com/11ty/eleventy/issues/2147
eventBus.on("eleventy.compileCacheReset", (path) => {
TemplateContent._compileEngineCache = new Map();
});

module.exports = TemplateContent;

0 comments on commit 0d2171e

Please sign in to comment.