Skip to content

Commit fc86088

Browse files
committed
fix: issue file is not resolved after start->stop->start in serve/watch mode when used cache filesystem, #114
1 parent a8b04dd commit fc86088

37 files changed

Lines changed: 858 additions & 904 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Change log
22

3+
## 4.1.2 (2024-10-21)
4+
5+
- fix: issue `file is not resolved` after start->stop->start in serve/watch mode when used cache filesystem, #114
6+
- chore: update dev packages
7+
38
## 4.1.1 (2024-10-17)
49

510
- fix: after 2-3 changes of the data file (global or entry), the dependent entry template is not recompiled.

package-lock.json

Lines changed: 810 additions & 867 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "html-bundler-webpack-plugin",
3-
"version": "4.1.1",
3+
"version": "4.1.2",
44
"description": "HTML Bundler Plugin for Webpack renders HTML templates containing source files of scripts, styles, images. Supports template engines: Eta, EJS, Handlebars, Nunjucks, Pug, TwigJS. Alternative to html-webpack-plugin.",
55
"keywords": [
66
"html",
@@ -194,7 +194,7 @@
194194
"typescript": "5.5.4",
195195
"vue": "3.5.3",
196196
"vue-loader": "^17.4.2",
197-
"webpack": "^5.94.0",
197+
"webpack": "^5.95.0",
198198
"webpack-cli": "5.1.4",
199199
"webpack-dev-server": "^5.1.0"
200200
}

src/Plugin/AssetCompiler.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ class AssetCompiler {
319319
});
320320
});
321321

322-
compiler.cache.hooks.shutdown.tap({ name: pluginName, stage: Cache.STAGE_DISK }, () => {
322+
compiler.cache.hooks.shutdown.tapAsync({ name: pluginName, stage: Cache.STAGE_DISK }, () => {
323323
if (!isCached) {
324324
const cacheData = collectionCache.getData();
325325

@@ -1558,6 +1558,7 @@ class AssetCompiler {
15581558
* Called when the compiler is closing or a watching compilation has stopped.
15591559
*/
15601560
shutdown() {
1561+
//console.log('xxxx shutdown: ', {});
15611562
PluginService.shutdown(this.compilation?.compiler);
15621563
}
15631564
}

src/Plugin/Messages/Info.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,13 @@ const verbose = (pluginCompiler) => {
101101
const pluginContext = PluginService.getPluginContext(pluginCompiler);
102102

103103
const collection = pluginContext.collection;
104-
const dependency = PluginService.getLoaderDependency(pluginCompiler);
105104
const collectionData = collection.getData();
106-
105+
const dependency = PluginService.getLoaderDependency(pluginCompiler);
107106
let str = '\n' + black.bgGreen` ${pluginLabel} ` + bg(193).black` Entry processing ` + '\n';
108107

109108
// display loader watch dependencies
110-
if (PluginService.isWatchMode(pluginCompiler)) {
109+
// TODO: fix verbose of dependency after start/stop in serve/watch mode when used cache filesystem
110+
if (dependency && PluginService.isWatchMode(pluginCompiler)) {
111111
const watchFiles = dependency.getFiles();
112112

113113
if (watchFiles && watchFiles.size > 0) {

src/Plugin/Option.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,9 @@ class Option {
674674
* @return {Array<string>}
675675
*/
676676
getRootSourcePaths() {
677-
const watchDirs = PluginService.getLoaderOption(this.compiler).getWatchPaths();
677+
const loaderOption = PluginService.getLoaderOption(this.compiler);
678678

679-
return watchDirs || [];
679+
return loaderOption ? loaderOption.getWatchPaths() : [];
680680
}
681681

682682
/**

src/Plugin/PluginService.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ class PluginService {
261261
}
262262

263263
/**
264-
* Called when the compiler is closing.
264+
* Called after by shutdown and watchClose.
265265
* Used for tests to reset data after each test case.
266266
*
267267
* @param {Compiler|null} compiler
@@ -274,6 +274,11 @@ class PluginService {
274274

275275
const context = this.getContext(compiler);
276276

277+
if (!context) {
278+
// when was already called the context was removed
279+
return;
280+
}
281+
277282
context.used = false;
278283
context.loaderCache.clear();
279284
context.contextCache.clear();

test/cases/integrity-hook-done/expected/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<title>Test</title>
55
<link href="style.47f4da55.css" rel="stylesheet" integrity="sha384-gaDmgJjLpipN1Jmuc98geFnDjVqWn1fixlG0Ab90qFyUIJ4ARXlKBsMGumxTSu7E" crossorigin="anonymous">
66
<link href="main.dc4ea4af.chunk.css" rel="stylesheet" integrity="sha384-W/pO0vwqqWBj4lq8nfe+kjrP8Z78smCBttkCvx1SYKrVI4WEdJa6W6i0I2hoc1t7" crossorigin="anonymous">
7-
<script src="main.a18a82dd.js" defer="defer" integrity="sha384-pYpPI3swJQFidSQef3FdO/6HyTQV2zBV3FQKWV3E3lqzmMr9wkSY39tLRQVzuHXS" crossorigin="anonymous"></script>
7+
<script src="main.5c313a48.js" defer="defer" integrity="sha384-954/OZQsHglHngcpjSGD4QKjeJfO2JADyQkvIlT8eCmhH2IP/+L7jY1IoczQ8YMe" crossorigin="anonymous"></script>
88
</head>
99
<body>
1010
<h1>Hello World!</h1>

test/cases/integrity-hook-done/expected/integrity.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"main.a18a82dd.js": "sha384-pYpPI3swJQFidSQef3FdO/6HyTQV2zBV3FQKWV3E3lqzmMr9wkSY39tLRQVzuHXS",
2+
"main.5c313a48.js": "sha384-954/OZQsHglHngcpjSGD4QKjeJfO2JADyQkvIlT8eCmhH2IP/+L7jY1IoczQ8YMe",
33
"854.b7f83599.chunk.js": "sha384-EUkN79LR81BZzp5wbZFWCuMf4JLRXeq3TrkleGG5sQzIl5ay561WABHAYJdwK5t9",
44
"473.f39b5874.chunk.js": "sha384-ne2fquQCfah8p+QoAjjY5bSP/o5+aNx32Ofvb36zdNNaru6tWRcmW2hckHXAt3kB",
55
"main.dc4ea4af.chunk.css": "sha384-W/pO0vwqqWBj4lq8nfe+kjrP8Z78smCBttkCvx1SYKrVI4WEdJa6W6i0I2hoc1t7",

test/cases/integrity-hook-done/expected/main.a18a82dd.js renamed to test/cases/integrity-hook-done/expected/main.5c313a48.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)