webpack 5.60.0 → 5.62.2

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.

Files changed (42) hide show
  1. package/lib/Chunk.js +3 -2
  2. package/lib/Compilation.js +36 -20
  3. package/lib/Compiler.js +13 -11
  4. package/lib/HotModuleReplacementPlugin.js +3 -1
  5. package/lib/NormalModule.js +3 -0
  6. package/lib/RuntimePlugin.js +9 -1
  7. package/lib/cache/PackFileCacheStrategy.js +3 -3
  8. package/lib/config/defaults.js +18 -10
  9. package/lib/config/normalization.js +1 -0
  10. package/lib/dependencies/AMDRequireDependency.js +6 -6
  11. package/lib/dependencies/CommonJsFullRequireDependency.js +5 -1
  12. package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -1
  13. package/lib/dependencies/CommonJsRequireContextDependency.js +5 -1
  14. package/lib/dependencies/ContextDependency.js +1 -0
  15. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +4 -1
  16. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +12 -3
  17. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +25 -17
  18. package/lib/dependencies/HarmonyImportDependency.js +23 -0
  19. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +17 -4
  20. package/lib/dependencies/HarmonyImportSpecifierDependency.js +24 -14
  21. package/lib/dependencies/RequireEnsureDependency.js +2 -2
  22. package/lib/hmr/lazyCompilationBackend.js +6 -1
  23. package/lib/node/NodeTargetPlugin.js +2 -0
  24. package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -1
  25. package/lib/optimize/ModuleConcatenationPlugin.js +5 -2
  26. package/lib/optimize/SplitChunksPlugin.js +8 -1
  27. package/lib/runtime/AsyncModuleRuntimeModule.js +2 -2
  28. package/lib/sharing/ConsumeSharedRuntimeModule.js +1 -1
  29. package/lib/sharing/ShareRuntimeModule.js +1 -1
  30. package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
  31. package/lib/util/createHash.js +12 -0
  32. package/lib/util/deprecation.js +10 -2
  33. package/lib/util/hash/BatchedHash.js +7 -4
  34. package/lib/util/hash/md4.js +20 -0
  35. package/lib/util/hash/wasm-hash.js +163 -0
  36. package/lib/util/hash/xxhash64.js +5 -139
  37. package/lib/webpack.js +1 -2
  38. package/module.d.ts +200 -0
  39. package/package.json +12 -10
  40. package/schemas/WebpackOptions.check.js +1 -1
  41. package/schemas/WebpackOptions.json +45 -21
  42. package/types.d.ts +34 -13
@@ -40,6 +40,8 @@ const processExportInfo = require("./processExportInfo");
40
40
 
41
41
  /** @typedef {"missing"|"unused"|"empty-star"|"reexport-dynamic-default"|"reexport-named-default"|"reexport-namespace-object"|"reexport-fake-namespace-object"|"reexport-undefined"|"normal-reexport"|"dynamic-reexport"} ExportModeType */
42
42
 
43
+ const { ExportPresenceModes } = HarmonyImportDependency;
44
+
43
45
  const idsSymbol = Symbol("HarmonyExportImportedSpecifierDependency.ids");
44
46
 
45
47
  class NormalReexportItem {
@@ -325,7 +327,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
325
327
  * @param {string | null} name the export name of for this module
326
328
  * @param {Set<string>} activeExports other named exports in the module
327
329
  * @param {ReadonlyArray<HarmonyExportImportedSpecifierDependency> | Iterable<HarmonyExportImportedSpecifierDependency>} otherStarExports other star exports in the module before this import
328
- * @param {boolean} strictExportPresence when true, missing exports in the imported module lead to errors instead of warnings
330
+ * @param {number} exportPresenceMode mode of checking export names
329
331
  * @param {HarmonyStarExportsList} allStarExports all star exports in the module
330
332
  * @param {Record<string, any>=} assertions import assertions
331
333
  */
@@ -336,7 +338,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
336
338
  name,
337
339
  activeExports,
338
340
  otherStarExports,
339
- strictExportPresence,
341
+ exportPresenceMode,
340
342
  allStarExports,
341
343
  assertions
342
344
  ) {
@@ -346,7 +348,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
346
348
  this.name = name;
347
349
  this.activeExports = activeExports;
348
350
  this.otherStarExports = otherStarExports;
349
- this.strictExportPresence = strictExportPresence;
351
+ this.exportPresenceMode = exportPresenceMode;
350
352
  this.allStarExports = allStarExports;
351
353
  }
