Skip to content
This repository has been archived by the owner on Feb 6, 2021. It is now read-only.

Make cacheKey calculation lazy #408

Merged
merged 1 commit into from
Feb 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,19 @@ module.exports = {
parallelConfig
}
};
// parallelBabelInfo will not be used in the cache unless it is explicitly included
let cacheKey = AstPlugins.makeCacheKey(templateCompilerPath, pluginInfo, JSON.stringify(parallelBabelInfo));

let cacheKey;
babelPlugins.push({
_parallelBabel: parallelBabelInfo,
baseDir: () => __dirname,
cacheKey: () => cacheKey,
cacheKey: () => {
if (cacheKey === undefined) {
// parallelBabelInfo will not be used in the cache unless it is explicitly included
cacheKey = AstPlugins.makeCacheKey(templateCompilerPath, pluginInfo, JSON.stringify(parallelBabelInfo));
}

return cacheKey;
},
});
}
else {
Expand Down
10 changes: 8 additions & 2 deletions lib/ast-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,21 @@ module.exports = {
global.EmberENV = clonedEmberENV;

let Compiler = require(templateCompilerPath);
let cacheKey = this.makeCacheKey(templateCompilerPath, pluginInfo);
let cacheKey;

let precompileInlineHTMLBarsPlugin;

pluginInfo.plugins.forEach((plugin) => Compiler.registerPlugin('ast', plugin));

let precompile = Compiler.precompile;
precompile.baseDir = () => path.resolve(__dirname, '..');
precompile.cacheKey = () => cacheKey;
precompile.cacheKey = () => {
if (cacheKey === undefined) {
cacheKey = this.makeCacheKey(templateCompilerPath, pluginInfo);
}

return cacheKey;
};

let modulePaths = ['ember-cli-htmlbars-inline-precompile', 'htmlbars-inline-precompile'];
precompileInlineHTMLBarsPlugin = [HTMLBarsInlinePrecompilePlugin, { precompile, modulePaths }];
Expand Down