html-webpack-plugin 5.5.4 → 5.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- 'use strict';
2
+ "use strict";
3
3
 
4
4
  /**
5
5
  * @file
@@ -13,7 +13,6 @@
13
13
  /** @typedef {import("webpack").sources.Source} Source */
14
14
  /** @typedef {{hash: string, entry: Chunk, content: string, assets: {[name: string]: { source: Source, info: import("webpack").AssetInfo }}}} ChildCompilationTemplateResult */
15
15
 
16
- let instanceId = 0;
17
16
  /**
18
17
  * The HtmlWebpackChildCompiler is a helper to allow reusing one childCompiler
19
18
  * for multiple HtmlWebpackPlugin instances to improve the compilation performance.
@@ -23,9 +22,7 @@ class HtmlWebpackChildCompiler {
23
22
  *
24
23
  * @param {string[]} templates
25
24
  */
26
- constructor (templates) {
27
- /** Id for this ChildCompiler */
28
- this.id = instanceId++;
25
+ constructor(templates) {
29
26
  /**
30
27
  * @type {string[]} templateIds
31
28
  * The template array will allow us to keep track which input generated which output
@@ -41,7 +38,11 @@ class HtmlWebpackChildCompiler {
41
38
  * All file dependencies of the child compiler
42
39
  * @type {{fileDependencies: string[], contextDependencies: string[], missingDependencies: string[]}}
43
40
  */
44
- this.fileDependencies = { fileDependencies: [], contextDependencies: [], missingDependencies: [] };
41
+ this.fileDependencies = {
42
+ fileDependencies: [],
43
+ contextDependencies: [],
44
+ missingDependencies: [],
45
+ };
45
46
  }
46
47
 
47
48
  /**
@@ -49,7 +50,7 @@ class HtmlWebpackChildCompiler {
49
50
  *
50
51
  * @returns {boolean}
51
52
  */
52
- isCompiling () {
53
+ isCompiling() {
53
54
  return !this.didCompile() && this.compilationStartedTimestamp !== undefined;
54
55
  }
55
56
 
@@ -58,7 +59,7 @@ class HtmlWebpackChildCompiler {
58
59
  *
59
60
  * @returns {boolean}
60
61
  */
61
- didCompile () {
62
+ didCompile() {
62
63
  return this.compilationEndedTimestamp !== undefined;
63
64
  }
64
65
 
@@ -69,7 +70,7 @@ class HtmlWebpackChildCompiler {
69
70
  * @param {import('webpack').Compilation} mainCompilation
70
71
  * @returns {Promise<{[templatePath: string]: ChildCompilationTemplateResult}>}
71
72
  */
72
- compileTemplates (mainCompilation) {
73
+ compileTemplates(mainCompilation) {
73
74
  const webpack = mainCompilation.compiler.webpack;
74
75
  const Compilation = webpack.Compilation;
75
76
 
@@ -86,46 +87,62 @@ class HtmlWebpackChildCompiler {
86
87
  }
87
88
 
88
89
  const outputOptions = {
89
- filename: '__child-[name]',
90
- publicPath: '',
90
+ filename: "__child-[name]",
91
+ publicPath: "",
91
92
  library: {
92
- type: 'var',
93
- name: 'HTML_WEBPACK_PLUGIN_RESULT'
93
+ type: "var",
94
+ name: "HTML_WEBPACK_PLUGIN_RESULT",
94
95
  },
95
- scriptType: /** @type {'text/javascript'} */('text/javascript'),
96
- iife: true
96
+ scriptType: /** @type {'text/javascript'} */ ("text/javascript"),
97
+ iife: true,
97
98
  };
98
- const compilerName = 'HtmlWebpackCompiler';
99
+ const compilerName = "HtmlWebpackCompiler";
99
100
  // Create an additional child compiler which takes the template
100
101
  // and turns it into an Node.JS html factory.
101
102
  // This allows us to use loaders during the compilation
102
- const childCompiler = mainCompilation.createChildCompiler(compilerName, outputOptions, [
103
- // Compile the template to nodejs javascript
104
- new NodeTargetPlugin(),
105
- new NodeTemplatePlugin(),
106
- new LoaderTargetPlugin('node'),
107
- new webpack.library.EnableLibraryPlugin('var')
108
- ]);
103
+ const childCompiler = mainCompilation.createChildCompiler(
104
+ compilerName,
105
+ outputOptions,
106
+ [
107
+ // Compile the template to nodejs javascript
108
+ new NodeTargetPlugin(),
109
+ new NodeTemplatePlugin(),
110
+ new LoaderTargetPlugin("node"),
111
+ new webpack.library.EnableLibraryPlugin("var"),
112
+ ],
113
+ );
109
114
  // The file path context which webpack uses to resolve all relative files to
110
115
  childCompiler.context = mainCompilation.compiler.context;
111
116
 
112
117
  // Generate output file names
113
- const temporaryTemplateNames = this.templates.map((template, index) => `__child-HtmlWebpackPlugin_${index}-${this.id}`);
118
+ const temporaryTemplateNames = this.templates.map(
119
+ (template, index) => `__child-HtmlWebpackPlugin_${index}-${template}`,
120
+ );
114
121
 
115
122
  // Add all templates
116
123
  this.templates.forEach((template, index) => {
117
- new EntryPlugin(childCompiler.context, 'data:text/javascript,__webpack_public_path__ = __webpack_base_uri__ = htmlWebpackPluginPublicPath;', `HtmlWebpackPlugin_${index}-${this.id}`).apply(childCompiler);
118
- new EntryPlugin(childCompiler.context, template, `HtmlWebpackPlugin_${index}-${this.id}`).apply(childCompiler);
124
+ new EntryPlugin(
125
+ childCompiler.context,
126
+ "data:text/javascript,__webpack_public_path__ = __webpack_base_uri__ = htmlWebpackPluginPublicPath;",
127
+ `HtmlWebpackPlugin_${index}-${template}`,
128
+ ).apply(childCompiler);
129
+ new EntryPlugin(
130
+ childCompiler.context,
131
+ template,
132
+ `HtmlWebpackPlugin_${index}-${template}`,
133
+ ).apply(childCompiler);
119
134
  });
120
135
 
121
136
  // The templates are compiled and executed by NodeJS - similar to server side rendering
122
137
  // Unfortunately this causes issues as some loaders require an absolute URL to support ES Modules
123
138
  // The following config enables relative URL support for the child compiler
124
139
  childCompiler.options.module = { ...childCompiler.options.module };
125
- childCompiler.options.module.parser = { ...childCompiler.options.module.parser };
140
+ childCompiler.options.module.parser = {
141
+ ...childCompiler.options.module.parser,
142
+ };
126
143
  childCompiler.options.module.parser.javascript = {
127
144
  ...childCompiler.options.module.parser.javascript,
128
- url: 'relative'
145
+ url: "relative",
129
146
  };
130
147
 
131
148
  this.compilationStartedTimestamp = new Date().getTime();
@@ -134,23 +151,26 @@ class HtmlWebpackChildCompiler {
134
151
  /** @type {Source[]} */
135
152
  const extractedAssets = [];
136
153
 
137
- childCompiler.hooks.thisCompilation.tap('HtmlWebpackPlugin', (compilation) => {
138
- compilation.hooks.processAssets.tap(
139
- {
140
- name: 'HtmlWebpackPlugin',
141
- stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS
142
- },
143
- (assets) => {
144
- temporaryTemplateNames.forEach((temporaryTemplateName) => {
145
- if (assets[temporaryTemplateName]) {
146
- extractedAssets.push(assets[temporaryTemplateName]);
147
-
148
- compilation.deleteAsset(temporaryTemplateName);
149
- }
150
- });
151
- }
152
- );
153
- });
154
+ childCompiler.hooks.thisCompilation.tap(
155
+ "HtmlWebpackPlugin",
156
+ (compilation) => {
157
+ compilation.hooks.processAssets.tap(
158
+ {
159
+ name: "HtmlWebpackPlugin",
160
+ stage: Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,
161
+ },
162
+ (assets) => {
163
+ temporaryTemplateNames.forEach((temporaryTemplateName) => {
164
+ if (assets[temporaryTemplateName]) {
165
+ extractedAssets.push(assets[temporaryTemplateName]);
166
+
167
+ compilation.deleteAsset(temporaryTemplateName);
168
+ }
169
+ });
170
+ },
171
+ );
172
+ },
173
+ );
154
174
 
155
175
  childCompiler.runAsChild((err, entries, childCompilation) => {
156
176
  // Extract templates
@@ -161,20 +181,34 @@ class HtmlWebpackChildCompiler {
161
181
 
162
182
  // Extract file dependencies
163
183
  if (entries && childCompilation) {
164
- this.fileDependencies = { fileDependencies: Array.from(childCompilation.fileDependencies), contextDependencies: Array.from(childCompilation.contextDependencies), missingDependencies: Array.from(childCompilation.missingDependencies) };
184
+ this.fileDependencies = {
185
+ fileDependencies: Array.from(childCompilation.fileDependencies),
186
+ contextDependencies: Array.from(
187
+ childCompilation.contextDependencies,
188
+ ),
189
+ missingDependencies: Array.from(
190
+ childCompilation.missingDependencies,
191
+ ),
192
+ };
165
193
  }
166
194
 
167
195
  // Reject the promise if the childCompilation contains error
168
- if (childCompilation && childCompilation.errors && childCompilation.errors.length) {
169
- const errorDetails = childCompilation.errors.map(error => {
196
+ if (
197
+ childCompilation &&
198
+ childCompilation.errors &&
199
+ childCompilation.errors.length
200
+ ) {
201
+ const errorDetailsArray = [];
202
+ for (const error of childCompilation.errors) {
170
203
  let message = error.message;
171
204
  if (error.stack) {
172
- message += '\n' + error.stack;
205
+ message += "\n" + error.stack;
173
206
  }
174
- return message;
175
- }).join('\n');
207
+ errorDetailsArray.push(message);
208
+ }
209
+ const errorDetails = errorDetailsArray.join("\n");
176
210
 
177
- reject(new Error('Child compilation failed:\n' + errorDetails));
211
+ reject(new Error("Child compilation failed:\n" + errorDetails));
178
212
 
179
213
  return;
180
214
  }
@@ -186,7 +220,7 @@ class HtmlWebpackChildCompiler {
186
220
  }
187
221
 
188
222
  if (!childCompilation || !entries) {
189
- reject(new Error('Empty child compilation'));
223
+ reject(new Error("Empty child compilation"));
190
224
  return;
191
225
  }
192
226
 
@@ -209,9 +243,9 @@ class HtmlWebpackChildCompiler {
209
243
  result[this.templates[entryIndex]] = {
210
244
  // TODO, can we have Buffer here?
211
245
  content: /** @type {string} */ (templateSource),
212
- hash: childCompilation.hash || 'XXXX',
246
+ hash: childCompilation.hash || "XXXX",
213
247
  entry: entries[entryIndex],
214
- assets
248
+ assets,
215
249
  };
216
250
  });
217
251
 
@@ -226,5 +260,5 @@ class HtmlWebpackChildCompiler {
226
260
  }
227
261
 
228
262
  module.exports = {
229
- HtmlWebpackChildCompiler
263
+ HtmlWebpackChildCompiler,
230
264
  };
@@ -1,5 +1,5 @@
1
1
  // @ts-check
2
- 'use strict';
2
+ "use strict";
3
3
 
4
4
  /** @typedef {import("webpack").Compilation} Compilation */
5
5
 
@@ -14,7 +14,7 @@ module.exports = {};
14
14
  * @param {Array<string>} chunks the chunks to sort
15
15
  * @return {Array<string>} The sorted chunks
16
16
  */
17
- module.exports.none = chunks => chunks;
17
+ module.exports.none = (chunks) => chunks;
18
18
 
19
19
  /**
20
20
  * Sort manually by the chunks
@@ -23,7 +23,11 @@ module.exports.none = chunks => chunks;
23
23
  * @param {any} htmlWebpackPluginOptions the plugin options
24
24
  * @return {string[]} The sorted chunks
25
25
  */
26
- module.exports.manual = (entryPointNames, compilation, htmlWebpackPluginOptions) => {
26
+ module.exports.manual = (
27
+ entryPointNames,
28
+ compilation,
29
+ htmlWebpackPluginOptions,
30
+ ) => {
27
31
  const chunks = htmlWebpackPluginOptions.chunks;
28
32
  if (!Array.isArray(chunks)) {
29
33
  return entryPointNames;
package/lib/errors.js CHANGED
@@ -1,18 +1,18 @@
1
1
  // @ts-nocheck
2
- 'use strict';
2
+ "use strict";
3
3
 
4
4
  let prettyError;
5
5
 
6
- function getPrettyError () {
6
+ function getPrettyError() {
7
7
  if (!prettyError) {
8
8
  // lazily require to improve startup time since pretty-error is rather heavy package
9
- const PrettyError = require('pretty-error');
9
+ const PrettyError = require("pretty-error");
10
10
  prettyError = new PrettyError();
11
11
  prettyError.withoutColors();
12
- prettyError.skipPackage('html-plugin-evaluation');
12
+ prettyError.skipPackage("html-plugin-evaluation");
13
13
  prettyError.skipNodeFiles();
14
14
  prettyError.skip(function (traceLine) {
15
- return traceLine.path === 'html-plugin-evaluation';
15
+ return traceLine.path === "html-plugin-evaluation";
16
16
  });
17
17
  }
18
18
  return prettyError;
@@ -21,20 +21,22 @@ function getPrettyError () {
21
21
  module.exports = function (err, context) {
22
22
  return {
23
23
  toHtml: function () {
24
- return 'Html Webpack Plugin:\n<pre>\n' + this.toString() + '</pre>';
24
+ return "Html Webpack Plugin:\n<pre>\n" + this.toString() + "</pre>";
25
25
  },
26
26
  toJsonHtml: function () {
27
27
  return JSON.stringify(this.toHtml());
28
28
  },
29
29
  toString: function () {
30
30
  try {
31
- return getPrettyError().render(err).replace(/webpack:\/\/\/\./g, context);
31
+ return getPrettyError()
32
+ .render(err)
33
+ .replace(/webpack:\/\/\/\./g, context);
32
34
  } catch (e) {
33
35
  // This can sometimes fail. We don't know why, but returning the
34
36
  // original error is better than returning the error thrown by
35
37
  // pretty-error.
36
38
  return err;
37
39
  }
38
- }
40
+ },
39
41
  };
40
42
  };
package/lib/html-tags.js CHANGED
@@ -17,7 +17,23 @@
17
17
  * All html tag elements which must not contain innerHTML
18
18
  * @see https://www.w3.org/TR/html5/syntax.html#void-elements
19
19
  */
20
- const voidTags = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
20
+ const voidTags = [
21
+ "area",
22
+ "base",
23
+ "br",
24
+ "col",
25
+ "embed",
26
+ "hr",
27
+ "img",
28
+ "input",
29
+ "keygen",
30
+ "link",
31
+ "meta",
32
+ "param",
33
+ "source",
34
+ "track",
35
+ "wbr",
36
+ ];
21
37
 
22
38
  /**
23
39
  * Turn a tag definition into a html string
@@ -27,20 +43,32 @@ const voidTags = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'k
27
43
  * @param xhtml {boolean}
28
44
  * Whether the generated html should add closing slashes to be xhtml compliant
29
45
  */
30
- function htmlTagObjectToString (tagDefinition, xhtml) {
46
+ function htmlTagObjectToString(tagDefinition, xhtml) {
31
47
  const attributes = Object.keys(tagDefinition.attributes || {})
32
48
  .filter(function (attributeName) {
33
- return tagDefinition.attributes[attributeName] === '' || tagDefinition.attributes[attributeName];
49
+ return (
50
+ tagDefinition.attributes[attributeName] === "" ||
51
+ tagDefinition.attributes[attributeName]
52
+ );
34
53
  })
35
54
  .map(function (attributeName) {
36
55
  if (tagDefinition.attributes[attributeName] === true) {
37
- return xhtml ? attributeName + '="' + attributeName + '"' : attributeName;
56
+ return xhtml
57
+ ? attributeName + '="' + attributeName + '"'
58
+ : attributeName;
38
59
  }
39
- return attributeName + '="' + tagDefinition.attributes[attributeName] + '"';
60
+ return (
61
+ attributeName + '="' + tagDefinition.attributes[attributeName] + '"'
62
+ );
40
63
  });
41
- return '<' + [tagDefinition.tagName].concat(attributes).join(' ') + (tagDefinition.voidTag && xhtml ? '/' : '') + '>' +
42
- (tagDefinition.innerHTML || '') +
43
- (tagDefinition.voidTag ? '' : '</' + tagDefinition.tagName + '>');
64
+ return (
65
+ "<" +
66
+ [tagDefinition.tagName].concat(attributes).join(" ") +
67
+ (tagDefinition.voidTag && xhtml ? "/" : "") +
68
+ ">" +
69
+ (tagDefinition.innerHTML || "") +
70
+ (tagDefinition.voidTag ? "" : "</" + tagDefinition.tagName + ">")
71
+ );
44
72
  }
45
73
 
46
74
  /**
@@ -59,13 +87,13 @@ function htmlTagObjectToString (tagDefinition, xhtml) {
59
87
  *
60
88
  * @returns {HtmlTagObject}
61
89
  */
62
- function createHtmlTagObject (tagName, attributes, innerHTML, meta) {
90
+ function createHtmlTagObject(tagName, attributes, innerHTML, meta) {
63
91
  return {
64
92
  tagName: tagName,
65
93
  voidTag: voidTags.indexOf(tagName) !== -1,
66
94
  attributes: attributes || {},
67
95
  meta: meta || {},
68
- innerHTML: innerHTML
96
+ innerHTML: innerHTML,
69
97
  };
70
98
  }
71
99
 
@@ -87,13 +115,13 @@ function createHtmlTagObject (tagName, attributes, innerHTML, meta) {
87
115
  *
88
116
  */
89
117
  class HtmlTagArray extends Array {
90
- toString () {
91
- return this.join('');
118
+ toString() {
119
+ return this.join("");
92
120
  }
93
121
  }
94
122
 
95
123
  module.exports = {
96
124
  HtmlTagArray: HtmlTagArray,
97
125
  createHtmlTagObject: createHtmlTagObject,
98
- htmlTagObjectToString: htmlTagObjectToString
126
+ htmlTagObjectToString: htmlTagObjectToString,
99
127
  };
package/lib/loader.js CHANGED
@@ -1,14 +1,16 @@
1
1
  /* This loader renders the template with underscore if no other loader was found */
2
2
  // @ts-nocheck
3
- 'use strict';
4
- const _ = require('lodash');
3
+ "use strict";
4
+ const _template = require("lodash/template");
5
5
 
6
6
  module.exports = function (source) {
7
7
  // Get templating options
8
8
  const options = this.getOptions();
9
9
  const force = options.force || false;
10
10
 
11
- const allLoadersButThisOne = this.loaders.filter((loader) => loader.normal !== module.exports);
11
+ const allLoadersButThisOne = this.loaders.filter(
12
+ (loader) => loader.normal !== module.exports,
13
+ );
12
14
 
13
15
  // This loader shouldn't kick in if there is any other loader (unless it's explicitly enforced)
14
16
  if (allLoadersButThisOne.length > 0 && !force) {
@@ -16,8 +18,11 @@ module.exports = function (source) {
16
18
  }
17
19
 
18
20
  // Allow only one html-webpack-plugin loader to allow loader options in the webpack config
19
- const htmlWebpackPluginLoaders = this.loaders.filter((loader) => loader.normal === module.exports);
20
- const lastHtmlWebpackPluginLoader = htmlWebpackPluginLoaders[htmlWebpackPluginLoaders.length - 1];
21
+ const htmlWebpackPluginLoaders = this.loaders.filter(
22
+ (loader) => loader.normal === module.exports,
23
+ );
24
+ const lastHtmlWebpackPluginLoader =
25
+ htmlWebpackPluginLoaders[htmlWebpackPluginLoaders.length - 1];
21
26
  if (this.loaders[this.loaderIndex] !== lastHtmlWebpackPluginLoader) {
22
27
  return source;
23
28
  }
@@ -29,12 +34,22 @@ module.exports = function (source) {
29
34
 
30
35
  // The following part renders the template with lodash as a minimalistic loader
31
36
  //
32
- const template = _.template(source, { interpolate: /<%=([\s\S]+?)%>/g, variable: 'data', ...options });
37
+ const template = _template(source, {
38
+ interpolate: /<%=([\s\S]+?)%>/g,
39
+ variable: "data",
40
+ ...options,
41
+ });
33
42
  // Use `eval("require")("lodash")` to enforce using the native nodejs require
34
43
  // during template execution
35
- return 'var _ = eval("require")(' + JSON.stringify(require.resolve('lodash')) + ');' +
36
- 'module.exports = function (templateParams) { with(templateParams) {' +
37
- // Execute the lodash template
38
- 'return (' + template.source + ')();' +
39
- '}}';
44
+ return (
45
+ 'var _ = eval("require")(' +
46
+ JSON.stringify(require.resolve("lodash")) +
47
+ ");" +
48
+ "module.exports = function (templateParams) { with(templateParams) {" +
49
+ // Execute the lodash template
50
+ "return (" +
51
+ template.source +
52
+ ")();" +
53
+ "}}"
54
+ );
40
55
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-webpack-plugin",
3
- "version": "5.5.4",
3
+ "version": "5.6.1",
4
4
  "license": "MIT",
5
5
  "description": "Simplifies creation of HTML files to serve your webpack bundles",
6
6
  "author": "Jan Nicklas <j.nicklas@me.com> (https://github.com/jantimon)",
@@ -13,38 +13,52 @@
13
13
  "typings.d.ts"
14
14
  ],
15
15
  "scripts": {
16
- "pretest": "semistandard",
17
16
  "posttest": "tsc",
18
- "commit": "git-cz",
19
- "build-examples": "node examples/build-examples.js",
20
- "test": "jest --runInBand --verbose --coverage",
21
- "test-watch": "jest --runInBand --watch",
22
17
  "puml": "npx puml generate flow.puml -o flow.png",
18
+ "build-examples": "node examples/build-examples.js",
19
+ "commitlint": "commitlint --from=master",
20
+ "security": "npm audit --omit=dev",
21
+ "lint:prettier": "prettier --cache --list-different .",
22
+ "lint:js": "eslint --cache .",
23
+ "lint:spelling": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
24
+ "lint": "npm-run-all -l -p \"lint:**\"",
25
+ "fix:js": "npm run lint:js -- --fix",
26
+ "fix:prettier": "npm run lint:prettier -- --write",
27
+ "fix": "npm-run-all -l fix:js fix:prettier",
28
+ "test:only": "cross-env NODE_ENV=test jest",
29
+ "test:watch": "npm run test:only -- --watch",
30
+ "test:manual": "npm run build && webpack-dev-server test/manual/src/index.js --open --config test/manual/webpack.config.js",
31
+ "test:coverage": "npm run test:only -- --coverage",
32
+ "pretest": "npm run lint",
33
+ "test": "npm run test:coverage",
34
+ "prepare": "husky",
23
35
  "release": "standard-version"
24
36
  },
25
- "semistandard": {
26
- "ignore": [
27
- "examples/*/dist/**/*.*"
28
- ]
29
- },
30
37
  "devDependencies": {
38
+ "@commitlint/cli": "^18.4.4",
39
+ "@commitlint/config-conventional": "^18.4.4",
31
40
  "@types/node": "^20.2.5",
32
- "commitizen": "^4.2.4",
41
+ "cross-env": "^7.0.3",
42
+ "cspell": "^8.3.2",
33
43
  "css-loader": "5.0.1",
34
44
  "cz-conventional-changelog": "2.1.0",
35
45
  "dir-compare": "^3.3.0",
46
+ "eslint": "^8.56.0",
36
47
  "html-loader": "2.1.1",
48
+ "husky": "^9.0.10",
37
49
  "jest": "^27.2.5",
50
+ "lint-staged": "^15.2.2",
38
51
  "mini-css-extract-plugin": "^1.6.0",
52
+ "npm-run-all": "^4.1.5",
53
+ "prettier": "^3.2.5",
39
54
  "pug": "3.0.2",
40
55
  "pug-loader": "2.4.0",
41
56
  "raw-loader": "4.0.2",
42
57
  "rimraf": "2.6.3",
43
- "semistandard": "^13.0.1",
44
58
  "standard-version": "^9.3.0",
45
59
  "style-loader": "2.0.0",
46
60
  "typescript": "4.9.4",
47
- "webpack": "^5.86.0",
61
+ "webpack": "^5.95.0",
48
62
  "webpack-cli": "4.5.0",
49
63
  "webpack-recompilation-simulator": "3.2.0"
50
64
  },
@@ -56,8 +70,17 @@
56
70
  "tapable": "^2.0.0"
57
71
  },
58
72
  "peerDependencies": {
73
+ "@rspack/core": "0.x || 1.x",
59
74
  "webpack": "^5.20.0"
60
75
  },
76
+ "peerDependenciesMeta": {
77
+ "@rspack/core": {
78
+ "optional": true
79
+ },
80
+ "webpack": {
81
+ "optional": true
82
+ }
83
+ },
61
84
  "keywords": [
62
85
  "webpack",
63
86
  "plugin",
@@ -70,11 +93,6 @@
70
93
  "engines": {
71
94
  "node": ">=10.13.0"
72
95
  },
73
- "config": {
74
- "commitizen": {
75
- "path": "./node_modules/cz-conventional-changelog"
76
- }
77
- },
78
96
  "jest": {
79
97
  "watchPathIgnorePatterns": [
80
98
  "<rootDir>/dist"
package/typings.d.ts CHANGED
@@ -20,6 +20,7 @@ declare class HtmlWebpackPlugin {
20
20
  apply(compiler: Compiler): void;
21
21
 
22
22
  static getHooks(compilation: Compilation): HtmlWebpackPlugin.Hooks;
23
+ static getCompilationHooks(compilation: Compilation): HtmlWebpackPlugin.Hooks;
23
24
 
24
25
  /**
25
26
  * Static helper to create a tag object to be get injected into the dom
@@ -27,7 +28,7 @@ declare class HtmlWebpackPlugin {
27
28
  static createHtmlTagObject(
28
29
  tagName: string,
29
30
  attributes?: { [attributeName: string]: string | boolean },
30
- innerHTML?: string
31
+ innerHTML?: string,
31
32
  ): HtmlWebpackPlugin.HtmlTagObject;
32
33
 
33
34
  static readonly version: number;
@@ -98,7 +99,7 @@ declare namespace HtmlWebpackPlugin {
98
99
  *
99
100
  * @default 'defer'
100
101
  */
101
- scriptLoading?: "blocking" | "defer" | "module";
102
+ scriptLoading?: "blocking" | "defer" | "module" | "systemjs-module";
102
103
  /**
103
104
  * Inject meta tags
104
105
  */
@@ -112,8 +113,8 @@ declare namespace HtmlWebpackPlugin {
112
113
  };
113
114
  /**
114
115
  * HTML Minification options accepts the following values:
115
- * - Set to `false` to disable minifcation
116
- * - Set to `'auto'` to enable minifcation only for production mode
116
+ * - Set to `false` to disable minification
117
+ * - Set to `'auto'` to enable minification only for production mode
117
118
  * - Set to custom minification according to
118
119
  * {@link https://github.com/kangax/html-minifier#options-quick-reference}
119
120
  */
@@ -155,7 +156,7 @@ declare namespace HtmlWebpackPlugin {
155
156
  headTags: HtmlTagObject[];
156
157
  bodyTags: HtmlTagObject[];
157
158
  },
158
- options: ProcessedOptions
159
+ options: ProcessedOptions,
159
160
  ) => { [option: string]: any } | Promise<{ [option: string]: any }>)
160
161
  | { [option: string]: any };
161
162
  /**
@@ -211,7 +212,7 @@ declare namespace HtmlWebpackPlugin {
211
212
  styles: HtmlTagObject[];
212
213
  meta: HtmlTagObject[];
213
214
  };
214
- publicPath: string,
215
+ publicPath: string;
215
216
  outputName: string;
216
217
  plugin: HtmlWebpackPlugin;
217
218
  }>;
@@ -220,7 +221,7 @@ declare namespace HtmlWebpackPlugin {
220
221
  headTags: HtmlTagObject[];
221
222
  bodyTags: HtmlTagObject[];
222
223
  outputName: string;
223
- publicPath: string,
224
+ publicPath: string;
224
225
  plugin: HtmlWebpackPlugin;
225
226
  }>;
226
227
 
@@ -285,7 +286,7 @@ declare namespace HtmlWebpackPlugin {
285
286
  * E.g. `{'plugin': 'html-webpack-plugin'}`
286
287
  */
287
288
  meta: {
288
- plugin?: string,
289
+ plugin?: string;
289
290
  [metaAttributeName: string]: any;
290
291
  };
291
292
  }