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

Potentially problematic release.


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

Files changed (236) hide show
  1. package/README.md +22 -24
  2. package/bin/webpack.js +0 -0
  3. package/hot/dev-server.js +17 -4
  4. package/hot/lazy-compilation-node.js +3 -1
  5. package/hot/poll.js +1 -1
  6. package/hot/signal.js +1 -1
  7. package/lib/APIPlugin.js +33 -0
  8. package/lib/BannerPlugin.js +13 -5
  9. package/lib/Cache.js +1 -1
  10. package/lib/CacheFacade.js +4 -11
  11. package/lib/Chunk.js +6 -3
  12. package/lib/ChunkGraph.js +94 -8
  13. package/lib/ChunkGroup.js +1 -1
  14. package/lib/CleanPlugin.js +81 -20
  15. package/lib/Compilation.js +188 -93
  16. package/lib/Compiler.js +87 -18
  17. package/lib/ConstPlugin.js +2 -2
  18. package/lib/ContextModule.js +142 -51
  19. package/lib/ContextModuleFactory.js +65 -25
  20. package/lib/DelegatedModule.js +1 -1
  21. package/lib/DelegatedModuleFactoryPlugin.js +1 -1
  22. package/lib/Dependency.js +17 -0
  23. package/lib/DependencyTemplate.js +9 -0
  24. package/lib/DependencyTemplates.js +1 -1
  25. package/lib/DllModule.js +1 -1
  26. package/lib/DllReferencePlugin.js +1 -1
  27. package/lib/EntryOptionPlugin.js +2 -0
  28. package/lib/ErrorHelpers.js +2 -2
  29. package/lib/EvalDevToolModulePlugin.js +16 -1
  30. package/lib/EvalSourceMapDevToolPlugin.js +25 -4
  31. package/lib/ExportsInfo.js +5 -5
  32. package/lib/ExternalModule.js +94 -54
  33. package/lib/ExternalModuleFactoryPlugin.js +5 -5
  34. package/lib/FileSystemInfo.js +124 -58
  35. package/lib/Generator.js +3 -0
  36. package/lib/HookWebpackError.js +1 -1
  37. package/lib/HotModuleReplacementPlugin.js +3 -1
  38. package/lib/LoaderOptionsPlugin.js +1 -1
  39. package/lib/Module.js +28 -4
  40. package/lib/ModuleFilenameHelpers.js +8 -4
  41. package/lib/ModuleHashingError.js +29 -0
  42. package/lib/MultiCompiler.js +1 -1
  43. package/lib/MultiWatching.js +1 -1
  44. package/lib/NodeStuffPlugin.js +13 -3
  45. package/lib/NormalModule.js +51 -33
  46. package/lib/NormalModuleFactory.js +42 -37
  47. package/lib/ProgressPlugin.js +4 -5
  48. package/lib/RawModule.js +1 -1
  49. package/lib/RuntimeGlobals.js +29 -1
  50. package/lib/RuntimeModule.js +1 -1
  51. package/lib/RuntimePlugin.js +84 -1
  52. package/lib/RuntimeTemplate.js +114 -2
  53. package/lib/Template.js +3 -2
  54. package/lib/TemplatedPathPlugin.js +48 -23
  55. package/lib/WatchIgnorePlugin.js +19 -7
  56. package/lib/Watching.js +33 -19
  57. package/lib/WebpackOptionsApply.js +79 -11
  58. package/lib/asset/AssetGenerator.js +228 -71
  59. package/lib/asset/AssetModulesPlugin.js +3 -0
  60. package/lib/asset/AssetParser.js +1 -0
  61. package/lib/asset/AssetSourceGenerator.js +31 -6
  62. package/lib/asset/AssetSourceParser.js +1 -0
  63. package/lib/asset/RawDataUrlModule.js +148 -0
  64. package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -4
  65. package/lib/buildChunkGraph.js +38 -7
  66. package/lib/cache/PackFileCacheStrategy.js +15 -8
  67. package/lib/cache/ResolverCachePlugin.js +90 -29
  68. package/lib/cli.js +44 -3
  69. package/lib/config/browserslistTargetHandler.js +41 -6
  70. package/lib/config/defaults.js +123 -19
  71. package/lib/config/normalization.js +10 -2
  72. package/lib/config/target.js +10 -0
  73. package/lib/container/ContainerEntryModule.js +8 -5
  74. package/lib/container/FallbackModule.js +4 -4
  75. package/lib/container/ModuleFederationPlugin.js +2 -0
  76. package/lib/container/RemoteModule.js +4 -2
  77. package/lib/container/RemoteRuntimeModule.js +8 -7
  78. package/lib/css/CssExportsGenerator.js +139 -0
  79. package/lib/css/CssGenerator.js +109 -0
  80. package/lib/css/CssLoadingRuntimeModule.js +442 -0
  81. package/lib/css/CssModulesPlugin.js +462 -0
  82. package/lib/css/CssParser.js +618 -0
  83. package/lib/css/walkCssTokens.js +659 -0
  84. package/lib/debug/ProfilingPlugin.js +24 -21
  85. package/lib/dependencies/AMDRequireDependency.js +6 -6
  86. package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -2
  87. package/lib/dependencies/CommonJsFullRequireDependency.js +5 -1
  88. package/lib/dependencies/CommonJsImportsParserPlugin.js +344 -61
  89. package/lib/dependencies/CommonJsRequireContextDependency.js +6 -2
  90. package/lib/dependencies/CommonJsRequireDependency.js +2 -1
  91. package/lib/dependencies/ContextDependency.js +16 -2
  92. package/lib/dependencies/ContextDependencyHelpers.js +21 -8
  93. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +4 -1
  94. package/lib/dependencies/ContextElementDependency.js +25 -3
  95. package/lib/dependencies/CreateScriptUrlDependency.js +12 -0
  96. package/lib/dependencies/CssExportDependency.js +85 -0
  97. package/lib/dependencies/CssImportDependency.js +75 -0
  98. package/lib/dependencies/CssLocalIdentifierDependency.js +119 -0
  99. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +101 -0
  100. package/lib/dependencies/CssUrlDependency.js +132 -0
  101. package/lib/dependencies/ExportsInfoDependency.js +6 -0
  102. package/lib/dependencies/HarmonyAcceptImportDependency.js +5 -3
  103. package/lib/dependencies/HarmonyCompatibilityDependency.js +5 -5
  104. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +127 -0
  105. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +12 -3
  106. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +25 -17
  107. package/lib/dependencies/HarmonyExportInitFragment.js +4 -1
  108. package/lib/dependencies/HarmonyImportDependency.js +23 -0
  109. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +142 -45
  110. package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -22
  111. package/lib/dependencies/HarmonyModulesPlugin.js +10 -0
  112. package/lib/dependencies/ImportContextDependency.js +0 -2
  113. package/lib/dependencies/ImportMetaContextDependency.js +35 -0
  114. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +252 -0
  115. package/lib/dependencies/ImportMetaContextPlugin.js +59 -0
  116. package/lib/dependencies/ImportMetaPlugin.js +22 -3
  117. package/lib/dependencies/ImportParserPlugin.js +35 -29
  118. package/lib/dependencies/JsonExportsDependency.js +17 -21
  119. package/lib/dependencies/LoaderDependency.js +13 -0
  120. package/lib/dependencies/LoaderImportDependency.js +13 -0
  121. package/lib/dependencies/LoaderPlugin.js +4 -2
  122. package/lib/dependencies/ModuleDependency.js +11 -1
  123. package/lib/dependencies/ProvidedDependency.js +31 -8
  124. package/lib/dependencies/RequireContextDependency.js +0 -16
  125. package/lib/dependencies/RequireEnsureDependency.js +2 -2
  126. package/lib/dependencies/RequireResolveContextDependency.js +2 -2
  127. package/lib/dependencies/RequireResolveDependency.js +2 -1
  128. package/lib/dependencies/URLDependency.js +3 -8
  129. package/lib/dependencies/URLPlugin.js +22 -1
  130. package/lib/dependencies/WorkerPlugin.js +2 -0
  131. package/lib/esm/ModuleChunkFormatPlugin.js +74 -49
  132. package/lib/esm/ModuleChunkLoadingPlugin.js +3 -1
  133. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +25 -9
  134. package/lib/hmr/HotModuleReplacement.runtime.js +29 -14
  135. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +4 -3
  136. package/lib/hmr/LazyCompilationPlugin.js +54 -26
  137. package/lib/hmr/lazyCompilationBackend.js +51 -12
  138. package/lib/ids/DeterministicModuleIdsPlugin.js +55 -35
  139. package/lib/ids/HashedModuleIdsPlugin.js +11 -14
  140. package/lib/ids/IdHelpers.js +26 -12
  141. package/lib/ids/NamedModuleIdsPlugin.js +6 -9
  142. package/lib/ids/NaturalModuleIdsPlugin.js +10 -13
  143. package/lib/ids/OccurrenceModuleIdsPlugin.js +13 -10
  144. package/lib/ids/SyncModuleIdsPlugin.js +140 -0
  145. package/lib/index.js +20 -0
  146. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +2 -2
  147. package/lib/javascript/BasicEvaluatedExpression.js +5 -2
  148. package/lib/javascript/ChunkHelpers.js +33 -0
  149. package/lib/javascript/JavascriptGenerator.js +1 -0
  150. package/lib/javascript/JavascriptModulesPlugin.js +27 -2
  151. package/lib/javascript/JavascriptParser.js +143 -73
  152. package/lib/javascript/StartupHelpers.js +7 -30
  153. package/lib/json/JsonData.js +8 -0
  154. package/lib/json/JsonParser.js +4 -6
  155. package/lib/library/AssignLibraryPlugin.js +39 -15
  156. package/lib/library/EnableLibraryPlugin.js +11 -0
  157. package/lib/library/UmdLibraryPlugin.js +5 -3
  158. package/lib/node/NodeTargetPlugin.js +3 -0
  159. package/lib/node/NodeWatchFileSystem.js +85 -31
  160. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +23 -8
  161. package/lib/node/RequireChunkLoadingRuntimeModule.js +24 -9
  162. package/lib/optimize/ConcatenatedModule.js +62 -26
  163. package/lib/optimize/ModuleConcatenationPlugin.js +26 -4
  164. package/lib/optimize/RealContentHashPlugin.js +45 -15
  165. package/lib/optimize/SplitChunksPlugin.js +8 -1
  166. package/lib/runtime/AsyncModuleRuntimeModule.js +50 -66
  167. package/lib/runtime/BaseUriRuntimeModule.js +31 -0
  168. package/lib/runtime/CreateScriptRuntimeModule.js +36 -0
  169. package/lib/runtime/CreateScriptUrlRuntimeModule.js +9 -34
  170. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +76 -0
  171. package/lib/runtime/LoadScriptRuntimeModule.js +11 -9
  172. package/lib/runtime/NonceRuntimeModule.js +24 -0
  173. package/lib/schemes/HttpUriPlugin.js +77 -14
  174. package/lib/serialization/FileMiddleware.js +44 -9
  175. package/lib/sharing/ConsumeSharedModule.js +8 -2
  176. package/lib/sharing/ConsumeSharedRuntimeModule.js +26 -5
  177. package/lib/sharing/ProvideSharedModule.js +4 -2
  178. package/lib/sharing/ProvideSharedPlugin.js +1 -2
  179. package/lib/sharing/ShareRuntimeModule.js +1 -1
  180. package/lib/sharing/utils.js +1 -1
  181. package/lib/stats/DefaultStatsFactoryPlugin.js +113 -68
  182. package/lib/stats/DefaultStatsPrinterPlugin.js +90 -25
  183. package/lib/util/ArrayHelpers.js +30 -0
  184. package/lib/util/AsyncQueue.js +1 -1
  185. package/lib/util/compileBooleanMatcher.js +1 -1
  186. package/lib/util/create-schema-validation.js +9 -2
  187. package/lib/util/createHash.js +12 -0
  188. package/lib/util/deprecation.js +10 -2
  189. package/lib/util/deterministicGrouping.js +1 -1
  190. package/lib/util/extractUrlAndGlobal.js +3 -0
  191. package/lib/util/fs.js +11 -0
  192. package/lib/util/hash/BatchedHash.js +7 -4
  193. package/lib/util/hash/md4.js +20 -0
  194. package/lib/util/hash/wasm-hash.js +163 -0
  195. package/lib/util/hash/xxhash64.js +5 -139
  196. package/lib/util/identifier.js +65 -44
  197. package/lib/util/internalSerializables.js +15 -0
  198. package/lib/util/nonNumericOnlyHash.js +22 -0
  199. package/lib/util/semver.js +17 -10
  200. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +9 -3
  201. package/lib/wasm-sync/WebAssemblyParser.js +1 -1
  202. package/lib/web/JsonpChunkLoadingRuntimeModule.js +31 -18
  203. package/lib/webpack.js +10 -3
  204. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -11
  205. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +33 -22
  206. package/module.d.ts +215 -0
  207. package/package.json +28 -32
  208. package/schemas/WebpackOptions.check.js +1 -1
  209. package/schemas/WebpackOptions.json +321 -30
  210. package/schemas/plugins/BannerPlugin.check.js +1 -1
  211. package/schemas/plugins/BannerPlugin.json +4 -0
  212. package/schemas/plugins/DllReferencePlugin.check.js +1 -1
  213. package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
  214. package/schemas/plugins/ProgressPlugin.check.js +1 -1
  215. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  216. package/schemas/plugins/asset/AssetParserOptions.check.js +1 -1
  217. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  218. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  219. package/schemas/plugins/container/ContainerPlugin.json +2 -1
  220. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  221. package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
  222. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  223. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  224. package/schemas/plugins/container/ModuleFederationPlugin.json +3 -1
  225. package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +7 -0
  226. package/schemas/plugins/css/CssGeneratorOptions.check.js +6 -0
  227. package/schemas/plugins/css/CssGeneratorOptions.json +3 -0
  228. package/schemas/plugins/css/CssParserOptions.check.d.ts +7 -0
  229. package/schemas/plugins/css/CssParserOptions.check.js +6 -0
  230. package/schemas/plugins/css/CssParserOptions.json +3 -0
  231. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +1 -1
  232. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +1 -1
  233. package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +1 -1
  234. package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
  235. package/schemas/plugins/schemes/HttpUriPlugin.json +4 -0
  236. package/types.d.ts +869 -296
