html-webpack-plugin 5.6.5 → 5.6.7

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.
Files changed (2) hide show
  1. package/index.js +16 -7
  2. package/package.json +3 -2
package/index.js CHANGED
@@ -5,7 +5,6 @@ const promisify = require("util").promisify;
5
5
 
6
6
  const vm = require("vm");
7
7
  const fs = require("fs");
8
- const _uniq = require("lodash/uniq");
9
8
  const path = require("path");
10
9
  const { CachedChildCompilation } = require("./lib/cached-child-compiler");
11
10
 
@@ -636,14 +635,22 @@ class HtmlWebpackPlugin {
636
635
  Object.getPrototypeOf(global),
637
636
  Object.getOwnPropertyDescriptors(global),
638
637
  );
639
- // Presence of `eval` breaks template's explicit `eval` call, might be a bug in Node
638
+ // Presence of `eval` and `Function` breaks template's explicit `eval` call
639
+ // Ref: https://github.com/nodejs/help/issues/2880
640
640
  delete globalClone.eval;
641
+ delete globalClone.Function;
641
642
  // Not using `...global` as it throws when localStorage is not explicitly enabled in Node 25+
643
+ // Provide a CommonJS-style `module`/`exports` pair so templates compiled as CommonJS
644
+ // (e.g. Rspack's child compilation output, which wraps the result in `module.exports = ...`)
645
+ // can assign to them instead of failing with `module is not defined`.
646
+ const sandboxModule = { exports: {} };
642
647
  const vmContext = vm.createContext(
643
648
  Object.assign(globalClone, {
644
649
  HTML_WEBPACK_PLUGIN: true,
645
650
  // Copying nonstandard globals like `require` explicitly as they may be absent from `global`
646
651
  require: require,
652
+ module: sandboxModule,
653
+ exports: sandboxModule.exports,
647
654
  htmlWebpackPluginPublicPath: publicPath,
648
655
  __filename: templateWithoutLoaders,
649
656
  __dirname: path.dirname(templateWithoutLoaders),
@@ -948,11 +955,13 @@ class HtmlWebpackPlugin {
948
955
  * @private
949
956
  */
950
957
  getAssetFiles(assets) {
951
- const files = _uniq(
952
- Object.keys(assets)
953
- .filter((assetType) => assetType !== "chunks" && assets[assetType])
954
- .reduce((files, assetType) => files.concat(assets[assetType]), []),
955
- );
958
+ const files = [
959
+ ...new Set(
960
+ Object.keys(assets)
961
+ .filter((assetType) => assetType !== "chunks" && assets[assetType])
962
+ .reduce((files, assetType) => files.concat(assets[assetType]), []),
963
+ ),
964
+ ];
956
965
  files.sort();
957
966
  return files;
958
967
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "html-webpack-plugin",
3
- "version": "5.6.5",
3
+ "version": "5.6.7",
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)",
@@ -44,6 +44,7 @@
44
44
  "cz-conventional-changelog": "2.1.0",
45
45
  "dir-compare": "^3.3.0",
46
46
  "eslint": "^8.56.0",
47
+ "handlebars-loader": "^1.7.3",
47
48
  "html-loader": "2.1.1",
48
49
  "husky": "^9.0.10",
49
50
  "jest": "^27.2.5",
@@ -58,7 +59,7 @@
58
59
  "standard-version": "^9.3.0",
59
60
  "style-loader": "2.0.0",
60
61
  "typescript": "4.9.4",
61
- "webpack": "^5.101.0",
62
+ "webpack": "^5.104.1",
62
63
  "webpack-cli": "4.5.0",
63
64
  "webpack-recompilation-simulator": "3.2.0"
64
65
  },