Skip to content

Commit 7a489a5

Browse files
krisseldenRobert Jackson
authored andcommitted
Make cacheKey lazy
Right now cacheKey is eagerly made during the included hook. This is problematic if you have configuration and addons working together. This defers making the cacheKey until it is requested during build. (cherry picked from commit b5fb8fa)
1 parent 4ec05dd commit 7a489a5

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

lib/utils.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,20 @@ function buildParalleizedBabelPlugin(pluginInfo, templateCompilerPath, isProduct
5959
};
6060

6161
// parallelBabelInfo will not be used in the cache unless it is explicitly included
62-
let cacheKey = makeCacheKey(templateCompilerPath, pluginInfo, JSON.stringify(parallelBabelInfo));
63-
62+
let cacheKey;
6463
return {
6564
_parallelBabel: parallelBabelInfo,
6665
baseDir: () => __dirname,
67-
cacheKey: () => cacheKey,
66+
cacheKey: () => {
67+
if (cacheKey === undefined) {
68+
cacheKey = makeCacheKey(
69+
templateCompilerPath,
70+
pluginInfo,
71+
JSON.stringify(parallelBabelInfo)
72+
);
73+
}
74+
return cacheKey;
75+
},
6876
};
6977
}
7078

@@ -188,15 +196,20 @@ function setup(pluginInfo, options) {
188196
let htmlbarsOptions = buildOptions(projectConfig, templateCompilerPath, pluginInfo);
189197
let { templateCompiler } = htmlbarsOptions;
190198

191-
let cacheKey = makeCacheKey(templateCompilerPath, pluginInfo);
192-
193199
registerPlugins(templateCompiler, {
194200
ast: pluginInfo.plugins,
195201
});
196202

197203
let { precompile } = templateCompiler;
198204
precompile.baseDir = () => path.resolve(__dirname, '..');
199-
precompile.cacheKey = () => cacheKey;
205+
206+
let cacheKey;
207+
precompile.cacheKey = () => {
208+
if (cacheKey === undefined) {
209+
cacheKey = makeCacheKey(templateCompilerPath, pluginInfo);
210+
}
211+
cacheKey;
212+
};
200213

201214
let plugin = [
202215
require.resolve('babel-plugin-htmlbars-inline-precompile'),

0 commit comments

Comments
 (0)