webpack 5.82.0 → 5.82.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.

@@ -124,10 +124,14 @@ const _isWhiteSpace = cc => {
124
124
  };
125
125
 
126
126
  /**
127
+ * ident-start code point
128
+ *
129
+ * A letter, a non-ASCII code point, or U+005F LOW LINE (_).
130
+ *
127
131
  * @param {number} cc char code
128
132
  * @returns {boolean} true, if cc is a start code point of an identifier
129
133
  */
130
- const _isIdentStartCodePoint = cc => {
134
+ const isIdentStartCodePoint = cc => {
131
135
  return (
132
136
  (cc >= CC_LOWER_A && cc <= CC_LOWER_Z) ||
133
137
  (cc >= CC_UPPER_A && cc <= CC_UPPER_Z) ||
@@ -341,11 +345,7 @@ const consumeNumericToken = (input, pos, callbacks) => {
341
345
  const consumeOtherIdentifier = (input, pos, callbacks) => {
342
346
  const start = pos;
343
347
  pos = _consumeIdentifier(input, pos, callbacks);
344
- if (
345
- pos !== input.length &&
346
- !callbacks.isSelector(input, pos) &&
347
- input.charCodeAt(pos) === CC_LEFT_PARENTHESIS
348
- ) {
348
+ if (pos !== input.length && input.charCodeAt(pos) === CC_LEFT_PARENTHESIS) {
349
349
  pos++;
350
350
  if (callbacks.function !== undefined) {
351
351
  return callbacks.function(input, start, pos);
@@ -683,7 +683,7 @@ const CHAR_MAP = Array.from({ length: 0x80 }, (_, cc) => {
683
683
  // digit
684
684
  if (_isDigit(cc)) return consumeNumericToken;
685
685
  // ident-start code point
686
- if (_isIdentStartCodePoint(cc)) {
686
+ if (isIdentStartCodePoint(cc)) {
687
687
  return consumeOtherIdentifier;
688
688
  }
689
689
  // EOF, but we don't have it
@@ -715,6 +715,8 @@ module.exports = (input, callbacks) => {
715
715
  }
716
716
  };
717
717
 
718
+ module.exports.isIdentStartCodePoint = isIdentStartCodePoint;
719
+
718
720
  /**
719
721
  * @param {string} input input
720
722
  * @param {number} pos position
@@ -732,6 +734,19 @@ module.exports.eatComments = (input, pos) => {
732
734
  return pos;
733
735
  };
734
736
 
737
+ /**
738
+ * @param {string} input input
739
+ * @param {number} pos position
740
+ * @returns {number} position after whitespace
741
+ */
742
+ module.exports.eatWhitespace = (input, pos) => {
743
+ while (_isWhiteSpace(input.charCodeAt(pos))) {
744
+ pos++;
745
+ }
746
+
747
+ return pos;
748
+ };
749
+
735
750
  /**
736
751
  * @param {string} input input
737
752
  * @param {number} pos position
@@ -127,7 +127,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
127
127
  "",
128
128
  "// object to store loaded and loading chunks",
129
129
  "// undefined = chunk not loaded, null = chunk preloaded/prefetched",
130
- "// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded",
130
+ "// [resolve, Promise] = chunk loading, 0 = chunk loaded",
131
131
  `var installedChunks = ${
132
132
  stateExpression ? `${stateExpression} = ${stateExpression} || ` : ""
133
133
  }{`,
@@ -210,7 +210,9 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
210
210
  )})])`,
211
211
  `promises.push(installedChunkData[1] = promise);`
212
212
  ]),
213
- "} else installedChunks[chunkId] = 0;"
213
+ hasJsMatcher === true
214
+ ? "}"
215
+ : "} else installedChunks[chunkId] = 0;"
214
216
  ]),
215
217
  "}"
216
218
  ]),
@@ -10,6 +10,9 @@ const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
10
10
  const Dependency = require("../Dependency");
11
11
  const Module = require("../Module");
12
12
  const ModuleFactory = require("../ModuleFactory");
13
+ const {
14
+ WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY
15
+ } = require("../ModuleTypeConstants");
13
16
  const RuntimeGlobals = require("../RuntimeGlobals");
14
17
  const Template = require("../Template");
15
18
  const CommonJsRequireDependency = require("../dependencies/CommonJsRequireDependency");
@@ -95,7 +98,11 @@ registerNotSerializable(LazyCompilationDependency);
95
98
 
96
99
  class LazyCompilationProxyModule extends Module {
97
100
  constructor(context, originalModule, request, client, data, active) {
98
- super("lazy-compilation-proxy", context, originalModule.layer);
101
+ super(
102
+ WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY,
103
+ context,
104
+ originalModule.layer
105
+ );
99
106
  this.originalModule = originalModule;
100
107
  this.request = request;
101
108
  this.client = client;
@@ -107,7 +114,7 @@ class LazyCompilationProxyModule extends Module {
107
114
  * @returns {string} a unique identifier of the module
108
115
  */
109
116
  identifier() {
110
- return `lazy-compilation-proxy|${this.originalModule.identifier()}`;
117
+ return `${WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY}|${this.originalModule.identifier()}`;
111
118
  }
112
119
 
113
120
  /**
@@ -115,7 +122,7 @@ class LazyCompilationProxyModule extends Module {
115
122
  * @returns {string} a user readable identifier of the module
116
123
  */
117
124
  readableIdentifier(requestShortener) {
118
- return `lazy-compilation-proxy ${this.originalModule.readableIdentifier(
125
+ return `${WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY} ${this.originalModule.readableIdentifier(
119
126
  requestShortener
120
127
  )}`;
121
128
  }
@@ -142,7 +149,9 @@ class LazyCompilationProxyModule extends Module {
142
149
  * @returns {string | null} an identifier for library inclusion
143
150
  */
144
151
  libIdent(options) {
145
- return `${this.originalModule.libIdent(options)}!lazy-compilation-proxy`;
152
+ return `${this.originalModule.libIdent(
153
+ options
154
+ )}!${WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY}`;
146
155
  }
147
156
 
148
157
  /**
@@ -21,7 +21,8 @@ const InitFragment = require("../InitFragment");
21
21
  const {
22
22
  JAVASCRIPT_MODULE_TYPE_AUTO,
23
23
  JAVASCRIPT_MODULE_TYPE_DYNAMIC,
24
- JAVASCRIPT_MODULE_TYPE_ESM
24
+ JAVASCRIPT_MODULE_TYPE_ESM,
25
+ WEBPACK_MODULE_TYPE_RUNTIME
25
26
  } = require("../ModuleTypeConstants");
26
27
  const RuntimeGlobals = require("../RuntimeGlobals");
27
28
  const Template = require("../Template");
@@ -394,7 +395,7 @@ class JavascriptModulesPlugin {
394
395
  }
395
396
  const runtimeModules = chunkGraph.getChunkModulesIterableBySourceType(
396
397
  chunk,
397
- "runtime"
398
+ WEBPACK_MODULE_TYPE_RUNTIME
398
399
  );
399
400
  if (runtimeModules) {
400
401
  const xor = new StringXor();
@@ -178,7 +178,9 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
178
178
  "});",
179
179
  "promises.push(installedChunkData[2] = promise);"
180
180
  ]),
181
- "} else installedChunks[chunkId] = 0;"
181
+ hasJsMatcher === true
182
+ ? "}"
183
+ : "} else installedChunks[chunkId] = 0;"
182
184
  ]),
183
185
  "}"
184
186
  ]),
@@ -8,6 +8,9 @@
8
8
  const { RawSource } = require("webpack-sources");
9
9
  const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
10
10
  const Module = require("../Module");
11
+ const {
12
+ WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE
13
+ } = require("../ModuleTypeConstants");
11
14
  const RuntimeGlobals = require("../RuntimeGlobals");
12
15
  const makeSerializable = require("../util/makeSerializable");
13
16
  const { rangeToString, stringifyHoley } = require("../util/semver");
@@ -52,7 +55,7 @@ class ConsumeSharedModule extends Module {
52
55
  * @param {ConsumeOptions} options consume options
53
56
  */
54
57
  constructor(context, options) {
55
- super("consume-shared-module", context);
58
+ super(WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE, context);
56
59
  this.options = options;
57
60
  }
58
61
 
@@ -69,7 +72,7 @@ class ConsumeSharedModule extends Module {
69
72
  singleton,
70
73
  eager
71
74
  } = this.options;
72
- return `consume-shared-module|${shareScope}|${shareKey}|${
75
+ return `${WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE}|${shareScope}|${shareKey}|${
73
76
  requiredVersion && rangeToString(requiredVersion)
74
77
  }|${strictVersion}|${importResolved}|${singleton}|${eager}`;
75
78
  }
@@ -7,6 +7,7 @@
7
7
 
8
8
  const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
9
9
  const Module = require("../Module");
10
+ const { WEBPACK_MODULE_TYPE_PROVIDE } = require("../ModuleTypeConstants");
10
11
  const RuntimeGlobals = require("../RuntimeGlobals");
11
12
  const makeSerializable = require("../util/makeSerializable");
12
13
  const ProvideForSharedDependency = require("./ProvideForSharedDependency");
@@ -39,7 +40,7 @@ class ProvideSharedModule extends Module {
39
40
  * @param {boolean} eager include the module in sync way
40
41
  */
41
42
  constructor(shareScope, name, version, request, eager) {
42
- super("provide-module");
43
+ super(WEBPACK_MODULE_TYPE_PROVIDE);
43
44
  this._shareScope = shareScope;
44
45
  this._name = name;
45
46
  this._version = version;
@@ -6,6 +6,7 @@
6
6
  "use strict";
7
7
 
8
8
  const util = require("util");
9
+ const { WEBPACK_MODULE_TYPE_RUNTIME } = require("../ModuleTypeConstants");
9
10
  const ModuleDependency = require("../dependencies/ModuleDependency");
10
11
  const formatLocation = require("../formatLocation");
11
12
  const { LogType } = require("../logging/Logger");
@@ -2093,19 +2094,21 @@ const MODULES_GROUPERS = type => ({
2093
2094
  if (!module.moduleType) return;
2094
2095
  if (groupModulesByType) {
2095
2096
  return [module.moduleType.split("/", 1)[0]];
2096
- } else if (module.moduleType === "runtime") {
2097
- return ["runtime"];
2097
+ } else if (module.moduleType === WEBPACK_MODULE_TYPE_RUNTIME) {
2098
+ return [WEBPACK_MODULE_TYPE_RUNTIME];
2098
2099
  }
2099
2100
  },
2100
2101
  getOptions: key => {
2101
- const exclude = key === "runtime" && !options.runtimeModules;
2102
+ const exclude =
2103
+ key === WEBPACK_MODULE_TYPE_RUNTIME && !options.runtimeModules;
2102
2104
  return {
2103
2105
  groupChildren: !exclude,
2104
2106
  force: exclude
2105
2107
  };
2106
2108
  },
2107
2109
  createGroup: (key, children, modules) => {
2108
- const exclude = key === "runtime" && !options.runtimeModules;
2110
+ const exclude =
2111
+ key === WEBPACK_MODULE_TYPE_RUNTIME && !options.runtimeModules;
2109
2112
  return {
2110
2113
  type: `${key} modules`,
2111
2114
  moduleType: key,
@@ -107,8 +107,9 @@ class DebugHash extends Hash {
107
107
  */
108
108
  update(data, inputEncoding) {
109
109
  if (typeof data !== "string") data = data.toString("utf-8");
110
- if (data.startsWith("debug-digest-")) {
111
- data = Buffer.from(data.slice("debug-digest-".length), "hex").toString();
110
+ const prefix = Buffer.from("@webpack-debug-digest@").toString("hex");
111
+ if (data.startsWith(prefix)) {
112
+ data = Buffer.from(data.slice(prefix.length), "hex").toString();
112
113
  }
113
114
  this.string += `[${data}](${new Error().stack.split("\n", 3)[2]})\n`;
114
115
  return this;
@@ -120,7 +121,7 @@ class DebugHash extends Hash {
120
121
  * @returns {string|Buffer} digest
121
122
  */
122
123
  digest(encoding) {
123
- return "debug-digest-" + Buffer.from(this.string).toString("hex");
124
+ return Buffer.from("@webpack-debug-digest@" + this.string).toString("hex");
124
125
  }
125
126
  }
126
127
 
@@ -189,7 +189,9 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
189
189
  )};`,
190
190
  `${RuntimeGlobals.loadScript}(url, loadingEnded, "chunk-" + chunkId, chunkId);`
191
191
  ]),
192
- "} else installedChunks[chunkId] = 0;"
192
+ hasJsMatcher === true
193
+ ? "}"
194
+ : "} else installedChunks[chunkId] = 0;"
193
195
  ]),
194
196
  "}"
195
197
  ]),
@@ -250,7 +252,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
250
252
  linkPreload.call(
251
253
  Template.asString([
252
254
  "var link = document.createElement('link');",
253
- scriptType
255
+ scriptType && scriptType !== "module"
254
256
  ? `link.type = ${JSON.stringify(scriptType)};`
255
257
  : "",
256
258
  "link.charset = 'utf-8';",
@@ -259,8 +261,10 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
259
261
  `link.setAttribute("nonce", ${RuntimeGlobals.scriptNonce});`
260
262
  ),
261
263
  "}",
262
- 'link.rel = "preload";',
263
- 'link.as = "script";',
264
+ scriptType === "module"
265
+ ? 'link.rel = "modulepreload";'
266
+ : 'link.rel = "preload";',
267
+ scriptType === "module" ? "" : 'link.as = "script";',
264
268
  `link.href = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkScriptFilename}(chunkId);`,
265
269
  crossOriginLoading
266
270
  ? crossOriginLoading === "use-credentials"
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.82.0",
3
+ "version": "5.82.1",
4
4
  "author": "Tobias Koppers @sokra",
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.",
5
+ "description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
6
6
  "license": "MIT",
7
7
  "dependencies": {
8
8
  "@types/eslint-scope": "^3.7.3",
@@ -14,7 +14,7 @@
14
14
  "acorn-import-assertions": "^1.7.6",
15
15
  "browserslist": "^4.14.5",
16
16
  "chrome-trace-event": "^1.0.2",
17
- "enhanced-resolve": "^5.13.0",
17
+ "enhanced-resolve": "^5.14.0",
18
18
  "es-module-lexer": "^1.2.1",
19
19
  "eslint-scope": "5.1.1",
20
20
  "events": "^3.2.0",
package/types.d.ts CHANGED
@@ -3506,6 +3506,7 @@ declare class EnvironmentPlugin {
3506
3506
  */
3507
3507
  apply(compiler: Compiler): void;
3508
3508
  }
3509
+ type ErrorWithDetail = Error & { details?: string };
3509
3510
  declare interface Etag {
3510
3511
  toString: () => string;
3511
3512
  }
@@ -6871,8 +6872,54 @@ declare interface MinChunkSizePluginOptions {
6871
6872
  minChunkSize: number;
6872
6873
  }
6873
6874
  declare class Module extends DependenciesBlock {
6874
- constructor(type: string, context?: string, layer?: string);
6875
- type: string;
6875
+ constructor(
6876
+ type:
6877
+ | ""
6878
+ | "runtime"
6879
+ | "javascript/auto"
6880
+ | "javascript/dynamic"
6881
+ | "javascript/esm"
6882
+ | "json"
6883
+ | "webassembly/async"
6884
+ | "webassembly/sync"
6885
+ | "css"
6886
+ | "css/global"
6887
+ | "css/module"
6888
+ | "asset"
6889
+ | "asset/inline"
6890
+ | "asset/resource"
6891
+ | "asset/source"
6892
+ | "asset/raw-data-url"
6893
+ | "fallback-module"
6894
+ | "remote-module"
6895
+ | "provide-module"
6896
+ | "consume-shared-module"
6897
+ | "lazy-compilation-proxy",
6898
+ context?: string,
6899
+ layer?: string
6900
+ );
6901
+ type:
6902
+ | ""
6903
+ | "runtime"
6904
+ | "javascript/auto"
6905
+ | "javascript/dynamic"
6906
+ | "javascript/esm"
6907
+ | "json"
6908
+ | "webassembly/async"
6909
+ | "webassembly/sync"
6910
+ | "css"
6911
+ | "css/global"
6912
+ | "css/module"
6913
+ | "asset"
6914
+ | "asset/inline"
6915
+ | "asset/resource"
6916
+ | "asset/source"
6917
+ | "asset/raw-data-url"
6918
+ | "fallback-module"
6919
+ | "remote-module"
6920
+ | "provide-module"
6921
+ | "consume-shared-module"
6922
+ | "lazy-compilation-proxy";
6876
6923
  context: null | string;
6877
6924
  layer: null | string;
6878
6925
  needId: boolean;
@@ -7831,9 +7878,9 @@ declare interface NormalModuleCreateData {
7831
7878
  layer?: string;
7832
7879
 
7833
7880
  /**
7834
- * module type
7881
+ * module type. When deserializing, this is set to an empty string "".
7835
7882
  */
7836
- type: string;
7883
+ type: "" | "javascript/auto" | "javascript/dynamic" | "javascript/esm";
7837
7884
 
7838
7885
  /**
7839
7886
  * request string
@@ -7977,9 +8024,9 @@ declare interface NormalModuleLoaderContext<OptionsType> {
7977
8024
  context: string,
7978
8025
  request: string,
7979
8026
  callback: (
7980
- arg0: null | Error,
7981
- arg1?: string | false,
7982
- arg2?: ResolveRequest
8027
+ err: null | ErrorWithDetail,
8028
+ res?: string | false,
8029
+ req?: ResolveRequest
7983
8030
  ) => void
7984
8031
  ): any;
7985
8032
  getResolve(options?: ResolveOptionsWithDependencyType): {
@@ -7987,9 +8034,9 @@ declare interface NormalModuleLoaderContext<OptionsType> {
7987
8034
  context: string,
7988
8035
  request: string,
7989
8036
  callback: (
7990
- arg0: null | Error,
7991
- arg1?: string | false,
7992
- arg2?: ResolveRequest
8037
+ err: null | ErrorWithDetail,
8038
+ res?: string | false,
8039
+ req?: ResolveRequest
7993
8040
  ) => void
7994
8041
  ): void;
7995
8042
  (context: string, request: string): Promise<string>;
@@ -10088,9 +10135,9 @@ declare abstract class Resolver {
10088
10135
  request: string,
10089
10136
  resolveContext: ResolveContext,
10090
10137
  callback: (
10091
- arg0: null | Error,
10092
- arg1?: string | false,
10093
- arg2?: ResolveRequest
10138
+ err: null | ErrorWithDetail,
10139
+ res?: string | false,
10140
+ req?: ResolveRequest
10094
10141
  ) => void
10095
10142
  ): void;
10096
10143
  doResolve(