@@ -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
+ // 2156 bytes
14
+ "AGFzbQEAAAABCAJgAX8AYAAAAwUEAQAAAAUDAQABBhoFfwFBAAt/AUEAC38BQQALfwFBAAt/AUEACwciBARpbml0AAAGdXBkYXRlAAIFZmluYWwAAwZtZW1vcnkCAAqLEAQmAEGBxpS6BiQBQYnXtv5+JAJB/rnrxXkkA0H2qMmBASQEQQAkAAvSCgEZfyMBIQUjAiECIwMhAyMEIQQDQCAAIAFLBEAgASgCJCISIAEoAiAiEyABKAIcIgkgASgCGCIIIAEoAhQiByABKAIQIg4gASgCDCIGIAEoAggiDyABKAIEIhAgASgCACIRIAMgBHMgAnEgBHMgBWpqQQN3IgogAiADc3EgA3MgBGpqQQd3IgsgAiAKc3EgAnMgA2pqQQt3IgwgCiALc3EgCnMgAmpqQRN3Ig0gCyAMc3EgC3MgCmpqQQN3IgogDCANc3EgDHMgC2pqQQd3IgsgCiANc3EgDXMgDGpqQQt3IgwgCiALc3EgCnMgDWpqQRN3Ig0gCyAMc3EgC3MgCmpqQQN3IhQgDCANc3EgDHMgC2pqQQd3IRUgASgCLCILIAEoAigiCiAMIA0gDSAUcyAVcXNqakELdyIWI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eDQgiGIARC8IHAh4CegPgAg0IEiIQiBEKGjJiw4MCBgwZ8QgSIQoGChIiQoMCAAYNCJ34gBEKw4MCBg4aMmDCEfDcDAAs=",
15
+ "base64"
16
+ )
17
+ );
18
+ //#endregion
19
+
20
+ module.exports = create.bind(null, md4, [], 64, 32);
@@ -0,0 +1,163 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+
6
+ "use strict";
7
+
8
+ // 65536 is the size of a wasm memory page
9
+ // 64 is the maximum chunk size for every possible wasm hash implementation
10
+ // 4 is the maximum number of bytes per char for string encoding (max is utf-8)
11
+ // ~3 makes sure that it's always a block of 4 chars, so avoid partially encoded bytes for base64
12
+ const MAX_SHORT_STRING = Math.floor((65536 - 64) / 4) & ~3;
13
+
14
+ class WasmHash {
15
+ /**
16
+ * @param {WebAssembly.Instance} instance wasm instance
17
+ * @param {WebAssembly.Instance[]} instancesPool pool of instances
18
+ * @param {number} chunkSize size of data chunks passed to wasm
19
+ * @param {number} digestSize size of digest returned by wasm
20
+ */
21
+ constructor(instance, instancesPool, chunkSize, digestSize) {
22
+ const exports = /** @type {any} */ (instance.exports);
23
+ exports.init();
24
+ this.exports = exports;
25
+ this.mem = Buffer.from(exports.memory.buffer, 0, 65536);
26
+ this.buffered = 0;
27
+ this.instancesPool = instancesPool;
28
+ this.chunkSize = chunkSize;
29
+ this.digestSize = digestSize;
30
+ }
31
+
32
+ reset() {
33
+ this.buffered = 0;
34
+ this.exports.init();
35
+ }
36
+
37
+ /**
38
+ * @param {Buffer | string} data data
39
+ * @param {BufferEncoding=} encoding encoding
40
+ * @returns {this} itself
41
+ */
42
+ update(data, encoding) {
43
+ if (typeof data === "string") {
44
+ while (data.length > MAX_SHORT_STRING) {
45
+ this._updateWithShortString(data.slice(0, MAX_SHORT_STRING), encoding);
46
+ data = data.slice(MAX_SHORT_STRING);
47
+ }
48
+ this._updateWithShortString(data, encoding);
49
+ return this;
50
+ }
51
+ this._updateWithBuffer(data);
52
+ return this;
53
+ }
54
+
55
+ /**
56
+ * @param {string} data data
57
+ * @param {BufferEncoding=} encoding encoding
58
+ * @returns {void}
59
+ */
60
+ _updateWithShortString(data, encoding) {
61
+ const { exports, buffered, mem, chunkSize } = this;
62
+ let endPos;
63
+ if (data.length < 70) {
64
+ if (!encoding || encoding === "utf-8" || encoding === "utf8") {
65
+ endPos = buffered;
66
+ for (let i = 0; i < data.length; i++) {
67
+ const cc = data.charCodeAt(i);
68
+ if (cc < 0x80) mem[endPos++] = cc;
69
+ else if (cc < 0x800) {
70
+ mem[endPos] = (cc >> 6) | 0xc0;
71
+ mem[endPos + 1] = (cc & 0x3f) | 0x80;
72
+ endPos += 2;
73
+ } else {
74
+ // bail-out for weird chars
75
+ endPos += mem.write(data.slice(i), endPos, encoding);
76
+ break;
77
+ }
78
+ }
79
+ } else if (encoding === "latin1") {
80
+ endPos = buffered;
81
+ for (let i = 0; i < data.length; i++) {
82
+ const cc = data.charCodeAt(i);
83
+ mem[endPos++] = cc;
84
+ }
85
+ } else {
86
+ endPos = buffered + mem.write(data, buffered, encoding);
87
+ }
88
+ } else {
89
+ endPos = buffered + mem.write(data, buffered, encoding);
90
+ }
91
+ if (endPos < chunkSize) {
92
+ this.buffered = endPos;
93
+ } else {
94
+ const l = endPos & ~(this.chunkSize - 1);
95
+ exports.update(l);
96
+ const newBuffered = endPos - l;
97
+ this.buffered = newBuffered;
98
+ if (newBuffered > 0) mem.copyWithin(0, l, endPos);
99
+ }
100
+ }
101
+
102
+ /**
103
+ * @param {Buffer} data data
104
+ * @returns {void}
105
+ */
106
+ _updateWithBuffer(data) {
107
+ const { exports, buffered, mem } = this;
108
+ const length = data.length;
109
+ if (buffered + length < this.chunkSize) {
110
+ data.copy(mem, buffered, 0, length);
111
+ this.buffered += length;
112
+ } else {
113
+ const l = (buffered + length) & ~(this.chunkSize - 1);
114
+ if (l > 65536) {
115
+ let i = 65536 - buffered;
116
+ data.copy(mem, buffered, 0, i);
117
+ exports.update(65536);
118
+ const stop = l - buffered - 65536;
119
+ while (i < stop) {
120
+ data.copy(mem, 0, i, i + 65536);
121
+ exports.update(65536);
122
+ i += 65536;
123
+ }
124
+ data.copy(mem, 0, i, l - buffered);
125
+ exports.update(l - buffered - i);
126
+ } else {
127
+ data.copy(mem, buffered, 0, l - buffered);
128
+ exports.update(l);
129
+ }
130
+ const newBuffered = length + buffered - l;
131
+ this.buffered = newBuffered;
132
+ if (newBuffered > 0) data.copy(mem, 0, length - newBuffered, length);
133
+ }
134
+ }
135
+
136
+ digest(type) {
137
+ const { exports, buffered, mem, digestSize } = this;
138
+ exports.final(buffered);
139
+ this.instancesPool.push(this);
140
+ const hex = mem.toString("latin1", 0, digestSize);
141
+ if (type === "hex") return hex;
142
+ if (type === "binary" || !type) return Buffer.from(hex, "hex");
143
+ return Buffer.from(hex, "hex").toString(type);
144
+ }
145
+ }
146
+
147
+ const create = (wasmModule, instancesPool, chunkSize, digestSize) => {
148
+ if (instancesPool.length > 0) {
149
+ const old = instancesPool.pop();
150
+ old.reset();
151
+ return old;
152
+ } else {
153
+ return new WasmHash(
154
+ new WebAssembly.Instance(wasmModule),
155
+ instancesPool,
156
+ chunkSize,
157
+ digestSize
158
+ );
159
+ }
160
+ };
161
+
162
+ module.exports = create;
163
+ module.exports.MAX_SHORT_STRING = MAX_SHORT_STRING;
@@ -5,150 +5,16 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const create = require("./wasm-hash");
9
+
8
10
  //#region wasm code: xxhash64 (../../../assembly/hash/xxhash64.asm.ts) --initialMemory 1
