html-webpack-plugin 5.5.4 → 5.6.0

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.
package/README.md CHANGED
@@ -90,9 +90,9 @@ The `html-webpack-plugin` provides [hooks](https://github.com/jantimon/html-webp
90
90
  * [html-webpack-inject-preload](https://github.com/principalstudio/html-webpack-inject-preload) allows to add preload links <link rel='preload'> anywhere you want.
91
91
  * [inject-body-webpack-plugin](https://github.com/Jaid/inject-body-webpack-plugin) is a simple method of injecting a custom HTML string into the body.
92
92
  * [html-webpack-plugin-django](https://github.com/TommasoAmici/html-webpack-plugin-django) a Webpack plugin to inject Django static tags.
93
+ * [html-webpack-inject-attributes-plugin](https://github.com/dyw934854565/html-webpack-inject-attributes-plugin) add extra attributes to inject assetTags.
93
94
  * [js-entry-webpack-plugin](https://github.com/liam61/html-webpack-plugin) creates webpack bundles into your js entry
94
95
 
95
-
96
96
  <h2 align="center">Usage</h2>
97
97
 
98
98
  The plugin will generate an HTML5 file for you that includes all your `webpack`
@@ -151,7 +151,7 @@ Allowed values are as follows:
151
151
  |**`templateParameters`**|`{Boolean\|Object\|Function}`| `false`| Allows to overwrite the parameters used in the template - see [example](https://github.com/jantimon/html-webpack-plugin/tree/master/examples/template-parameters) |
152
152
  |**`inject`**|`{Boolean\|String}`|`true`|`true \|\| 'head' \|\| 'body' \|\| false` Inject all assets into the given `template` or `templateContent`. When passing `'body'` all javascript resources will be placed at the bottom of the body element. `'head'` will place the scripts in the head element. Passing `true` will add it to the head/body depending on the `scriptLoading` option. Passing `false` will disable automatic injections. - see the [inject:false example](https://github.com/jantimon/html-webpack-plugin/tree/master/examples/custom-insertion-position)|
153
153
  |**`publicPath`**|`{String\|'auto'}`|`'auto'`|The publicPath used for script and link tags|
154
- |**`scriptLoading`**|`{'blocking'\|'defer'\|'module'}`|`'defer'`| Modern browsers support non blocking javascript loading (`'defer'`) to improve the page startup performance. Setting to `'module'` adds attribute [`type="module"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#applying_the_module_to_your_html). This also implies "defer", since modules are automatically deferred. |
154
+ |**`scriptLoading`**|`{'blocking'\|'defer'\|'module'\|'systemjs-module'}`|`'defer'`| Modern browsers support non blocking javascript loading (`'defer'`) to improve the page startup performance. Setting to `'module'` adds attribute [`type="module"`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules#applying_the_module_to_your_html). This also implies "defer", since modules are automatically deferred. |
155
155
  |**`favicon`**|`{String}`|``|Adds the given favicon path to the output HTML|
156
156
  |**`meta`**|`{Object}`|`{}`|Allows to inject `meta`-tags. E.g. `meta: {viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no'}`|
157
157
  |**`base`**|`{Object\|String\|false}`|`false`|Inject a [`base`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) tag. E.g. `base: "https://example.com/path/page.html`|
package/index.js CHANGED
@@ -78,9 +78,9 @@ class HtmlWebpackPlugin {
78
78
  options.template = this.getTemplatePath(this.options.template, compiler.context);
79
79
 
80
80
  // Assert correct option spelling
81
- if (options.scriptLoading !== 'defer' && options.scriptLoading !== 'blocking' && options.scriptLoading !== 'module') {
81
+ if (options.scriptLoading !== 'defer' && options.scriptLoading !== 'blocking' && options.scriptLoading !== 'module' && options.scriptLoading !== 'systemjs-module') {
82
82
  /** @type {Logger} */
83
- (this.logger).error('The "scriptLoading" option need to be set to "defer", "blocking" or "module"');
83
+ (this.logger).error('The "scriptLoading" option need to be set to "defer", "blocking" or "module" or "systemjs-module"');
84
84
  }
85
85
 
86
86
  if (options.inject !== true && options.inject !== false && options.inject !== 'head' && options.inject !== 'body') {
@@ -794,6 +794,8 @@ class HtmlWebpackPlugin {
794
794
  attributes.defer = true;
795
795
  } else if (this.options.scriptLoading === 'module') {
796
796
  attributes.type = 'module';
797
+ } else if (this.options.scriptLoading === 'systemjs-module') {
798
+ attributes.type = 'systemjs-module';
797
799
  }
798
800
 
799
801
  attributes.src = src;
@@ -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.
@@ -24,8 +23,6 @@ class HtmlWebpackChildCompiler {
24
23
  * @param {string[]} templates
25
24
  */
26
25
  constructor (templates) {
27
- /** Id for this ChildCompiler */
28
- this.id = instanceId++;
29
26
  /**
30
27
  * @type {string[]} templateIds
31
28
  * The template array will allow us to keep track which input generated which output
@@ -110,12 +107,12 @@ class HtmlWebpackChildCompiler {
110
107
  childCompiler.context = mainCompilation.compiler.context;
111
108
 
112
109
  // Generate output file names
113
- const temporaryTemplateNames = this.templates.map((template, index) => `__child-HtmlWebpackPlugin_${index}-${this.id}`);
110
+ const temporaryTemplateNames = this.templates.map((template, index) => `__child-HtmlWebpackPlugin_${index}-${template}`);
114
111
 
115
112
  // Add all templates
116
113
  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);
114
+ new EntryPlugin(childCompiler.context, 'data:text/javascript,__webpack_public_path__ = __webpack_base_uri__ = htmlWebpackPluginPublicPath;', `HtmlWebpackPlugin_${index}-${template}`).apply(childCompiler);
115
+ new EntryPlugin(childCompiler.context, template, `HtmlWebpackPlugin_${index}-${template}`).apply(childCompiler);
119
116
  });
120
117
 
121
118
  // The templates are compiled and executed by NodeJS - similar to server side rendering
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.0",
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)",
@@ -56,8 +56,17 @@
56
56
  "tapable": "^2.0.0"
57
57
  },
58
58
  "peerDependencies": {
59
+ "@rspack/core": "0.x || 1.x",
59
60
  "webpack": "^5.20.0"
60
61
  },
62
+ "peerDependenciesMeta": {
63
+ "@rspack/core": {
64
+ "optional": true
65
+ },
66
+ "webpack": {
67
+ "optional": true
68
+ }
69
+ },
61
70
  "keywords": [
62
71
  "webpack",
63
72
  "plugin",
package/typings.d.ts CHANGED
@@ -98,7 +98,7 @@ declare namespace HtmlWebpackPlugin {
98
98
  *
99
99
  * @default 'defer'
100
100
  */
101
- scriptLoading?: "blocking" | "defer" | "module";
101
+ scriptLoading?: "blocking" | "defer" | "module" | "systemjs-module";
102
102
  /**
103
103
  * Inject meta tags
104
104
  */