webpack 5.75.0 → 5.76.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.

Potentially problematic release.


This version of webpack might be problematic. Click here for more details.

package/README.md CHANGED
@@ -158,11 +158,11 @@ or are automatically applied via regex from your webpack configuration.
158
158
 
159
159
  #### Transpiling
160
160
 
161
- | Name | Status | Install Size | Description |
162
- | :--------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------: | :------------: | :------------------------------------------------------------------------------------------------ |
163
- | <a href="https://github.com/babel/babel-loader"><img width="48" height="48" title="babel-loader" src="https://worldvectorlogo.com/logos/babel-10.svg"></a> | ![babel-npm] | ![babel-size] | Loads ES2015+ code and transpiles to ES5 using <a href="https://github.com/babel/babel">Babel</a> |
164
- | <a href="https://github.com/TypeStrong/ts-loader"><img width="48" height="48" src="https://cdn.rawgit.com/Microsoft/TypeScript/master/doc/logo.svg"></a> | ![type-npm] | ![type-size] | Loads TypeScript like JavaScript |
165
- | <a href="https://github.com/webpack-contrib/coffee-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/coffeescript.svg"></a> | ![coffee-npm] | ![coffee-size] | Loads CoffeeScript like JavaScript |
161
+ | Name | Status | Install Size | Description |
162
+ | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------: | :------------: | :------------------------------------------------------------------------------------------------ |
163
+ | <a href="https://github.com/babel/babel-loader"><img width="48" height="48" title="babel-loader" src="https://worldvectorlogo.com/logos/babel-10.svg"></a> | ![babel-npm] | ![babel-size] | Loads ES2015+ code and transpiles to ES5 using <a href="https://github.com/babel/babel">Babel</a> |
164
+ | <a href="https://github.com/TypeStrong/ts-loader"><img width="48" height="48" src="https://raw.githubusercontent.com/microsoft/TypeScript-Website/f407e1ae19e5e990d9901ac8064a32a8cc60edf0/packages/typescriptlang-org/static/branding/ts-logo-128.svg"></a> | ![type-npm] | ![type-size] | Loads TypeScript like JavaScript |
165
+ | <a href="https://github.com/webpack-contrib/coffee-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/coffeescript.svg"></a> | ![coffee-npm] | ![coffee-size] | Loads CoffeeScript like JavaScript |
166
166
 
167
167
  [babel-npm]: https://img.shields.io/npm/v/babel-loader.svg
168
168
  [babel-size]: https://packagephobia.com/badge?p=babel-loader
@@ -175,7 +175,7 @@ or are automatically applied via regex from your webpack configuration.
175
175
 
176
176
  | Name | Status | Install Size | Description |
177
177
  | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------: | :--------------: | :-------------------------------------------------------------------------------------- |
178
- | <a href="https://github.com/webpack-contrib/html-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/html5.svg"></a> | ![html-npm] | ![html-size] | Exports HTML as string, requires references to static resources |
178
+ | <a href="https://github.com/webpack-contrib/html-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/html5-2.svg"></a> | ![html-npm] | ![html-size] | Exports HTML as string, requires references to static resources |
179
179
  | <a href="https://github.com/pugjs/pug-loader"><img width="48" height="48" src="https://cdn.rawgit.com/pugjs/pug-logo/master/SVG/pug-final-logo-_-colour-128.svg"></a> | ![pug-npm] | ![pug-size] | Loads Pug templates and returns a function |
180
180
  | <a href="https://github.com/webdiscus/pug-loader"><img width="48" height="48" src="https://cdn.rawgit.com/pugjs/pug-logo/master/SVG/pug-final-logo-_-colour-128.svg"></a> | ![pug3-npm] | ![pug3-size] | Compiles Pug to a function or HTML string, useful for use with Vue, React, Angular |
181
181
  | <a href="https://github.com/peerigon/markdown-loader"><img width="48" height="48" src="https://worldvectorlogo.com/logos/markdown.svg"></a> | ![md-npm] | ![md-size] | Compiles Markdown to HTML |
package/bin/webpack.js CHANGED
File without changes
@@ -330,6 +330,8 @@ class NormalModule extends Module {
330
330
  this._isEvaluatingSideEffects = false;
331
331
  /** @type {WeakSet<ModuleGraph> | undefined} */
332
332
  this._addedSideEffectsBailout = undefined;
333
+ /** @type {Map<string, any>} */
334
+ this._codeGeneratorData = new Map();
333
335
  }
334
336
 
335
337
  /**
@@ -1188,11 +1190,9 @@ class NormalModule extends Module {
1188
1190
  runtimeRequirements.add(RuntimeGlobals.thisAsExports);
1189
1191
  }
1190
1192
 
1191
- /** @type {Map<string, any>} */
1192
- let data;
1193
+ /** @type {function(): Map<string, any>} */
1193
1194
  const getData = () => {
1194
- if (data === undefined) data = new Map();
1195
- return data;
1195
+ return this._codeGeneratorData;
1196
1196
  };
1197
1197
 
1198
1198
  const sources = new Map();
@@ -1223,7 +1223,7 @@ class NormalModule extends Module {
1223
1223
  const resultEntry = {
1224
1224
  sources,
1225
1225
  runtimeRequirements,
1226
- data
1226
+ data: this._codeGeneratorData
1227
1227
  };
1228
1228
  return resultEntry;
1229
1229
  }
@@ -1371,6 +1371,7 @@ class NormalModule extends Module {
1371
1371
  write(this.error);
1372
1372
  write(this._lastSuccessfulBuildMeta);
1373
1373
  write(this._forceBuild);
1374
+ write(this._codeGeneratorData);
1374
1375
  super.serialize(context);
1375
1376
  }
