webpack 5.42.1 → 5.45.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.

Files changed (43) hide show
  1. package/lib/Compilation.js +5 -2
  2. package/lib/Compiler.js +4 -4
  3. package/lib/ExternalModule.js +18 -0
  4. package/lib/ExternalModuleFactoryPlugin.js +1 -1
  5. package/lib/FileSystemInfo.js +14 -15
  6. package/lib/FlagDependencyUsagePlugin.js +5 -1
  7. package/lib/MultiCompiler.js +10 -8
  8. package/lib/SourceMapDevToolPlugin.js +1 -1
  9. package/lib/Template.js +1 -0
  10. package/lib/Watching.js +12 -0
  11. package/lib/asset/AssetGenerator.js +28 -15
  12. package/lib/container/ContainerPlugin.js +4 -1
  13. package/lib/container/ModuleFederationPlugin.js +1 -0
  14. package/lib/dependencies/WorkerPlugin.js +1 -1
  15. package/lib/esm/ExportWebpackRequireRuntimeModule.js +29 -0
  16. package/lib/esm/ModuleChunkFormatPlugin.js +91 -11
  17. package/lib/esm/ModuleChunkLoadingPlugin.js +13 -0
  18. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +46 -37
  19. package/lib/hmr/lazyCompilationBackend.js +5 -2
  20. package/lib/javascript/JavascriptModulesPlugin.js +3 -1
  21. package/lib/json/JsonData.js +41 -0
  22. package/lib/json/JsonGenerator.js +8 -2
  23. package/lib/json/JsonParser.js +2 -1
  24. package/lib/library/SystemLibraryPlugin.js +1 -1
  25. package/lib/optimize/ConcatenatedModule.js +16 -0
  26. package/lib/optimize/RuntimeChunkPlugin.js +1 -1
  27. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +5 -4
  28. package/lib/rules/RuleSetCompiler.js +2 -2
  29. package/lib/runtime/OnChunksLoadedRuntimeModule.js +5 -1
  30. package/lib/schemes/DataUriPlugin.js +7 -6
  31. package/lib/util/StackedCacheMap.js +110 -0
  32. package/lib/util/internalSerializables.js +1 -0
  33. package/lib/util/makeSerializable.js +0 -1
  34. package/lib/webpack.js +1 -1
  35. package/package.json +24 -18
  36. package/schemas/WebpackOptions.check.js +1 -1
  37. package/schemas/WebpackOptions.json +9 -2
  38. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  39. package/schemas/plugins/container/ContainerPlugin.json +15 -0
  40. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  41. package/schemas/plugins/container/ModuleFederationPlugin.json +15 -0
  42. package/types.d.ts +22 -9
  43. package/lib/util/StackedSetMap.js +0 -166
@@ -67,6 +67,9 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
67
67
  } = compilation;
68
68
  const fn = RuntimeGlobals.ensureChunkHandlers;
69
69
  const withBaseURI = this._runtimeRequirements.has(RuntimeGlobals.baseURI);
70
+ const withExternalInstallChunk = this._runtimeRequirements.has(
71
+ RuntimeGlobals.externalInstallChunk
72
+ );
70
73
  const withLoading = this._runtimeRequirements.has(
71
74
  RuntimeGlobals.ensureChunkHandlers
72
75
  );
@@ -110,6 +113,38 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
110
113
  ),
111
114
  "};",
112
115
  "",
