Skip to content

Commit fbf7414

Browse files
committed
test: add manual test for the issue #110
1 parent 2cb4dca commit fbf7414

7 files changed

Lines changed: 96 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Manual test for the issue [#110](https://github.com/webdiscus/html-bundler-webpack-plugin/issues/110)
2+
3+
Cache issue with `integrity: true` and `output.filename = '[name].[contenthash].js'`
4+
in watch mode after adding a new import statement to a JS file.
5+
6+
7+
Try to reproduce the issue:
8+
9+
1. Start in serv mode:
10+
`npm start`
11+
2. Open URL in browser: `http://localhost:8080/`
12+
3. Open `./src/main.js`
13+
4. Change the file:
14+
```diff
15+
import str from './module';
16+
17+
// test in serv mode: add new import JS file
18+
- //import str2 from './module-new'; // <= uncomment
19+
- //console.log('>> main', { str2 }); // <= uncomment
20+
+ import str2 from './module-new';
21+
+ console.log('>> main', { str2 });
22+
23+
console.log('>> main', { str });
24+
```
25+
26+
Currently: This simple test works fine w/o errors.
27+
28+
TODO: reproduce issue described in the issue #110.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"description": "IMPORTANT: don't install webpack here because the Webpack instance MUST be one, otherwise appear the error: The 'compilation' argument must be an instance of Compilation.",
3+
"scripts": {
4+
"start": "webpack serve --mode development",
5+
"watch": "webpack watch --mode development",
6+
"build": "webpack --mode=production --progress"
7+
},
8+
"devDependencies": {
9+
"html-bundler-webpack-plugin": "file:../../.."
10+
}
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<title>Home</title>
5+
<script src="./main.js" defer="defer"></script>
6+
</head>
7+
<body>
8+
<h1>Hello World!</h1>
9+
<p>Change the content of an imported JS file.</p>
10+
</body>
11+
</html>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import str from './module';
2+
3+
// test in serv mode: add new import JS file
4+
// import str2 from './module-new'; // <= uncomment
5+
// console.log('>> main', { str2 }); // <= uncomment
6+
7+
console.log('>> main', { str });
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = 'New added module: 123';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = 'Test 123';
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const path = require('path');
2+
const HtmlBundlerPlugin = require('html-bundler-webpack-plugin');
3+
4+
module.exports = {
5+
mode: 'production', // 1. test in production mode
6+
//mode: 'development', // 2. test in development mode
7+
stats: 'minimal',
8+
9+
output: {
10+
path: path.join(__dirname, 'dist/'),
11+
filename: '[name].[contenthash].js',
12+
crossOriginLoading: 'anonymous',
13+
},
14+
15+
plugins: [
16+
new HtmlBundlerPlugin({
17+
entry: {
18+
index: './src/index.html',
19+
},
20+
integrity: true, // test integrity in serv mode after adding new import JS in main.js
21+
verbose: true,
22+
}),
23+
],
24+
25+
// enable live reload
26+
devServer: {
27+
static: {
28+
directory: path.join(__dirname, 'dist'),
29+
},
30+
watchFiles: {
31+
paths: ['src/**/*.*'],
32+
options: {
33+
usePolling: true,
34+
},
35+
},
36+
},
37+
};

0 commit comments

Comments
 (0)