1376
1377
 
@@ -1403,6 +1404,7 @@ class NormalModule extends Module {
1403
1404
  this.error = read();
1404
1405
  this._lastSuccessfulBuildMeta = read();
1405
1406
  this._forceBuild = read();
1407
+ this._codeGeneratorData = read();
1406
1408
  super.deserialize(context);
1407
1409
  }
1408
1410
  }
@@ -137,7 +137,7 @@ class ImportParserPlugin {
137
137
  if (importOptions.webpackInclude !== undefined) {
138
138
  if (
139
139
  !importOptions.webpackInclude ||
140
- importOptions.webpackInclude.constructor.name !== "RegExp"
140
+ !(importOptions.webpackInclude instanceof RegExp)
141
141
  ) {
142
142
  parser.state.module.addWarning(
143
143
  new UnsupportedFeatureWarning(
@@ -146,13 +146,13 @@ class ImportParserPlugin {
146
146
  )
147
147
  );
148
148
  } else {
149
- include = new RegExp(importOptions.webpackInclude);
149
+ include = importOptions.webpackInclude;
150
150
  }
151
151
  }
152
152
  if (importOptions.webpackExclude !== undefined) {
153
153
  if (
154
154
  !importOptions.webpackExclude ||
155
- importOptions.webpackExclude.constructor.name !== "RegExp"
155
+ !(importOptions.webpackExclude instanceof RegExp)
156
156
  ) {
157
157
  parser.state.module.addWarning(
158
158
  new UnsupportedFeatureWarning(
@@ -161,7 +161,7 @@ class ImportParserPlugin {
161
161
  )
162
162
  );
163
163
  } else {
164
- exclude = new RegExp(importOptions.webpackExclude);
164
+ exclude = importOptions.webpackExclude;
165
165
  }
166
166
  }
167
167
  if (importOptions.webpackExports !== undefined) {
@@ -3635,17 +3635,27 @@ class JavascriptParser extends Parser {
3635
3635
  return EMPTY_COMMENT_OPTIONS;
3636
3636
  }
3637
3637
  let options = {};
3638
+ /** @type {unknown[]} */
3638
3639
  let errors = [];
3639
3640
  for (const comment of comments) {
3640
3641
  const { value } = comment;
3641
3642
  if (value && webpackCommentRegExp.test(value)) {
3642
3643
  // try compile only if webpack options comment is present
3643
3644
  try {
3644
- const val = vm.runInNewContext(`(function(){return {${value}};})()`);
3645
- Object.assign(options, val);
3645
+ for (let [key, val] of Object.entries(
3646
+ vm.runInNewContext(`(function(){return {${value}};})()`)
3647
+ )) {
3648
+ if (typeof val === "object" && val !== null) {
3649
+ if (val.constructor.name === "RegExp") val = new RegExp(val);
3650
+ else val = JSON.parse(JSON.stringify(val));
3651
+ }
3652
+ options[key] = val;
3653
+ }
3646
3654
  } catch (e) {
3647
- e.comment = comment;
3648
- errors.push(e);
3655
+ const newErr = new Error(String(e.message));
3656
+ newErr.stack = String(e.stack);
3657
+ Object.assign(newErr, { comment });
3658
+ errors.push(newErr);
3649
3659
  }
3650
3660
  }
3651
3661
  }
@@ -11,6 +11,7 @@ const ExternalsPlugin = require("../ExternalsPlugin");
11
11
 
12
12
  const builtins = [
13
13
  "assert",
14
+ "assert/strict",
14
15
  "async_hooks",
15
16
  "buffer",
16
17
  "child_process",
@@ -342,7 +342,6 @@ ${referencingAssets
342
342
  for (const oldHash of hashesInOrder) {
343
343
  const assets = hashToAssets.get(oldHash);
344
344
  assets.sort(comparator);
345
- const hash = createHash(this._hashFunction);
346
345
  await Promise.all(
347
346
  assets.map(asset =>
348
347
  asset.ownHashes.has(oldHash)
@@ -363,6 +362,10 @@ ${referencingAssets
363
362
  });
364
363
  let newHash = hooks.updateHash.call(assetsContent, oldHash);
365
364
  if (!newHash) {
365
+ const hash = createHash(this._hashFunction);
366
+ if (compilation.outputOptions.hashSalt) {
367
+ hash.update(compilation.outputOptions.hashSalt);
368
+ }
366
369
  for (const content of assetsContent) {
367
370
  hash.update(content);
368
371
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.75.0",
3
+ "version": "5.76.1",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
6
6
  "license": "MIT",
@@ -76,7 +76,7 @@
76
76
  "less": "^4.0.0",
77
77
  "less-loader": "^8.0.0",
78
78
  "lint-staged": "^11.0.0",
79
- "loader-utils": "^2.0.0",
79
+ "loader-utils": "^2.0.3",
80
80
  "lodash": "^4.17.19",
81
81
  "lodash-es": "^4.17.15",
82
82
  "memfs": "^3.2.0",
package/types.d.ts CHANGED
@@ -6595,6 +6595,12 @@ declare interface LoaderRunnerLoaderContext<OptionsType> {
6595
6595
  * Example: "/abc/resource.js?query#frag"
6596
6596
  */
6597
6597
  resource: string;
6598
+
6599
+ /**
6600
+ * Target of compilation.
6601
+ * Example: "web"
6602
+ */
6603
+ target: string;
6598
6604
  }
6599
6605
  declare class LoaderTargetPlugin {
6600
6606
  constructor(target: string);