9
11
  const xxhash64 = new WebAssembly.Module(
10
12
  Buffer.from(
11
- // 1180 bytes
12
- "AGFzbQEAAAABCAJgAX8AYAAAAwQDAQAABQMBAAEGGgV+AUIAC34BQgALfgFCAAt+AUIAC34BQgALByIEBGluaXQAAAZ1cGRhdGUAAQVmaW5hbAACBm1lbW9yeQIACrwIAzAAQtbrgu7q/Yn14AAkAELP1tO+0ser2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iUKHla+vmLbem55/foVCh5Wvr5i23puef35CnaO16oOxjYr6AH0FQsXP2bLx5brqJwsjBCAArXx8IQIDQCABQQhqIABNBEAgAiABKQMAQs/W077Sx6vZQn5CH4lCh5Wvr5i23puef36FQhuJQoeVr6+Ytt6bnn9+Qp2jteqDsY2K+gB9IQIgAUEIaiEBDAELCyABQQRqIABNBEAgAiABNQIAQoeVr6+Ytt6bnn9+hUIXiULP1tO+0ser2UJ+Qvnz3fGZ9pmrFnwhAiABQQRqIQELA0AgACABRwRAIAIgATEAAELFz9my8eW66id+hUILiUKHla+vmLbem55/fiECIAFBAWohAQwBCwtBACACIAJCIYiFQs/W077Sx6vZQn4iAkIdiCAChUL5893xmfaZqxZ+IgJCIIggAoUiAkIgiCIDQv//A4NCIIYgA0KAgPz/D4NCEIiEIgNC/4GAgPAfg0IQhiADQoD+g4CA4D+DQgiIhCIDQo+AvIDwgcAHg0IIhiADQvCBwIeAnoD4AINCBIiEIgNChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IANCsODAgYOGjJgwhHw3AwBBCCACQv////8PgyICQv//A4NCIIYgAkKAgPz/D4NCEIiEIgJC/4GAgPAfg0IQhiACQoD+g4CA4D+DQgiIhCICQo+AvIDwgcAHg0IIhiACQvCBwIeAnoD4AINCBIiEIgJChoyYsODAgYMGfEIEiEKBgoSIkKDAgAGDQid+IAJCsODAgYOGjJgwhHw3AwAL",
13
15
  "base64"
14
16
  )
15
17
  );
