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 <kselden@linkedin.com>
  • Loading branch information
rwjblue and krisselden committed Feb 5, 2021
1 parent 4a5c196 commit a8c3398
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
13 changes: 10 additions & 3 deletions index.js
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
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

0 comments on commit a8c3398

Please sign in to comment.