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

Commit

Permalink
Make cacheKey calculation lazy
Browse files Browse the repository at this point in the history
Co-authored-by: Kris Selden <[email protected]>
rwjblue and krisselden committed Feb 5, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 4a5c196 commit a8c3398
Showing 2 changed files with 18 additions and 5 deletions.
13 changes: 10 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -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 {
10 changes: 8 additions & 2 deletions lib/ast-plugins.js
Original file line number Diff line number Diff line change
@@ -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 }];

0 comments on commit a8c3398

Please sign in to comment.