16
18
  //#endregion
17
19
 
18
- class XxHash64 {
19
- /**
20
- * @param {WebAssembly.Instance} instance wasm instance
21
- */
22
- constructor(instance) {
23
- const exports = /** @type {any} */ (instance.exports);
24
- exports.init();
25
- this.exports = exports;
26
- this.mem = Buffer.from(exports.memory.buffer, 0, 65536);
27
- this.buffered = 0;
28
- }
29
-
30
- reset() {
31
- this.buffered = 0;
32
- this.exports.init();
33
- }
34
-
35
- /**
36
- * @param {Buffer | string} data data
37
- * @param {BufferEncoding=} encoding encoding
38
- * @returns {this} itself
39
- */
40
- update(data, encoding) {
41
- if (typeof data === "string") {
42
- if (data.length < 21845) {
43
- this._updateWithShortString(data, encoding);
44
- return this;
45
- } else {
46
- data = Buffer.from(data, encoding);
47
- }
48
- }
49
- this._updateWithBuffer(data);
50
- return this;
51
- }
52
-
53
- /**
54
- * @param {string} data data
55
- * @param {BufferEncoding=} encoding encoding
56
- * @returns {void}
57
- */
58
- _updateWithShortString(data, encoding) {
59
- const { exports, buffered, mem } = this;
60
- let endPos;
61
- if (data.length < 70) {
62
- if (!encoding || encoding === "utf-8" || encoding === "utf8") {
63
- endPos = buffered;
64
- for (let i = 0; i < data.length; i++) {
65
- const cc = data.charCodeAt(i);
66
- if (cc < 0x80) mem[endPos++] = cc;
67
- else if (cc < 0x800) {
68
- mem[endPos] = (cc >> 6) | 0xc0;
69
- mem[endPos + 1] = (cc & 0x3f) | 0x80;
70
- endPos += 2;
71
- } else {
72
- // bail-out for weird chars
73
- endPos += mem.write(data.slice(endPos), endPos, encoding);
74
- break;
75
- }
76
- }
77
- } else if (encoding === "latin1") {
78
- endPos = buffered;
79
- for (let i = 0; i < data.length; i++) {
80
- const cc = data.charCodeAt(i);
81
- mem[endPos++] = cc;
82
- }
83
- } else {
84
- endPos = buffered + mem.write(data, buffered, encoding);
85
- }
86
- } else {
87
- endPos = buffered + mem.write(data, buffered, encoding);
88
- }
89
- if (endPos < 32) {
90
- this.buffered = endPos;
91
- } else {
92
- const l = (endPos >> 5) << 5;
93
- exports.update(l);
94
- const newBuffered = endPos - l;
95
- this.buffered = newBuffered;
96
- if (newBuffered > 0) mem.copyWithin(0, l, endPos);
97
- }
98
- }
99
-
100
- /**
101
- * @param {Buffer} data data
102
- * @returns {void}
103
- */
104
- _updateWithBuffer(data) {
105
- const { exports, buffered, mem } = this;
106
- const length = data.length;
107
- if (buffered + length < 32) {
108
- data.copy(mem, buffered, 0, length);
109
- this.buffered += length;
110
- } else {
111
- const l = ((buffered + length) >> 5) << 5;
112
- if (l > 65536) {
113
- let i = 65536 - buffered;
114
- data.copy(mem, buffered, 0, i);
115
- exports.update(65536);
116
- const stop = l - buffered - 65536;
117
- while (i < stop) {
118
- data.copy(mem, 0, i, i + 65536);
119
- exports.update(65536);
120
- i += 65536;
121
- }
122
- data.copy(mem, 0, i, l - buffered);
123
- exports.update(l - buffered - i);
124
- } else {
125
- data.copy(mem, buffered, 0, l - buffered);
126
- exports.update(l);
127
- }
128
- const newBuffered = length + buffered - l;
129
- this.buffered = newBuffered;
130
- if (newBuffered > 0) data.copy(mem, 0, length - newBuffered, length);
131
- }
132
- }
133
-
134
- digest(type) {
135
- const { exports, buffered, mem } = this;
136
- exports.final(buffered);
137
- instancesPool.push(this);
138
- return mem.toString("latin1", 0, 16);
139
- }
140
- }
141
-
142
- const instancesPool = [];
143
-
144
- const create = () => {
145
- if (instancesPool.length > 0) {
146
- const old = instancesPool.pop();
147
- old.reset();
148
- return old;
149
- } else {
150
- return new XxHash64(new WebAssembly.Instance(xxhash64));
151
- }
152
- };
153
-
154
- module.exports = create;
20
+ module.exports = create.bind(null, xxhash64, [], 32, 16);
@@ -81,7 +81,49 @@ const requestToAbsolute = (context, relativePath) => {
81
81
  return relativePath;
82
82
  };
