Skip to content

Commit b7a9e8f

Browse files
committed
feat: drop webpack 4 and node <= 10 support
BREAKING CHANGE: drop support for webpack 4 and node <= 10
1 parent 1e970e6 commit b7a9e8f

File tree

5 files changed

+13
-25
lines changed

5 files changed

+13
-25
lines changed

.github/workflows/main.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ jobs:
88
runs-on: ${{ matrix.os }}
99
strategy:
1010
matrix:
11-
node: ['6.x', '12.x', '14.x']
12-
os: [ubuntu-latest, windows-latest]
13-
webpack: ['4']
11+
node: ['10.x', '12.x', '14.x']
12+
os: [ubuntu-latest, windows-latest, macOS-latest]
13+
webpack: ['5']
1414

1515
steps:
1616
- name: LF

.node-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.11.5
1+
10.13.0

index.js

+5-13
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ const { assert } = require('console');
2828
const fsStatAsync = promisify(fs.stat);
2929
const fsReadFileAsync = promisify(fs.readFile);
3030

31-
const webpackMajorVersion = Number(require('webpack/package.json').version.split('.')[0]);
32-
3331
class HtmlWebpackPlugin {
3432
/**
3533
* @param {HtmlWebpackOptions} [options]
@@ -164,9 +162,7 @@ class HtmlWebpackPlugin {
164162
hash: templateResult.mainCompilationHash
165163
};
166164

167-
const childCompilationOutputName = webpackMajorVersion === 4
168-
? compilation.mainTemplate.getAssetPath(this.options.filename, compiledEntries)
169-
: compilation.getAssetPath(this.options.filename, compiledEntries);
165+
const childCompilationOutputName = compilation.getAssetPath(this.options.filename, compiledEntries);
170166

171167
// If the child compilation was not executed during a previous main compile run
172168
// it is a cached result
@@ -543,14 +539,10 @@ class HtmlWebpackPlugin {
543539
* if a path publicPath is set in the current webpack config use it otherwise
544540
* fallback to a relative path
545541
*/
546-
const webpackPublicPath = webpackMajorVersion === 4
547-
? compilation.mainTemplate.getPublicPath({ hash: compilationHash })
548-
: compilation.getAssetPath(compilation.outputOptions.publicPath, { hash: compilationHash });
549-
550-
const isPublicPathDefined = webpackMajorVersion === 4
551-
? webpackPublicPath.trim() !== ''
552-
// Webpack 5 introduced "auto" - however it can not be retrieved at runtime
553-
: webpackPublicPath.trim() !== '' && webpackPublicPath !== 'auto';
542+
const webpackPublicPath = compilation.getAssetPath(compilation.outputOptions.publicPath, { hash: compilationHash });
543+
544+
// Webpack 5 introduced "auto" - however it can not be retrieved at compile time
545+
const isPublicPathDefined = webpackPublicPath.trim() !== '' && webpackPublicPath !== 'auto';
554546

555547
let publicPath =
556548
// If the html-webpack-plugin options contain a custom public path uset it

lib/child-compiler.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,14 @@ class HtmlWebpackChildCompiler {
168168
* @returns Array<string>
169169
*/
170170
function extractHelperFilesFromCompilation (mainCompilation, childCompilation, filename, childEntryChunks) {
171-
const webpackMajorVersion = Number(require('webpack/package.json').version.split('.')[0]);
172-
173171
const helperAssetNames = childEntryChunks.map((entryChunk, index) => {
174172
const entryConfig = {
175173
hash: childCompilation.hash,
176174
chunk: entryChunk,
177175
name: `HtmlWebpackPlugin_${index}`
178176
};
179177

180-
return webpackMajorVersion === 4
181-
? mainCompilation.mainTemplate.getAssetPath(filename, entryConfig)
182-
: mainCompilation.getAssetPath(filename, entryConfig);
178+
return mainCompilation.getAssetPath(filename, entryConfig);
183179
});
184180

185181
helperAssetNames.forEach((helperFileName) => {

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"standard-version": "5.0.2",
4747
"style-loader": "0.23.1",
4848
"typescript": "3.8.3",
49-
"webpack": "4.35.2",
49+
"webpack": "5.0.0",
5050
"webpack-recompilation-simulator": "3.2.0"
5151
},
5252
"dependencies": {
@@ -61,7 +61,7 @@
6161
"util.promisify": "1.0.0"
6262
},
6363
"peerDependencies": {
64-
"webpack": "^4.0.0 || ^5.0.0"
64+
"webpack": "^5.0.0"
6565
},
6666
"keywords": [
6767
"webpack",
@@ -73,7 +73,7 @@
7373
"homepage": "https://github.com/jantimon/html-webpack-plugin",
7474
"repository": "https://github.com/jantimon/html-webpack-plugin.git",
7575
"engines": {
76-
"node": ">=6.9"
76+
"node": ">=10.13.0"
7777
},
7878
"config": {
7979
"commitizen": {

0 commit comments

Comments
 (0)