352
354
 
@@ -735,20 +737,29 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
735
737
  }
736
738
  }
737
739
 
740
+ /**
741
+ * @param {ModuleGraph} moduleGraph module graph
742
+ * @returns {number} effective mode
743
+ */
744
+ _getEffectiveExportPresenceLevel(moduleGraph) {
745
+ if (this.exportPresenceMode !== ExportPresenceModes.AUTO)
746
+ return this.exportPresenceMode;
747
+ return moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule
748
+ ? ExportPresenceModes.ERROR
749
+ : ExportPresenceModes.WARN;
750
+ }
751
+
738
752
  /**
739
753
  * Returns warnings
740
754
  * @param {ModuleGraph} moduleGraph module graph
741
755
  * @returns {WebpackError[]} warnings
742
756
  */
743
757
  getWarnings(moduleGraph) {
744
- if (
745
- this.strictExportPresence ||
746
- moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule
747
- ) {
748
- return null;
758
+ const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
759
+ if (exportsPresence === ExportPresenceModes.WARN) {
760
+ return this._getErrors(moduleGraph);
749
761
  }
750
-
751
- return this._getErrors(moduleGraph);
762
+ return null;
752
763
  }
753
764
 
754
765
  /**
@@ -757,13 +768,10 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
757
768
  * @returns {WebpackError[]} errors
758
769
  */
759
770
  getErrors(moduleGraph) {
760
- if (
761
- this.strictExportPresence ||
762
- moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule
763
- ) {
771
+ const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
772
+ if (exportsPresence === ExportPresenceModes.ERROR) {
764
773
  return this._getErrors(moduleGraph);
765
774
  }
766
-
767
775
  return null;
768
776
  }
769
777
 
@@ -856,7 +864,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
856
864
  write(this.name);
857
865
  write(this.activeExports);
858
866
  write(this.otherStarExports);
859
- write(this.strictExportPresence);
867
+ write(this.exportPresenceMode);
860
868
  write(this.allStarExports);
861
869
 
862
870
  super.serialize(context);
@@ -870,7 +878,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
870
878
  this.name = read();
871
879
  this.activeExports = read();
872
880
  this.otherStarExports = read();
873
- this.strictExportPresence = read();
881
+ this.exportPresenceMode = read();
874
882
  this.allStarExports = read();
875
883
 
876
884
  super.deserialize(context);
@@ -27,6 +27,27 @@ const ModuleDependency = require("./ModuleDependency");
27
27
  /** @typedef {import("../util/Hash")} Hash */
28
28
  /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
29
29
 
30
+ const ExportPresenceModes = {
31
+ NONE: /** @type {0} */ (0),
32
+ WARN: /** @type {1} */ (1),
33
+ AUTO: /** @type {2} */ (2),
34
+ ERROR: /** @type {3} */ (3),
35
+ fromUserOption(str) {
36
+ switch (str) {
37
+ case "error":
38
+ return ExportPresenceModes.ERROR;
39
+ case "warn":
40
+ return ExportPresenceModes.WARN;
41
+ case "auto":
42
+ return ExportPresenceModes.AUTO;
43
+ case false:
44
+ return ExportPresenceModes.NONE;
45
+ default:
46
+ throw new Error(`Invalid export presence value ${str}`);
47
+ }
48
+ }
49
+ };
50
+
30
51
  class HarmonyImportDependency extends ModuleDependency {
31
52
  /**
32
53
  *
@@ -334,3 +355,5 @@ HarmonyImportDependency.Template = class HarmonyImportDependencyTemplate extends
334
355
  return emittedModules.get(referencedModule) || false;
335
356
  }
336
357
  };
358
+
359
+ module.exports.ExportPresenceModes = ExportPresenceModes;
@@ -11,6 +11,7 @@ const ConstDependency = require("./ConstDependency");
11
11
  const HarmonyAcceptDependency = require("./HarmonyAcceptDependency");
12
12
  const HarmonyAcceptImportDependency = require("./HarmonyAcceptImportDependency");
13
13
  const HarmonyExports = require("./HarmonyExports");
14
+ const { ExportPresenceModes } = require("./HarmonyImportDependency");
14
15
  const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
15
16
  const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDependency");
16
17
 
@@ -19,6 +20,7 @@ const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDepend
19
20
  /** @typedef {import("estree").Identifier} Identifier */
20
21
  /** @typedef {import("estree").ImportDeclaration} ImportDeclaration */
21
22
  /** @typedef {import("estree").ImportExpression} ImportExpression */
23
+ /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
22
24
  /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
23
25
  /** @typedef {import("../optimize/InnerGraph").InnerGraph} InnerGraph */
24
26
  /** @typedef {import("../optimize/InnerGraph").TopLevelSymbol} TopLevelSymbol */
@@ -60,8 +62,18 @@ function getAssertions(node) {
60
62
  }
61
63
 
62
64
  module.exports = class HarmonyImportDependencyParserPlugin {
65
+ /**
66
+ * @param {JavascriptParserOptions} options options
67
+ */
63
68
  constructor(options) {
64
- this.strictExportPresence = options.strictExportPresence;
69
+ this.exportPresenceMode =
70
+ options.importExportsPresence !== undefined
71
+ ? ExportPresenceModes.fromUserOption(options.importExportsPresence)
72
+ : options.exportsPresence !== undefined
73
+ ? ExportPresenceModes.fromUserOption(options.exportsPresence)
74
+ : options.strictExportPresence
75
+ ? ExportPresenceModes.ERROR
76
+ : ExportPresenceModes.AUTO;
65
77
  this.strictThisContextOnImports = options.strictThisContextOnImports;
66
78
  }
67
79
 
@@ -70,6 +82,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
70
82
  * @returns {void}
71
83
  */
72
84
  apply(parser) {
85
+ const { exportPresenceMode } = this;
73
86
  parser.hooks.isPure
74
87
  .for("Identifier")
75
88
  .tap("HarmonyImportDependencyParserPlugin", expression => {
@@ -128,7 +141,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
128
141
  settings.ids,
129
142
  settings.name,
130
143
  expr.range,
131
- this.strictExportPresence,
144
+ exportPresenceMode,
132
145
  settings.assertions
133
146
  );
134
147
  dep.shorthand = parser.scope.inShorthand;
@@ -150,7 +163,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
150
163
  ids,
151
164
  settings.name,
152
165
  expr.range,
153
- this.strictExportPresence,
166
+ exportPresenceMode,
154
167
  settings.assertions
155
168
  );
156
169
  dep.asiSafe = !parser.isAsiPosition(expr.range[0]);
@@ -171,7 +184,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
171
184
  ids,
172
185
  settings.name,
173
186
  callee.range,
174
- this.strictExportPresence,
187
+ exportPresenceMode,
175
188
  settings.assertions
176
189
  );
177
190
  dep.directImport = members.length === 0;
@@ -28,6 +28,8 @@ const HarmonyImportDependency = require("./HarmonyImportDependency");
28
28
 
29
29
  const idsSymbol = Symbol("HarmonyImportSpecifierDependency.ids");
30
30
 
31
+ const { ExportPresenceModes } = HarmonyImportDependency;
32
+
31
33
  class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
32
34
  constructor(
33
35
  request,
@@ -35,14 +37,14 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
35
37
  ids,
36
38
  name,
37
39
  range,
38
- strictExportPresence,
40
+ exportPresenceMode,
39
41
  assertions
40
42
  ) {
41
43
  super(request, sourceOrder, assertions);
42
44
  this.ids = ids;
43
45
  this.name = name;
44
46
  this.range = range;
45
- this.strictExportPresence = strictExportPresence;
47
+ this.exportPresenceMode = exportPresenceMode;
46
48
  this.namespaceObjectAsContext = false;
47
49
  this.call = undefined;
48
50
  this.directImport = undefined;
@@ -153,19 +155,29 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
153
155
  return [ids];
154
156
  }
155
157
 
158
+ /**
159
+ * @param {ModuleGraph} moduleGraph module graph
160
+ * @returns {number} effective mode
161
+ */
162
+ _getEffectiveExportPresenceLevel(moduleGraph) {
163
+ if (this.exportPresenceMode !== ExportPresenceModes.AUTO)
164
+ return this.exportPresenceMode;
165
+ return moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule
166
+ ? ExportPresenceModes.ERROR
167
+ : ExportPresenceModes.WARN;
168
+ }
169
+
156
170
  /**
157
171
  * Returns warnings
158
172
  * @param {ModuleGraph} moduleGraph module graph
159
173
  * @returns {WebpackError[]} warnings
160
174
  */
161
175
  getWarnings(moduleGraph) {
162
- if (
163
- this.strictExportPresence ||
164
- moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule
165
- ) {
166
- return null;
176
+ const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
177
+ if (exportsPresence === ExportPresenceModes.WARN) {
178
+ return this._getErrors(moduleGraph);
167
179
  }
168
- return this._getErrors(moduleGraph);
180
+ return null;
169
181
  }
170
182
 
171
183
  /**
@@ -174,10 +186,8 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
174
186
  * @returns {WebpackError[]} errors
175
187
  */
176
188
  getErrors(moduleGraph) {
177
- if (
178
- this.strictExportPresence ||
179
- moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule
180
- ) {
189
+ const exportsPresence = this._getEffectiveExportPresenceLevel(moduleGraph);
190
+ if (exportsPresence === ExportPresenceModes.ERROR) {
181
191
  return this._getErrors(moduleGraph);
182
192
  }
183
193
  return null;
@@ -209,7 +219,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
209
219
  write(this.ids);
210
220
  write(this.name);
211
221
  write(this.range);
212
- write(this.strictExportPresence);
222
+ write(this.exportPresenceMode);
213
223
  write(this.namespaceObjectAsContext);
214
224
  write(this.call);
215
225
  write(this.directImport);
@@ -224,7 +234,7 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
224
234
  this.ids = read();
225
235
  this.name = read();
226
236
  this.range = read();
227
- this.strictExportPresence = read();
237
+ this.exportPresenceMode = read();
228
238
  this.namespaceObjectAsContext = read();
229
239
  this.call = read();
230
240
  this.directImport = read();
@@ -85,14 +85,14 @@ RequireEnsureDependency.Template = class RequireEnsureDependencyTemplate extends
85
85
  source.replace(
86
86
  contentRange[1],
87
87
  errorHandlerRange[0] - 1,
88
- ").bind(null, __webpack_require__)).catch("
88
+ ").bind(null, __webpack_require__))['catch']("
89
89
  );
90
90
  source.replace(errorHandlerRange[1], range[1] - 1, ")");
91
91
  } else {
92
92
  source.replace(
93
93
  contentRange[1],
94
94
  range[1] - 1,
95
- `).bind(null, __webpack_require__)).catch(${RuntimeGlobals.uncaughtErrorHandler})`
95
+ `).bind(null, __webpack_require__))['catch'](${RuntimeGlobals.uncaughtErrorHandler})`
96
96
  );
97
97
  }
98
98
  }
@@ -41,7 +41,12 @@ module.exports = options => (compiler, callback) => {
41
41
  const listen =
42
42
  typeof options.listen === "function"
43
43
  ? options.listen
44
- : server => server.listen(options.listen);
44
+ : server => {
45
+ let listen = options.listen;
46
+ if (typeof listen === "object" && !("port" in listen))
47
+ listen = { ...listen, port: undefined };
48
+ server.listen(listen);
49
+ };
45
50
 
46
51
  const protocol = options.protocol || (isHttps ? "https" : "http");
47
52
 
@@ -34,6 +34,8 @@ const builtins = [
34
34
  "net",
35
35
  "os",
36
36
  "path",
37
+ "path/posix",
38
+ "path/win32",
37
39
  "perf_hooks",
38
40
  "process",
39
41
  "punycode",
@@ -211,7 +211,7 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
211
211
  RuntimeGlobals.getUpdateManifestFilename
212
212
  }());`
213
213
  ]),
214
- '}).catch(function(err) { if(err.code !== "MODULE_NOT_FOUND") throw err; });'
214
+ "})['catch'](function(err) { if(err.code !== 'MODULE_NOT_FOUND') throw err; });"
215
215
  ]),
216
216
  "}"
217
217
  ])
@@ -56,6 +56,7 @@ class ModuleConcatenationPlugin {
56
56
  * @returns {void}
57
57
  */
58
58
  apply(compiler) {
59
+ const { _backCompat: backCompat } = compiler;
59
60
  compiler.hooks.compilation.tap("ModuleConcatenationPlugin", compilation => {
60
61
  const moduleGraph = compilation.moduleGraph;
61
62
  const bailoutReasonMap = new Map();
@@ -389,8 +390,10 @@ class ModuleConcatenationPlugin {
389
390
  };
390
391
 
391
392
  const integrate = () => {
392
- ChunkGraph.setChunkGraphForModule(newModule, chunkGraph);
393
- ModuleGraph.setModuleGraphForModule(newModule, moduleGraph);
393
+ if (backCompat) {
394
+ ChunkGraph.setChunkGraphForModule(newModule, chunkGraph);
395
+ ModuleGraph.setModuleGraphForModule(newModule, moduleGraph);
396
+ }
394
397
 
395
398
  for (const warning of concatConfiguration.getWarningsSorted()) {
396
399
  moduleGraph
@@ -102,6 +102,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
102
102
 
103
103
  /**
104
104
  * @typedef {Object} FallbackCacheGroup
105
+ * @property {ChunkFilterFunction} chunksFilter
105
106
  * @property {SplitChunksSizes} minSize
106
107
  * @property {SplitChunksSizes} maxAsyncSize
107
108
  * @property {SplitChunksSizes} maxInitialSize
@@ -658,6 +659,9 @@ module.exports = class SplitChunksPlugin {
658
659
  automaticNameDelimiter: options.automaticNameDelimiter,
659
660
  usedExports: options.usedExports,
660
661
  fallbackCacheGroup: {
662
+ chunksFilter: normalizeChunksFilter(
663
+ fallbackCacheGroup.chunks || options.chunks || "all"
664
+ ),
661
665
  minSize: mergeSizes(
662
666
  normalizeSizes(fallbackCacheGroup.minSize, defaultSizeTypes),
663
667
  minSize
@@ -1598,6 +1602,7 @@ module.exports = class SplitChunksPlugin {
1598
1602
  const { outputOptions } = compilation;
1599
1603
 
1600
1604
  // Make sure that maxSize is fulfilled
1605
+ const { fallbackCacheGroup } = this.options;
1601
1606
  for (const chunk of Array.from(compilation.chunks)) {
1602
1607
  const chunkConfig = maxSizeQueueMap.get(chunk);
1603
1608
  const {
@@ -1605,7 +1610,9 @@ module.exports = class SplitChunksPlugin {
1605
1610
  maxAsyncSize,
1606
1611
  maxInitialSize,
1607
1612
  automaticNameDelimiter
1608
- } = chunkConfig || this.options.fallbackCacheGroup;
1613
+ } = chunkConfig || fallbackCacheGroup;
1614
+ if (!chunkConfig && !fallbackCacheGroup.chunksFilter(chunk))
1615
+ continue;
1609
1616
  /** @type {SplitChunksSizes} */
1610
1617
  let maxSize;
1611
1618
  if (chunk.isOnlyInitial()) {
@@ -59,7 +59,7 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
59
59
  ])});`,
60
60
  `var obj = {};
61
61
  obj[webpackThen] = ${runtimeTemplate.expressionFunction(
62
- "queueFunction(queue, fn), dep.catch(reject)",
62
+ "queueFunction(queue, fn), dep['catch'](reject)",
63
63
  "fn, reject"
64
64
  )};`,
65
65
  "return obj;"
@@ -114,7 +114,7 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
114
114
  "if (isEvaluating) { return completeFunction(fn); }",
115
115
  "if (currentDeps) whenAll(currentDeps, fn, rejectFn);",
116
116
  "queueFunction(queue, fn);",
117
- "promise.catch(rejectFn);"
117
+ "promise['catch'](rejectFn);"
118
118
  ]
119
119
  )};`,
120
120
  "module.exports = promise;",
@@ -320,7 +320,7 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
320
320
  "var promise = moduleToHandlerMapping[id]();",
321
321
  "if(promise.then) {",
322
322
  Template.indent(
323
- `promises.push(installedModules[id] = promise.then(onFactory).catch(onError));`
323
+ "promises.push(installedModules[id] = promise.then(onFactory)['catch'](onError));"
324
324
  ),
325
325
  "} else onFactory(promise);"
326
326
  ]),
@@ -105,7 +105,7 @@ class ShareRuntimeModule extends RuntimeModule {
105
105
  )}`,
106
106
  "if(module.then) return promises.push(module.then(initFn, handleError));",
107
107
  "var initResult = initFn(module);",
108
- "if(initResult && initResult.then) return promises.push(initResult.catch(handleError));"
108
+ "if(initResult && initResult.then) return promises.push(initResult['catch'](handleError));"
109
109
  ]),