83
83
 
84
- const makeCacheable = fn => {
84
+ const makeCacheable = realFn => {
85
+ /** @type {WeakMap<object, Map<string, ParsedResource>>} */
86
+ const cache = new WeakMap();
87
+
88
+ const getCache = associatedObjectForCache => {
89
+ const entry = cache.get(associatedObjectForCache);
90
+ if (entry !== undefined) return entry;
91
+ /** @type {Map<string, ParsedResource>} */
92
+ const map = new Map();
93
+ cache.set(associatedObjectForCache, map);
94
+ return map;
95
+ };
96
+
97
+ /**
98
+ * @param {string} str the path with query and fragment
99
+ * @param {Object=} associatedObjectForCache an object to which the cache will be attached
100
+ * @returns {ParsedResource} parsed parts
101
+ */
102
+ const fn = (str, associatedObjectForCache) => {
103
+ if (!associatedObjectForCache) return realFn(str);
104
+ const cache = getCache(associatedObjectForCache);
105
+ const entry = cache.get(str);
106
+ if (entry !== undefined) return entry;
107
+ const result = realFn(str);
108
+ cache.set(str, result);
109
+ return result;
110
+ };
111
+
112
+ fn.bindCache = associatedObjectForCache => {
113
+ const cache = getCache(associatedObjectForCache);
114
+ return str => {
115
+ const entry = cache.get(str);
116
+ if (entry !== undefined) return entry;
117
+ const result = realFn(str);
118
+ cache.set(str, result);
119
+ return result;
120
+ };
121
+ };
122
+
123
+ return fn;
124
+ };
125
+
126
+ const makeCacheableWithContext = fn => {
85
127
  /** @type {WeakMap<object, Map<string, Map<string, string>>>} */
86
128
  const cache = new WeakMap();
87
129
 
@@ -215,7 +257,7 @@ const _makePathsRelative = (context, identifier) => {
215
257
  .join("");
216
258
  };
217
259
 
218
- exports.makePathsRelative = makeCacheable(_makePathsRelative);
260
+ exports.makePathsRelative = makeCacheableWithContext(_makePathsRelative);
219
261
 
220
262
  /**
221
263
  *
@@ -230,7 +272,7 @@ const _makePathsAbsolute = (context, identifier) => {
230
272
  .join("");
231
273
  };
232
274
 
233
- exports.makePathsAbsolute = makeCacheable(_makePathsAbsolute);
275
+ exports.makePathsAbsolute = makeCacheableWithContext(_makePathsAbsolute);
234
276
 
235
277
  /**
236
278
  * @param {string} context absolute context path
@@ -244,7 +286,7 @@ const _contextify = (context, request) => {
244
286
  .join("!");
245
287
  };
246
288
 
247
- const contextify = makeCacheable(_contextify);
289
+ const contextify = makeCacheableWithContext(_contextify);
248
290
  exports.contextify = contextify;
249
291
 
250
292
  /**
@@ -259,13 +301,15 @@ const _absolutify = (context, request) => {
259
301
  .join("!");
260
302
  };
261
303
 
262
- const absolutify = makeCacheable(_absolutify);
304
+ const absolutify = makeCacheableWithContext(_absolutify);
263
305
  exports.absolutify = absolutify;
264
306
 
265
307
  const PATH_QUERY_FRAGMENT_REGEXP =
266
308
  /^((?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)?$/;
309
+ const PATH_QUERY_REGEXP = /^((?:\0.|[^?\0])*)(\?.*)?$/;
267
310
 
268
311
  /** @typedef {{ resource: string, path: string, query: string, fragment: string }} ParsedResource */
312
+ /** @typedef {{ resource: string, path: string, query: string }} ParsedResourceWithoutFragment */
269
313
 
270
314
  /**
271
315
  * @param {string} str the path with query and fragment
@@ -280,47 +324,24 @@ const _parseResource = str => {
280
324
  fragment: match[3] || ""
281
325
  };
282
326
  };
283
- exports.parseResource = (realFn => {
284
- /** @type {WeakMap<object, Map<string, ParsedResource>>} */
285
- const cache = new WeakMap();
327
+ exports.parseResource = makeCacheable(_parseResource);
286
328
 
287
- const getCache = associatedObjectForCache => {
288
- const entry = cache.get(associatedObjectForCache);
289
- if (entry !== undefined) return entry;
290
- /** @type {Map<string, ParsedResource>} */
291
- const map = new Map();
292
- cache.set(associatedObjectForCache, map);
293
- return map;
294
- };
295
-
296
- /**
297
- * @param {string} str the path with query and fragment
298
- * @param {Object=} associatedObjectForCache an object to which the cache will be attached
299
- * @returns {ParsedResource} parsed parts
300
- */
301
- const fn = (str, associatedObjectForCache) => {
302
- if (!associatedObjectForCache) return realFn(str);
303
- const cache = getCache(associatedObjectForCache);
304
- const entry = cache.get(str);
305
- if (entry !== undefined) return entry;
306
- const result = realFn(str);
307
- cache.set(str, result);
308
- return result;
309
- };
310
-
311
- fn.bindCache = associatedObjectForCache => {
312
- const cache = getCache(associatedObjectForCache);
313
- return str => {
314
- const entry = cache.get(str);
315
- if (entry !== undefined) return entry;
316
- const result = realFn(str);
317
- cache.set(str, result);
318
- return result;
319
- };
329
+ /**
330
+ * Parse resource, skips fragment part
331
+ * @param {string} str the path with query and fragment
332
+ * @returns {ParsedResourceWithoutFragment} parsed parts
333
+ */
334
+ const _parseResourceWithoutFragment = str => {
335
+ const match = PATH_QUERY_REGEXP.exec(str);
336
+ return {
337
+ resource: str,
338
+ path: match[1].replace(/\0(.)/g, "$1"),
339
+ query: match[2] ? match[2].replace(/\0(.)/g, "$1") : ""
320
340
  };
321
-
322
- return fn;
323
- })(_parseResource);
341
+ };
342
+ exports.parseResourceWithoutFragment = makeCacheable(
343
+ _parseResourceWithoutFragment
344
+ );
324
345
 
325
346
  /**
326
347
  * @param {string} filename the filename which should be undone
@@ -67,6 +67,16 @@ module.exports = {
67
67
  require("../dependencies/ContextElementDependency"),
68
68
  "dependencies/CriticalDependencyWarning": () =>
69
69
  require("../dependencies/CriticalDependencyWarning"),
70
+ "dependencies/CssImportDependency": () =>
71
+ require("../dependencies/CssImportDependency"),
72
+ "dependencies/CssLocalIdentifierDependency": () =>
73
+ require("../dependencies/CssLocalIdentifierDependency"),
74
+ "dependencies/CssSelfLocalIdentifierDependency": () =>
75
+ require("../dependencies/CssSelfLocalIdentifierDependency"),
76
+ "dependencies/CssExportDependency": () =>
77
+ require("../dependencies/CssExportDependency"),
78
+ "dependencies/CssUrlDependency": () =>
79
+ require("../dependencies/CssUrlDependency"),
70
80
  "dependencies/DelegatedSourceDependency": () =>
71
81
  require("../dependencies/DelegatedSourceDependency"),
72
82
  "dependencies/DllEntryDependency": () =>
@@ -93,6 +103,8 @@ module.exports = {
93
103
  require("../dependencies/HarmonyImportSideEffectDependency"),
94
104
  "dependencies/HarmonyImportSpecifierDependency": () =>
95
105
  require("../dependencies/HarmonyImportSpecifierDependency"),
106
+ "dependencies/HarmonyEvaluatedImportSpecifierDependency": () =>
107
+ require("../dependencies/HarmonyEvaluatedImportSpecifierDependency"),
96
108
  "dependencies/ImportContextDependency": () =>
97
109
  require("../dependencies/ImportContextDependency"),
98
110
  "dependencies/ImportDependency": () =>
@@ -116,6 +128,8 @@ module.exports = {
116
128
  require("../dependencies/ImportMetaHotAcceptDependency"),
117
129
  "dependencies/ImportMetaHotDeclineDependency": () =>
118
130
  require("../dependencies/ImportMetaHotDeclineDependency"),
131
+ "dependencies/ImportMetaContextDependency": () =>
132
+ require("../dependencies/ImportMetaContextDependency"),
119
133
  "dependencies/ProvidedDependency": () =>
120
134
  require("../dependencies/ProvidedDependency"),
121
135
  "dependencies/PureExpressionDependency": () =>
@@ -175,6 +189,7 @@ module.exports = {
175
189
  ModuleParseError: () => require("../ModuleParseError"),
176
190
  ModuleWarning: () => require("../ModuleWarning"),
177
191
  NormalModule: () => require("../NormalModule"),
192
+ RawDataUrlModule: () => require("../asset/RawDataUrlModule"),
178
193
  RawModule: () => require("../RawModule"),
179
194
  "sharing/ConsumeSharedModule": () =>
180
195
  require("../sharing/ConsumeSharedModule"),
@@ -0,0 +1,22 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Ivan Kopeykin @vankop
4
+ */
5
+
6
+ "use strict";
7
+
8
+ const A_CODE = "a".charCodeAt(0);
9
+
10
+ /**
11
+ * @param {string} hash hash
12
+ * @param {number} hashLength hash length
13
+ * @returns {string} returns hash that has at least one non numeric char
14
+ */
15
+ module.exports = (hash, hashLength) => {
16
+ if (hashLength < 1) return "";
17
+ const slice = hash.slice(0, hashLength);
18
+ if (slice.match(/[^\d]/)) return slice;
19
+ return `${String.fromCharCode(
20
+ A_CODE + (parseInt(hash[0], 10) % 6)
21
+ )}${slice.slice(1)}`;
22
+ };
@@ -89,7 +89,9 @@ exports.versionLt = versionLt;
89
89
  */
90
90
  exports.parseRange = str => {
91
91
  const splitAndConvert = str => {
92
- return str.split(".").map(item => (`${+item}` === item ? +item : item));
92
+ return str
93
+ .split(".")
94
+ .map(item => (item !== "NaN" && `${+item}` === item ? +item : item));
93
95
  };
94
96
  // see https://docs.npmjs.com/misc/semver#range-grammar for grammar
95
97
  const parsePartial = str => {
@@ -131,13 +133,15 @@ exports.parseRange = str => {
131
133
  return [-range[0] - 1, ...range.slice(1)];
132
134
  };
133
135
  const parseSimple = str => {
134
- // simple ::= primitive | partial | tilde | caret
135
- // primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
136
- // tilde ::= '~' partial
137
- // caret ::= '^' partial
136
+ // simple ::= primitive | partial | tilde | caret
137
+ // primitive ::= ( '<' | '>' | '>=' | '<=' | '=' | '!' ) ( ' ' ) * partial
138
+ // tilde ::= '~' ( ' ' ) * partial
139
+ // caret ::= '^' ( ' ' ) * partial
138
140
  const match = /^(\^|~|<=|<|>=|>|=|v|!)/.exec(str);
139
141
  const start = match ? match[0] : "";
140
- const remainder = parsePartial(str.slice(start.length));
142
+ const remainder = parsePartial(
143
+ start.length ? str.slice(start.length).trim() : str.trim()
144
+ );
141
145
  switch (start) {
142
146
  case "^":
143
147
  if (remainder.length > 1 && remainder[1] === 0) {
@@ -191,11 +195,14 @@ exports.parseRange = str => {
191
195
  return [, ...arr, ...items.slice(1).map(() => fn)];
192
196
  };
193
197
  const parseRange = str => {
194
- // range ::= hyphen | simple ( ' ' simple ) * | ''
195
- // hyphen ::= partial ' - ' partial
196
- const items = str.split(" - ");
198
+ // range ::= hyphen | simple ( ' ' ( ' ' ) * simple ) * | ''
199
+ // hyphen ::= partial ( ' ' ) * ' - ' ( ' ' ) * partial
200
+ const items = str.split(/\s+-\s+/);
197
201
  if (items.length === 1) {
198
- const items = str.trim().split(/\s+/g).map(parseSimple);
202
+ const items = str
203
+ .trim()
204
+ .split(/(?<=[-0-9A-Za-z])\s+/g)
205
+ .map(parseSimple);
199
206
  return combine(items, 2);
200
207
  }
201
208
  const a = parsePartial(items[0]);
@@ -167,14 +167,20 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
167
167
  )}`,
168
168
  `${RuntimeGlobals.asyncModule}(${
169
169
  module.moduleArgument
170
- }, ${runtimeTemplate.basicFunction(
171
- "__webpack_handle_async_dependencies__",
170
+ }, async ${runtimeTemplate.basicFunction(
171
+ "__webpack_handle_async_dependencies__, __webpack_async_result__",
172
172
  [
173
+ "try {",
173
174
  importsCode,
174
175
  `var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([${promises.join(
175
176
  ", "
176
177
  )}]);`,
177
- "return __webpack_async_dependencies__.then ? __webpack_async_dependencies__.then(__webpack_instantiate__) : __webpack_instantiate__(__webpack_async_dependencies__);"
178
+ `var [${promises.join(
179
+ ", "
180
+ )}] = __webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__;`,
181
+ `${importsCompatCode}await ${instantiateCall};`,
182
+ "__webpack_async_result__();",
183
+ "} catch(e) { __webpack_async_result__(e); }"
178
184
  ]
179
185
  )}, 1);`
180
186
  ])