Skip to content

Commit 5d06fd0

Browse files
committed
fix(tests): Upgrade webpack-recompilation-simulator
1 parent fa7f9a8 commit 5d06fd0

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ class HtmlWebpackPlugin {
8787
// Clear the cache once a new HtmlWebpackPlugin is added
8888
childCompiler.clearCache(compiler);
8989

90-
compiler.hooks.compilation.tap('HtmlWebpackPlugin', (compilation) => {
90+
// Clear the cache if the child compiler is outdated
91+
compiler.hooks.thisCompilation.tap('HtmlWebpackPlugin', (compilation) => {
9192
if (childCompiler.hasOutDatedTemplateCache(compilation)) {
9293
childCompiler.clearCache(compiler);
9394
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"url-loader": "^0.5.7",
4747
"webpack": "4.8.3",
4848
"webpack-cli": "2.0.12",
49-
"webpack-recompilation-simulator": "^1.3.0"
49+
"webpack-recompilation-simulator": "^2.0.1"
5050
},
5151
"dependencies": {
5252
"@types/tapable": "1.0.2",

spec/CachingSpec.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jasmine.getEnv().defaultTimeoutInterval = 30000;
1919
function setUpCompiler (htmlWebpackPlugin) {
2020
spyOn(htmlWebpackPlugin, 'evaluateCompilationResult').and.callThrough();
2121
var webpackConfig = {
22+
// Caching works only in development
23+
mode: 'development',
2224
entry: path.join(__dirname, 'fixtures/index.js'),
2325
output: {
2426
path: OUTPUT_DIR,
@@ -53,6 +55,7 @@ describe('HtmlWebpackPluginCaching', function () {
5355
});
5456
var childCompilerHash;
5557
var compiler = setUpCompiler(htmlWebpackPlugin);
58+
compiler.addTestFile(path.join(__dirname, 'fixtures/index.js'));
5659
compiler.run()
5760
// Change the template file and compile again
5861
.then(function () {
@@ -77,6 +80,7 @@ describe('HtmlWebpackPluginCaching', function () {
7780
var htmlWebpackPlugin = new HtmlWebpackPlugin();
7881
var compiler = setUpCompiler(htmlWebpackPlugin);
7982
var childCompilerHash;
83+
compiler.addTestFile(path.join(__dirname, 'fixtures/index.js'));
8084
compiler.run()
8185
// Change a js file and compile again
8286
.then(function () {
@@ -104,6 +108,7 @@ describe('HtmlWebpackPluginCaching', function () {
104108
});
105109
var childCompilerHash;
106110
var compiler = setUpCompiler(htmlWebpackPlugin);
111+
compiler.addTestFile(path.join(__dirname, 'fixtures/index.js'));
107112
compiler.run()
108113
// Change a js file and compile again
109114
.then(function () {
@@ -132,7 +137,7 @@ describe('HtmlWebpackPluginCaching', function () {
132137
});
133138
var childCompilerHash;
134139
var compiler = setUpCompiler(htmlWebpackPlugin);
135-
compiler.simulateFileChange(template, {footer: '<!-- 0 -->'});
140+
compiler.addTestFile(template);
136141
compiler.run()
137142
// Change the template file and compile again
138143
.then(function () {
@@ -161,8 +166,8 @@ describe('HtmlWebpackPluginCaching', function () {
161166
template: template
162167
});
163168
var compiler = setUpCompiler(htmlWebpackPlugin);
164-
compiler.simulateFileChange(template, {footer: ' '});
165-
compiler.simulateFileChange(jsFile, {footer: ' '});
169+
compiler.addTestFile(template);
170+
compiler.addTestFile(jsFile);
166171
// Build the template file for the first time
167172
compiler.run()
168173
// Change the template file (second build)

0 commit comments

Comments
 (0)