116
+ withLoading || withExternalInstallChunk
117
+ ? `var installChunk = ${runtimeTemplate.basicFunction("data", [
118
+ runtimeTemplate.destructureObject(
119
+ ["ids", "modules", "runtime"],
120
+ "data"
121
+ ),
122
+ '// add "modules" to the modules object,',
123
+ '// then flag all "ids" as loaded and fire callback',
124
+ "var moduleId, chunkId, i = 0;",
125
+ "for(moduleId in modules) {",
126
+ Template.indent([
127
+ `if(${RuntimeGlobals.hasOwnProperty}(modules, moduleId)) {`,
128
+ Template.indent(
129
+ `${RuntimeGlobals.moduleFactories}[moduleId] = modules[moduleId];`
130
+ ),
131
+ "}"
132
+ ]),
133
+ "}",
134
+ "if(runtime) runtime(__webpack_require__);",
135
+ "for(;i < ids.length; i++) {",
136
+ Template.indent([
137
+ "chunkId = ids[i];",
138
+ `if(${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId) && installedChunks[chunkId]) {`,
139
+ Template.indent("installedChunks[chunkId][0]();"),
140
+ "}",
141
+ "installedChunks[ids[i]] = 0;"
142
+ ]),
143
+ "}",
144
+ withOnChunkLoad ? `${RuntimeGlobals.onChunksLoaded}();` : ""
145
+ ])}`
146
+ : "// no install chunk",
147
+ "",
113
148
  withLoading
114
149
  ? Template.asString([
115
150
  `${fn}.j = ${runtimeTemplate.basicFunction(
@@ -137,45 +172,13 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
137
172
  rootOutputDir
138
173
  )} + ${
139
174
  RuntimeGlobals.getChunkScriptFilename
140
- }(chunkId)).then(${runtimeTemplate.basicFunction(
141
- "data",
175
+ }(chunkId)).then(installChunk, ${runtimeTemplate.basicFunction(
176
+ "e",
142
177
  [
143
- runtimeTemplate.destructureObject(
144
- ["ids", "modules", "runtime"],
145
- "data"
146
- ),
147
- '// add "modules" to the modules object,',
148
- '// then flag all "ids" as loaded and fire callback',
149
- "var moduleId, chunkId, i = 0;",
150
- "for(moduleId in modules) {",
151
- Template.indent([
152
- `if(${RuntimeGlobals.hasOwnProperty}(modules, moduleId)) {`,
153
- Template.indent(
154
- `${RuntimeGlobals.moduleFactories}[moduleId] = modules[moduleId];`
155
- ),
156
- "}"
157
- ]),
158
- "}",
159
- "if(runtime) runtime(__webpack_require__);",
160
- "for(;i < ids.length; i++) {",
161
- Template.indent([
162
- "chunkId = ids[i];",
163
- `if(${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId) && installedChunks[chunkId]) {`,
164
- Template.indent(
165
- "installedChunks[chunkId][0]();"
166
- ),
167
- "}",
168
- "installedChunks[ids[i]] = 0;"
169
- ]),
170
- "}",
171
- withOnChunkLoad
172
- ? `${RuntimeGlobals.onChunksLoaded}();`
173
- : ""
178
+ "if(installedChunks[chunkId] !== 0) installedChunks[chunkId] = undefined;",
179
+ "throw e;"
174
180
  ]
175
- )}, ${runtimeTemplate.basicFunction("e", [
176
- "if(installedChunks[chunkId] !== 0) installedChunks[chunkId] = undefined;",
177
- "throw e;"
178
- ])});`,
181
+ )});`,
179
182
  `var promise = Promise.race([promise, new Promise(${runtimeTemplate.expressionFunction(
180
183
  `installedChunkData = installedChunks[chunkId] = [resolve]`,
181
184
  "resolve"
@@ -193,6 +196,12 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
193
196
  ])
194
197
  : "// no chunk on demand loading",
195
198
  "",
199
+ withExternalInstallChunk
200
+ ? Template.asString([
201
+ `${RuntimeGlobals.externalInstallChunk} = installChunk;`
202
+ ])
203
+ : "// no external install chunk",
204
+ "",
196
205
  withOnChunkLoad
197
206
  ? `${
198
207
  RuntimeGlobals.onChunksLoaded
@@ -20,7 +20,7 @@ module.exports = (compiler, client, callback) => {
20
20
  const activeModules = new Map();
21
21
  const prefix = "/lazy-compilation-using-";
22
22
 
23
- const server = http.createServer((req, res) => {
23
+ const requestListener = (req, res) => {
24
24
  const keys = req.url.slice(prefix.length).split("@");
25
25
  req.socket.on("close", () => {
26
26
  setTimeout(() => {
@@ -51,7 +51,8 @@ module.exports = (compiler, client, callback) => {
51
51
  }
52
52
  }
53
53
  if (moduleActivated && compiler.watching) compiler.watching.invalidate();
54
- });
54
+ };
55
+ const server = http.createServer(requestListener);
55
56
  let isClosing = false;
56
57
  /** @type {Set<import("net").Socket>} */
57
58
  const sockets = new Set();
@@ -78,6 +79,8 @@ module.exports = (compiler, client, callback) => {
78
79
  callback(null, {
79
80
  dispose(callback) {
80
81
  isClosing = true;
82
+ // Removing the listener is a workaround for a memory leak in node.js
83
+ server.off("request", requestListener);
81
84
  server.close(err => {
82
85
  callback(err);
83
86
  });
@@ -834,7 +834,9 @@ class JavascriptModulesPlugin {
834
834
  }
835
835
  }
836
836
  if (runtimeRequirements.has(RuntimeGlobals.onChunksLoaded)) {
837
- startupSource.add(`${RuntimeGlobals.onChunksLoaded}();\n`);
837
+ startupSource.add(
838
+ `__webpack_exports__ = ${RuntimeGlobals.onChunksLoaded}(__webpack_exports__);\n`
839
+ );
838
840
  }
839
841
  source.add(
840
842
  hooks.renderStartup.call(startupSource, lastInlinedModule, {
@@ -0,0 +1,41 @@
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 { register } = require("../util/serialization");
9
+
10
+ class JsonData {
11
+ constructor(data) {
12
+ this._buffer = undefined;
13
+ this._data = undefined;
14
+ if (Buffer.isBuffer(data)) {
15
+ this._buffer = data;
16
+ } else {
17
+ this._data = data;
18
+ }
19
+ }
20
+
21
+ get() {
22
+ if (this._data === undefined && this._buffer !== undefined) {
23
+ this._data = JSON.parse(this._buffer.toString());
24
+ }
25
+ return this._data;
26
+ }
27
+ }
28
+
29
+ register(JsonData, "webpack/lib/json/JsonData", null, {
30
+ serialize(obj, { write }) {
31
+ if (obj._buffer === undefined && obj._data !== undefined) {
32
+ obj._buffer = Buffer.from(JSON.stringify(obj._data));
33
+ }
34
+ write(obj._buffer);
35
+ },
36
+ deserialize({ read }) {
37
+ return new JsonData(read());
38
+ }
39
+ });
40
+
41
+ module.exports = JsonData;
@@ -116,7 +116,10 @@ class JsonGenerator extends Generator {
116
116
  * @returns {number} estimate size of the module
117
117
  */
118
118
  getSize(module, type) {
119
- let data = module.buildInfo && module.buildInfo.jsonData;
119
+ let data =
120
+ module.buildInfo &&
121
+ module.buildInfo.jsonData &&
122
+ module.buildInfo.jsonData.get();
120
123
  if (!data) return 0;
121
124
  return stringifySafe(data).length + 10;
122
125
  }
@@ -145,7 +148,10 @@ class JsonGenerator extends Generator {
145
148
  concatenationScope
146
149
  }
147
150
  ) {
148
- const data = module.buildInfo && module.buildInfo.jsonData;
151
+ const data =
152
+ module.buildInfo &&
153
+ module.buildInfo.jsonData &&
154
+ module.buildInfo.jsonData.get();
149
155
  if (data === undefined) {
150
156
  return new RawSource(
151
157
  runtimeTemplate.missingModuleStatement({
@@ -8,6 +8,7 @@
8
8
  const parseJson = require("json-parse-better-errors");
9
9
  const Parser = require("../Parser");
10
10
  const JsonExportsDependency = require("../dependencies/JsonExportsDependency");
11
+ const JsonData = require("./JsonData");
11
12
 
12
13
  /** @typedef {import("../../declarations/plugins/JsonModulesPluginParser").JsonModulesPluginParserOptions} JsonModulesPluginParserOptions */
13
14
  /** @typedef {import("../Parser").ParserState} ParserState */
@@ -41,7 +42,7 @@ class JsonParser extends Parser {
41
42
  ? source
42
43
  : parseFn(source[0] === "\ufeff" ? source.slice(1) : source);
43
44
 
44
- state.module.buildInfo.jsonData = data;
45
+ state.module.buildInfo.jsonData = new JsonData(data);
45
46
  state.module.buildInfo.strict = true;
46
47
  state.module.buildMeta.exportsType = "default";
47
48
  state.module.buildMeta.defaultObject =
@@ -72,7 +72,7 @@ class SystemLibraryPlugin extends AbstractLibraryPlugin {
72
72
  render(source, { chunkGraph, moduleGraph, chunk }, { options, compilation }) {
73
73
  const modules = chunkGraph
74
74
  .getChunkModules(chunk)
75
- .filter(m => m instanceof ExternalModule);
75
+ .filter(m => m instanceof ExternalModule && m.externalType === "system");
76
76
  const externals = /** @type {ExternalModule[]} */ (modules);
77
77
 
78
78
  // The name this bundle should be registered as with System
@@ -45,6 +45,7 @@ const {
45
45
  /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
46
46
  /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
47
47
  /** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
48
+ /** @template T @typedef {import("../InitFragment")<T>} InitFragment */
48
49
  /** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
49
50
  /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
50
51
  /** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
@@ -55,6 +56,7 @@ const {
55
56
  /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
56
57
  /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
57
58
  /** @typedef {import("../WebpackError")} WebpackError */
59
+ /** @typedef {import("../javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
58
60
  /** @typedef {import("../util/Hash")} Hash */
59
61
  /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
60
62
  /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
@@ -104,6 +106,7 @@ if (!ReferencerClass.prototype.PropertyDefinition) {
104
106
  * @property {Object} ast
105
107
  * @property {Source} internalSource
106
108
  * @property {ReplaceSource} source
109
+ * @property {InitFragment<ChunkRenderContext>[]=} chunkInitFragments
107
110
  * @property {Iterable<string>} runtimeRequirements
108
111
  * @property {Scope} globalScope
109
112
  * @property {Scope} moduleScope
@@ -1508,6 +1511,8 @@ ${defineGetters}`
1508
1511
  }
1509
1512
  }
1510
1513
 
1514
+ const chunkInitFragments = [];
1515
+
1511
1516
  // evaluate modules in order
1512
1517
  for (const rawInfo of modulesWithInfo) {
1513
1518
  let name;
@@ -1521,6 +1526,9 @@ ${defineGetters}`
1521
1526
  )}\n`
1522
1527
  );
1523
1528
  result.add(info.source);
1529
+ if (info.chunkInitFragments) {
1530
+ for (const f of info.chunkInitFragments) chunkInitFragments.push(f);
1531
+ }
1524
1532
  if (info.runtimeRequirements) {
1525
1533
  for (const r of info.runtimeRequirements) {
1526
1534
  runtimeRequirements.add(r);
@@ -1583,9 +1591,14 @@ ${defineGetters}`
1583
1591
  }
1584
1592
  }
1585
1593
 
1594
+ const data = new Map();
1595
+ if (chunkInitFragments.length > 0)
1596
+ data.set("chunkInitFragments", chunkInitFragments);
1597
+
1586
1598
  /** @type {CodeGenerationResult} */
1587
1599
  const resultEntry = {
1588
1600
  sources: new Map([["javascript", new CachedSource(result)]]),
1601
+ data,
1589
1602
  runtimeRequirements
1590
1603
  };
1591
1604
 
@@ -1626,6 +1639,8 @@ ${defineGetters}`
1626
1639
  concatenationScope
1627
1640
  });
1628
1641
  const source = codeGenResult.sources.get("javascript");
1642
+ const data = codeGenResult.data;
1643
+ const chunkInitFragments = data && data.get("chunkInitFragments");
1629
1644
  const code = source.source().toString();
1630
1645
  let ast;
1631
1646
  try {
@@ -1662,6 +1677,7 @@ ${defineGetters}`
1662
1677
  info.ast = ast;
1663
1678
  info.internalSource = source;
1664
1679
  info.source = resultSource;
1680
+ info.chunkInitFragments = chunkInitFragments;
1665
1681
  info.globalScope = globalScope;
1666
1682
  info.moduleScope = moduleScope;
1667
1683
  } catch (err) {
@@ -27,7 +27,7 @@ class RuntimeChunkPlugin {
27
27
  (_, { name: entryName }) => {
28
28
  if (entryName === undefined) return;
29
29
  const data = compilation.entries.get(entryName);
30
- if (!data.options.runtime && !data.options.dependOn) {
30
+ if (data.options.runtime === undefined && !data.options.dependOn) {
31
31
  // Determine runtime chunk name
32
32
  let name = this.options.name;
33
33
  if (typeof name === "function") {
@@ -32,16 +32,17 @@ class ChunkPrefetchStartupRuntimeModule extends RuntimeModule {
32
32
  `${RuntimeGlobals.onChunksLoaded}(0, ${JSON.stringify(
33
33
  // This need to include itself to delay execution after this chunk has been fully loaded
34
34
  onChunks.filter(c => c === chunk).map(c => c.id)
35
- )}, ${runtimeTemplate.expressionFunction(
35
+ )}, ${runtimeTemplate.basicFunction(
36
+ "",
36
37
  chunks.size < 3
37
38
  ? Array.from(
38
39
  chunks,
39
40
  c =>
40
- `${RuntimeGlobals.prefetchChunk}(${JSON.stringify(c.id)})`
41
- ).join(", ")
41
+ `${RuntimeGlobals.prefetchChunk}(${JSON.stringify(c.id)});`
42
+ )
42
43
  : `${JSON.stringify(Array.from(chunks, c => c.id))}.map(${
43
44
  RuntimeGlobals.prefetchChunk
44
- })`
45
+ });`
45
46
  )}, 5);`
46
47
  )
47
48
  );
@@ -225,7 +225,7 @@ class RuleSetCompiler {
225
225
  if (typeof condition === "string") {
226
226
  return {
227
227
  matchWhenEmpty: condition.length === 0,
228
- fn: str => str.startsWith(condition)
228
+ fn: str => typeof str === "string" && str.startsWith(condition)
229
229
  };
230
230
  }
231
231
  if (typeof condition === "function") {
@@ -245,7 +245,7 @@ class RuleSetCompiler {
245
245
  if (condition instanceof RegExp) {
246
246
  return {
247
247
  matchWhenEmpty: condition.test(""),
248
- fn: v => condition.test(v)
248
+ fn: v => typeof v === "string" && condition.test(v)
249
249
  };
250
250
  }
251
251
  if (Array.isArray(condition)) {
@@ -58,7 +58,11 @@ class OnChunksLoadedRuntimeModule extends RuntimeModule {
58
58
  ]),
59
59
  "}",
60
60
  "if(fulfilled) {",
61
- Template.indent(["deferred.splice(i--, 1)", "result = fn();"]),
61
+ Template.indent([
62
+ "deferred.splice(i--, 1)",
63
+ "var r = fn();",
64
+ "if (r !== undefined) result = r;"
65
+ ]),
62
66
  "}"
63
67
  ]),
64
68
  "}",
@@ -11,15 +11,14 @@ const NormalModule = require("../NormalModule");
11
11
 
12
12
  // data URL scheme: "data:text/javascript;charset=utf-8;base64,some-string"
13
13
  // http://www.ietf.org/rfc/rfc2397.txt
14
- const URIRegEx = /^data:(?:[^;,]+)?(?:(?:;[^;,]+)*?)(;base64)?,(.*)$/i;
15
- const URIMetaRegEx = /^data:([^;,]+)?(?:(?:;[^;,]+)*?)(?:;(base64))?,/i;
14
+ const URIRegEx = /^data:([^;,]+)?((?:;[^;,]+)*?)(?:;(base64))?,(.*)$/i;
16
15
 
17
16
  const decodeDataURI = uri => {
18
17
  const match = URIRegEx.exec(uri);
19
18
  if (!match) return null;
20
19
 
21
- const isBase64 = match[1];
22
- const body = match[2];
20
+ const isBase64 = match[3];
21
+ const body = match[4];
23
22
  return isBase64
24
23
  ? Buffer.from(body, "base64")
25
24
  : Buffer.from(decodeURIComponent(body), "ascii");
@@ -38,10 +37,12 @@ class DataUriPlugin {
38
37
  normalModuleFactory.hooks.resolveForScheme
39
38
  .for("data")
40
39
  .tap("DataUriPlugin", resourceData => {
41
- const match = URIMetaRegEx.exec(resourceData.resource);
40
+ const match = URIRegEx.exec(resourceData.resource);
42
41
  if (match) {
43
42
  resourceData.data.mimetype = match[1] || "";
44
- resourceData.data.encoding = match[2] || false;
43
+ resourceData.data.parameters = match[2] || "";
44
+ resourceData.data.encoding = match[3] || false;
45
+ resourceData.data.encodedContent = match[4] || "";
45
46
  }
46
47
  });
47
48
  NormalModule.getCompilationHooks(compilation)
@@ -0,0 +1,110 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+
6
+ "use strict";
7
+
8
+ /**
9
+ * @template K
10
+ * @template V
11
+ */
12
+ class StackedCacheMap {
13
+ constructor() {
14
+ /** @type {Map<K, V>} */
15
+ this.map = new Map();
16
+ /** @type {ReadonlyMap<K, V>[]} */
17
+ this.stack = [];
18
+ }
19
+
20
+ /**
21
+ * @param {ReadonlyMap<K, V>} map map to add
22
+ * @param {boolean} immutable if 'map' is immutable and StackedCacheMap can keep referencing it
23
+ */
24
+ addAll(map, immutable) {
25
+ if (immutable) {
26
+ this.stack.push(map);
27
+
28
+ // largest map should go first
29
+ for (let i = this.stack.length - 1; i > 0; i--) {
30
+ const beforeLast = this.stack[i - 1];
31
+ if (beforeLast.size >= map.size) break;
32
+ this.stack[i] = beforeLast;
33
+ this.stack[i - 1] = map;
34
+ }
35
+ } else {
36
+ for (const [key, value] of map) {
37
+ this.map.set(key, value);
38
+ }
39
+ }
40
+ }
41
+
42
+ /**
43
+ * @param {K} item the key of the element to add
44
+ * @param {V} value the value of the element to add
45
+ * @returns {void}
46
+ */
47
+ set(item, value) {
48
+ this.map.set(item, value);
49
+ }
50
+
51
+ /**
52
+ * @param {K} item the item to delete
53
+ * @returns {void}
54
+ */
55
+ delete(item) {
56
+ throw new Error("Items can't be deleted from a StackedCacheMap");
57
+ }
58
+
59
+ /**
60
+ * @param {K} item the item to test
61
+ * @returns {boolean} true if the item exists in this set
62
+ */
63
+ has(item) {
64
+ throw new Error(
65
+ "Checking StackedCacheMap.has before reading is inefficient, use StackedCacheMap.get and check for undefined"
66
+ );
67
+ }
68
+
69
+ /**
70
+ * @param {K} item the key of the element to return
71
+ * @returns {V} the value of the element
72
+ */
73
+ get(item) {
74
+ for (const map of this.stack) {
75
+ const value = map.get(item);
76
+ if (value !== undefined) return value;
77
+ }
78
+ return this.map.get(item);
79
+ }
80
+
81
+ clear() {
82
+ this.stack.length = 0;
83
+ this.map.clear();
84
+ }
85
+
86
+ get size() {
87
+ let size = this.map.size;
88
+ for (const map of this.stack) {
89
+ size += map.size;
90
+ }
91
+ return size;
92
+ }
93
+
94
+ [Symbol.iterator]() {
95
+ const iterators = this.stack.map(map => map[Symbol.iterator]());
96
+ let current = this.map[Symbol.iterator]();
97
+ return {
98
+ next() {
99
+ let result = current.next();
100
+ while (result.done && iterators.length > 0) {
101
+ current = iterators.pop();
102
+ result = current.next();
103
+ }
104
+ return result;
105
+ }
106
+ };
107
+ }
108
+ }
109
+
110
+ module.exports = StackedCacheMap;
@@ -156,6 +156,7 @@ module.exports = {
156
156
  require("../dependencies/WebpackIsIncludedDependency"),
157
157
  "dependencies/WorkerDependency": () =>
158
158
  require("../dependencies/WorkerDependency"),
159
+ "json/JsonData": () => require("../json/JsonData"),
159
160
  "optimize/ConcatenatedModule": () =>
160
161
  require("../optimize/ConcatenatedModule"),
161
162
  DelegatedModule: () => require("../DelegatedModule"),
@@ -9,7 +9,6 @@ const { register } = require("./serialization");
9
9
  class ClassSerializer {
10
10
  constructor(Constructor) {
11
11
  this.Constructor = Constructor;
12
- this.hash = null;
13
12
  }
14
13
 
15
14
  serialize(obj, context) {
package/lib/webpack.js CHANGED
@@ -152,7 +152,7 @@ const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
152
152
  if (watch) {
153
153
  util.deprecate(
154
154
  () => {},
155
- "A 'callback' argument need to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.",
155
+ "A 'callback' argument needs to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.",
156
156
  "DEP_WEBPACK_WATCH_WITHOUT_CALLBACK"
157
157
  )();
158
158
  }