110
110
  "} catch(err) { handleError(err); }"
111
111
  ])}`,
@@ -1160,7 +1160,7 @@ const AVAILABLE_FORMATS = {
1160
1160
  },
1161
1161
  { regExp: /(\(module has no exports\))/g, format: red },
1162
1162
  { regExp: /\(possible exports: (.+)\)/g, format: green },
1163
- { regExp: /\s*(.+ doesn't exist)/g, format: red },
1163
+ { regExp: /\s*([^\s].* doesn't exist)/g, format: red },
1164
1164
  { regExp: /('\w+' option has not been set)/g, format: red },
1165
1165
  {
1166
1166
  regExp: /(Emitted value instead of an instance of Error)/g,
@@ -126,6 +126,7 @@ class DebugHash extends Hash {
126
126
 
127
127
  let crypto = undefined;
128
128
  let createXXHash64 = undefined;
129
+ let createMd4 = undefined;
129
130
  let BatchedHash = undefined;
130
131
 
131
132
  /**
@@ -149,6 +150,17 @@ module.exports = algorithm => {
149
150
  }
150
151
  }
151
152
  return new BatchedHash(createXXHash64());
153
+ case "md4":
154
+ if (createMd4 === undefined) {
155
+ createMd4 = require("./hash/md4");
156
+ if (BatchedHash === undefined) {
157
+ BatchedHash = require("./hash/BatchedHash");
158
+ }
159
+ }
160
+ return new BatchedHash(createMd4());
161
+ case "native-md4":
162
+ if (crypto === undefined) crypto = require("crypto");
163
+ return new BulkUpdateDecorator(() => crypto.createHash("md4"), "md4");
152
164
  default:
153
165
  if (crypto === undefined) crypto = require("crypto");
154
166
  return new BulkUpdateDecorator(
@@ -165,8 +165,16 @@ exports.arrayToSetDeprecation = (set, name) => {
165
165
  };
166
166
 
167
167
  exports.createArrayToSetDeprecationSet = name => {
168
- class SetDeprecatedArray extends Set {}
169
- exports.arrayToSetDeprecation(SetDeprecatedArray.prototype, name);
168
+ let initialized = false;
169
+ class SetDeprecatedArray extends Set {
170
+ constructor(items) {
171
+ super(items);
172
+ if (!initialized) {
173
+ initialized = true;
174
+ exports.arrayToSetDeprecation(SetDeprecatedArray.prototype, name);
175
+ }
176
+ }
177
+ }
170
178
  return SetDeprecatedArray;
171
179
  };
172
180
 
@@ -6,8 +6,7 @@
6
6
  "use strict";
7
7
 
8
8
  const Hash = require("../Hash");
9
-
10
- const MAX_STRING_LENGTH = 21845;
9
+ const MAX_SHORT_STRING = require("./wasm-hash").MAX_SHORT_STRING;
11
10
 
12
11
  class BatchedHash extends Hash {
13
12
  constructor(hash) {
@@ -28,7 +27,7 @@ class BatchedHash extends Hash {
28
27
  if (
29
28
  typeof data === "string" &&
30
29
  inputEncoding === this.encoding &&
31
- this.string.length + data.length < MAX_STRING_LENGTH
30
+ this.string.length + data.length < MAX_SHORT_STRING
32
31
  ) {
33
32
  this.string += data;
34
33
  return this;
@@ -37,7 +36,11 @@ class BatchedHash extends Hash {
37
36
  this.string = undefined;
38
37
  }
39
38
  if (typeof data === "string") {
40
- if (data.length < MAX_STRING_LENGTH) {
39
+ if (
40
+ data.length < MAX_SHORT_STRING &&
41
+ // base64 encoding is not valid since it may contain padding chars
42
+ (!inputEncoding || !inputEncoding.startsWith("ba"))
43
+ ) {
41
44
  this.string = data;
42
45
  this.encoding = inputEncoding;
43
46
  } else {
@@ -0,0 +1,20 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const create = require("./wasm-hash");
9
+
10
+ //#region wasm code: md4 (../../../assembly/hash/md4.asm.ts) --initialMemory 1
11
+ const md4 = new WebAssembly.Module(
12
+ Buffer.from(
13
+ // 2150 bytes
14
+ "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",
15
+ "base64"
16
+ )
17
+ );
18
+ //#endregion
19
+
20
+ module.exports = create.bind(null, md4, [], 64, 32);