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

Commit a8c3398

Browse files
Robert Jacksonkrisselden
andcommitted
Make cacheKey calculation lazy
Co-authored-by: Kris Selden <[email protected]>
1 parent 4a5c196 commit a8c3398

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,19 @@ module.exports = {
7878
parallelConfig
7979
}
8080
};
81-
// parallelBabelInfo will not be used in the cache unless it is explicitly included
82-
let cacheKey = AstPlugins.makeCacheKey(templateCompilerPath, pluginInfo, JSON.stringify(parallelBabelInfo));
81+
82+
let cacheKey;
8383
babelPlugins.push({
8484
_parallelBabel: parallelBabelInfo,
8585
baseDir: () => __dirname,
86-
cacheKey: () => cacheKey,
86+
cacheKey: () => {
87+
if (cacheKey === undefined) {
88+
// parallelBabelInfo will not be used in the cache unless it is explicitly included
89+
cacheKey = AstPlugins.makeCacheKey(templateCompilerPath, pluginInfo, JSON.stringify(parallelBabelInfo));
90+
}
91+
92+
return cacheKey;
93+
},
8794
});
8895
}
8996
else {

lib/ast-plugins.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,21 @@ module.exports = {
5353
global.EmberENV = clonedEmberENV;
5454

5555
let Compiler = require(templateCompilerPath);
56-
let cacheKey = this.makeCacheKey(templateCompilerPath, pluginInfo);
56+
let cacheKey;
5757

5858
let precompileInlineHTMLBarsPlugin;
5959

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

6262
let precompile = Compiler.precompile;
6363
precompile.baseDir = () => path.resolve(__dirname, '..');
64-
precompile.cacheKey = () => cacheKey;
64+
precompile.cacheKey = () => {
65+
if (cacheKey === undefined) {
66+
cacheKey = this.makeCacheKey(templateCompilerPath, pluginInfo);
67+
}
68+
69+
return cacheKey;
70+
};
6571

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

0 commit comments

Comments
 (0)