Skip to content

Commit b5fb8fa

Browse files
committed
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.
1 parent 91b133a commit b5fb8fa

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
@@ -66,12 +66,20 @@ function buildParalleizedBabelPlugin(
6666
};
6767

6868
// parallelBabelInfo will not be used in the cache unless it is explicitly included
69-
let cacheKey = makeCacheKey(templateCompilerPath, pluginInfo, JSON.stringify(parallelBabelInfo));
70-
69+
let cacheKey;
7170
return {
7271
_parallelBabel: parallelBabelInfo,
7372
baseDir: () => __dirname,
74-
cacheKey: () => cacheKey,
73+
cacheKey: () => {
74+
if (cacheKey === undefined) {
75+
cacheKey = makeCacheKey(
76+
templateCompilerPath,
77+
pluginInfo,
78+
JSON.stringify(parallelBabelInfo)
79+
);
80+
}
81+
return cacheKey;
82+
},
7583
};
7684
}
7785

@@ -196,15 +204,20 @@ function setup(pluginInfo, options) {
196204
let htmlbarsOptions = buildOptions(projectConfig, templateCompilerPath, pluginInfo);
197205
let { templateCompiler } = htmlbarsOptions;
198206

199-
let cacheKey = makeCacheKey(templateCompilerPath, pluginInfo);
200-
201207
registerPlugins(templateCompiler, {
202208
ast: pluginInfo.plugins,
203209
});
204210

205211
let { precompile } = templateCompiler;
206212
precompile.baseDir = () => path.resolve(__dirname, '..');
207-
precompile.cacheKey = () => cacheKey;
213+
214+
let cacheKey;
215+
precompile.cacheKey = () => {
216+
if (cacheKey === undefined) {
217+
cacheKey = makeCacheKey(templateCompilerPath, pluginInfo);
218+
}
219+
cacheKey;
220+
};
208221

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

0 commit comments

Comments
 (0)