webpack 5.33.0 → 5.35.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 (112) hide show
  1. package/bin/webpack.js +0 -0
  2. package/lib/BannerPlugin.js +11 -7
  3. package/lib/ChunkGraph.js +12 -6
  4. package/lib/CleanPlugin.js +17 -15
  5. package/lib/Compilation.js +1 -1
  6. package/lib/DllPlugin.js +11 -7
  7. package/lib/DllReferencePlugin.js +11 -7
  8. package/lib/FileSystemInfo.js +112 -74
  9. package/lib/IgnorePlugin.js +11 -6
  10. package/lib/LoaderOptionsPlugin.js +10 -7
  11. package/lib/NormalModule.js +2 -2
  12. package/lib/ProgressPlugin.js +10 -6
  13. package/lib/RuntimePlugin.js +3 -1
  14. package/lib/SourceMapDevToolPlugin.js +10 -7
  15. package/lib/WatchIgnorePlugin.js +11 -6
  16. package/lib/WebpackOptionsApply.js +2 -1
  17. package/lib/asset/AssetModulesPlugin.js +33 -14
  18. package/lib/cache/PackFileCacheStrategy.js +16 -2
  19. package/lib/config/defaults.js +2 -1
  20. package/lib/container/ContainerPlugin.js +11 -3
  21. package/lib/container/ContainerReferencePlugin.js +12 -3
  22. package/lib/container/ModuleFederationPlugin.js +12 -5
  23. package/lib/debug/ProfilingPlugin.js +10 -6
  24. package/lib/dependencies/LoaderPlugin.js +6 -1
  25. package/lib/ids/HashedModuleIdsPlugin.js +11 -6
  26. package/lib/ids/OccurrenceChunkIdsPlugin.js +11 -6
  27. package/lib/ids/OccurrenceModuleIdsPlugin.js +11 -6
  28. package/lib/index.js +9 -3
  29. package/lib/json/JsonModulesPlugin.js +9 -8
  30. package/lib/node/CommonJsChunkLoadingPlugin.js +3 -1
  31. package/lib/node/NodeTargetPlugin.js +5 -1
  32. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +3 -1
  33. package/lib/node/ReadFileCompileWasmPlugin.js +3 -1
  34. package/lib/optimize/AggressiveSplittingPlugin.js +12 -6
  35. package/lib/optimize/LimitChunkCountPlugin.js +18 -10
  36. package/lib/optimize/MinChunkSizePlugin.js +11 -7
  37. package/lib/runtime/StartupChunkDependenciesPlugin.js +3 -1
  38. package/lib/serialization/BinaryMiddleware.js +47 -25
  39. package/lib/sharing/ConsumeSharedPlugin.js +11 -3
  40. package/lib/sharing/ProvideSharedPlugin.js +11 -3
  41. package/lib/util/comparators.js +1 -3
  42. package/lib/util/create-schema-validation.js +21 -0
  43. package/lib/util/registerExternalSerializer.js +1 -1
  44. package/lib/web/FetchCompileAsyncWasmPlugin.js +3 -1
  45. package/lib/web/FetchCompileWasmPlugin.js +3 -1
  46. package/lib/web/JsonpChunkLoadingPlugin.js +3 -1
  47. package/lib/webpack.js +7 -2
  48. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -1
  49. package/package.json +6 -6
  50. package/schemas/WebpackOptions.check.d.ts +7 -0
  51. package/schemas/WebpackOptions.check.js +6 -0
  52. package/schemas/WebpackOptions.json +13 -9
  53. package/schemas/plugins/BannerPlugin.check.d.ts +7 -0
  54. package/schemas/plugins/BannerPlugin.check.js +6 -0
  55. package/schemas/plugins/DllPlugin.check.d.ts +7 -0
  56. package/schemas/plugins/DllPlugin.check.js +6 -0
  57. package/schemas/plugins/DllReferencePlugin.check.d.ts +7 -0
  58. package/schemas/plugins/DllReferencePlugin.check.js +6 -0
  59. package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +7 -0
  60. package/schemas/plugins/HashedModuleIdsPlugin.check.js +6 -0
  61. package/schemas/plugins/IgnorePlugin.check.d.ts +7 -0
  62. package/schemas/plugins/IgnorePlugin.check.js +6 -0
  63. package/schemas/plugins/JsonModulesPluginParser.check.d.ts +7 -0
  64. package/schemas/plugins/JsonModulesPluginParser.check.js +6 -0
  65. package/schemas/plugins/LoaderOptionsPlugin.check.d.ts +7 -0
  66. package/schemas/plugins/LoaderOptionsPlugin.check.js +6 -0
  67. package/schemas/plugins/ProgressPlugin.check.d.ts +7 -0
  68. package/schemas/plugins/ProgressPlugin.check.js +6 -0
  69. package/schemas/plugins/SourceMapDevToolPlugin.check.d.ts +7 -0
  70. package/schemas/plugins/SourceMapDevToolPlugin.check.js +6 -0
  71. package/schemas/plugins/WatchIgnorePlugin.check.d.ts +7 -0
  72. package/schemas/plugins/WatchIgnorePlugin.check.js +6 -0
  73. package/schemas/plugins/asset/AssetGeneratorOptions.check.d.ts +7 -0
  74. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +6 -0
  75. package/schemas/plugins/asset/AssetGeneratorOptions.json +3 -0
  76. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.d.ts +7 -0
  77. package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +6 -0
  78. package/schemas/plugins/asset/AssetInlineGeneratorOptions.json +3 -0
  79. package/schemas/plugins/asset/AssetParserOptions.check.d.ts +7 -0
  80. package/schemas/plugins/asset/AssetParserOptions.check.js +6 -0
  81. package/schemas/plugins/asset/AssetParserOptions.json +3 -0
  82. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.d.ts +7 -0
  83. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +6 -0
  84. package/schemas/plugins/asset/AssetResourceGeneratorOptions.json +3 -0
  85. package/schemas/plugins/container/ContainerPlugin.check.d.ts +7 -0
  86. package/schemas/plugins/container/ContainerPlugin.check.js +6 -0
  87. package/schemas/plugins/container/ContainerReferencePlugin.check.d.ts +7 -0
  88. package/schemas/plugins/container/ContainerReferencePlugin.check.js +6 -0
  89. package/schemas/plugins/container/ExternalsType.check.d.ts +7 -0
  90. package/schemas/plugins/container/ExternalsType.check.js +6 -0
  91. package/schemas/plugins/container/ExternalsType.json +3 -0
  92. package/schemas/plugins/container/ModuleFederationPlugin.check.d.ts +7 -0
  93. package/schemas/plugins/container/ModuleFederationPlugin.check.js +6 -0
  94. package/schemas/plugins/debug/ProfilingPlugin.check.d.ts +7 -0
  95. package/schemas/plugins/debug/ProfilingPlugin.check.js +6 -0
  96. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.d.ts +7 -0
  97. package/schemas/plugins/ids/OccurrenceChunkIdsPlugin.check.js +6 -0
  98. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.d.ts +7 -0
  99. package/schemas/plugins/ids/OccurrenceModuleIdsPlugin.check.js +6 -0
  100. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.d.ts +7 -0
  101. package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +6 -0
  102. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.d.ts +7 -0
  103. package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +6 -0
  104. package/schemas/plugins/optimize/MinChunkSizePlugin.check.d.ts +7 -0
  105. package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +6 -0
  106. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.d.ts +7 -0
  107. package/schemas/plugins/sharing/ConsumeSharedPlugin.check.js +6 -0
  108. package/schemas/plugins/sharing/ProvideSharedPlugin.check.d.ts +7 -0
  109. package/schemas/plugins/sharing/ProvideSharedPlugin.check.js +6 -0
  110. package/schemas/plugins/sharing/SharePlugin.check.d.ts +7 -0
  111. package/schemas/plugins/sharing/SharePlugin.check.js +6 -0
  112. package/types.d.ts +21 -3
@@ -5,16 +5,23 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const { validate } = require("schema-utils");
9
- const schema = require("../../schemas/plugins/optimize/LimitChunkCountPlugin.json");
10
8
  const { STAGE_ADVANCED } = require("../OptimizationStages");
11
9
  const LazyBucketSortedSet = require("../util/LazyBucketSortedSet");
12
10
  const { compareChunks } = require("../util/comparators");
11
+ const createSchemaValidation = require("../util/create-schema-validation");
13
12
 
13
+ /** @typedef {import("../../declarations/plugins/optimize/LimitChunkCountPlugin").LimitChunkCountPluginOptions} LimitChunkCountPluginOptions */
14
14
  /** @typedef {import("../Chunk")} Chunk */
15
15
  /** @typedef {import("../Compiler")} Compiler */
16
16
 
17
- /** @typedef {import("../../declarations/plugins/optimize/LimitChunkCountPlugin").LimitChunkCountPluginOptions} LimitChunkCountPluginOptions */
17
+ const validate = createSchemaValidation(
18
+ require("../../schemas/plugins/optimize/LimitChunkCountPlugin.check.js"),
19
+ () => require("../../schemas/plugins/optimize/LimitChunkCountPlugin.json"),
20
+ {
21
+ name: "Limit Chunk Count Plugin",
22
+ baseDataPath: "options"
23
+ }
24
+ );
18
25
 
19
26
  /**
20
27
  * @typedef {Object} ChunkCombination
@@ -43,10 +50,7 @@ class LimitChunkCountPlugin {
43
50
  * @param {LimitChunkCountPluginOptions=} options options object
44
51
  */
45
52
  constructor(options) {
46
- validate(schema, options, {
47
- name: "Limit Chunk Count Plugin",
48
- baseDataPath: "options"
49
- });
53
+ validate(options);
50
54
  this.options = options;
51
55
  }
52
56
 
@@ -175,7 +179,8 @@ class LimitChunkCountPlugin {
175
179
  }
176
180
 
177
181
  // merge the chunks
178
- if (a.integrate(b, "limit")) {
182
+ if (chunkGraph.canChunksBeIntegrated(a, b)) {
183
+ chunkGraph.integrateChunks(a, b);
179
184
  compilation.chunks.delete(b);
180
185
 
181
186
  // flag chunk a as modified as further optimization are possible for all children here
@@ -204,7 +209,8 @@ class LimitChunkCountPlugin {
204
209
  continue;
205
210
  }
206
211
  // Update size
207
- const newIntegratedSize = a.integratedSize(
212
+ const newIntegratedSize = chunkGraph.getIntegratedChunksSize(
213
+ a,
208
214
  combination.b,
209
215
  options
210
216
  );
@@ -222,10 +228,12 @@ class LimitChunkCountPlugin {
222
228
  continue;
223
229
  }
224
230
  // Update size
225
- const newIntegratedSize = combination.a.integratedSize(
231
+ const newIntegratedSize = chunkGraph.getIntegratedChunksSize(
232
+ combination.a,
226
233
  a,
227
234
  options
228
235
  );
236
+
229
237
  const finishUpdate = combinations.startUpdate(combination);
230
238
  combination.b = a;
231
239
  combination.integratedSize = newIntegratedSize;
@@ -5,24 +5,28 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const { validate } = require("schema-utils");
9
- const schema = require("../../schemas/plugins/optimize/MinChunkSizePlugin.json");
10
8
  const { STAGE_ADVANCED } = require("../OptimizationStages");
9
+ const createSchemaValidation = require("../util/create-schema-validation");
11
10
 
11
+ /** @typedef {import("../../declarations/plugins/optimize/MinChunkSizePlugin").MinChunkSizePluginOptions} MinChunkSizePluginOptions */
12
12
  /** @typedef {import("../Chunk")} Chunk */
13
13
  /** @typedef {import("../Compiler")} Compiler */
14
14
 
15
- /** @typedef {import("../../declarations/plugins/optimize/MinChunkSizePlugin").MinChunkSizePluginOptions} MinChunkSizePluginOptions */
15
+ const validate = createSchemaValidation(
16
+ require("../../schemas/plugins/optimize/MinChunkSizePlugin.check.js"),
17
+ () => require("../../schemas/plugins/optimize/MinChunkSizePlugin.json"),
18
+ {
19
+ name: "Min Chunk Size Plugin",
20
+ baseDataPath: "options"
21
+ }
22
+ );
16
23
 
17
24
  class MinChunkSizePlugin {
18
25
  /**
19
26
  * @param {MinChunkSizePluginOptions} options options object
20
27
  */
21
28
  constructor(options) {
22
- validate(schema, options, {
23
- name: "Min Chunk Size Plugin",
24
- baseDataPath: "options"
25
- });
29
+ validate(options);
26
30
  this.options = options;
27
31
  }
28
32
 
@@ -32,7 +32,9 @@ class StartupChunkDependenciesPlugin {
32
32
  const isEnabledForChunk = chunk => {
33
33
  const options = chunk.getEntryOptions();
34
34
  const chunkLoading =
35
- (options && options.chunkLoading) || globalChunkLoading;
35
+ options && options.chunkLoading !== undefined
36
+ ? options.chunkLoading
37
+ : globalChunkLoading;
36
38
  return chunkLoading === this.chunkLoading;
37
39
  };
38
40
  compilation.hooks.additionalTreeRuntimeRequirements.tap(
@@ -123,6 +123,12 @@ class BinaryMiddleware extends SerializerMiddleware {
123
123
  return this._serialize(data, context);
124
124
  }
125
125
 
126
+ _serializeLazy(fn, context) {
127
+ return SerializerMiddleware.serializeLazy(fn, data =>
128
+ this._serialize(data, context)
129
+ );
130
+ }
131
+
126
132
  /**
127
133
  * @param {DeserializedType} data data
128
134
  * @param {Object} context context object
@@ -135,7 +141,7 @@ class BinaryMiddleware extends SerializerMiddleware {
135
141
  let leftOverBuffer = null;
136
142
  let currentPosition = 0;
137
143
  /** @type {BufferSerializableType[]} */
138
- const buffers = [];
144
+ let buffers = [];
139
145
  let buffersTotalLength = 0;
140
146
  const allocate = bytesNeeded => {
141
147
  if (currentBuffer !== null) {
@@ -146,8 +152,11 @@ class BinaryMiddleware extends SerializerMiddleware {
146
152
  currentBuffer = leftOverBuffer;
147
153
  leftOverBuffer = null;
148
154
  } else {
149
- currentBuffer = Buffer.allocUnsafeSlow(
150
- Math.max(bytesNeeded, buffersTotalLength, 16384)
155
+ currentBuffer = Buffer.allocUnsafe(
156
+ Math.max(
157
+ bytesNeeded,
158
+ Math.min(Math.max(buffersTotalLength, 1024), 16384)
159
+ )
151
160
  );
152
161
  }
153
162
  };
@@ -201,10 +210,7 @@ class BinaryMiddleware extends SerializerMiddleware {
201
210
  SerializerMiddleware.setLazySerializedValue(thing, data);
202
211
  serializedData = data;
203
212
  } else {
204
- serializedData = SerializerMiddleware.serializeLazy(
205
- thing,
206
- data => this._serialize(data, context)
207
- );
213
+ serializedData = this._serializeLazy(thing, context);
208
214
  }
209
215
  }
210
216
  if (typeof serializedData === "function") {
@@ -471,7 +477,13 @@ class BinaryMiddleware extends SerializerMiddleware {
471
477
  };
472
478
  serializeData(data);
473
479
  flush();
474
- return buffers;
480
+
481
+ // avoid leaking memory
482
+ currentBuffer = null;
483
+ leftOverBuffer = null;
484
+ const _buffers = buffers;
485
+ buffers = undefined;
486
+ return _buffers;
475
487
  }
476
488
 
477
489
  /**
@@ -483,6 +495,21 @@ class BinaryMiddleware extends SerializerMiddleware {
483
495
  return this._deserialize(data, context);
484
496
  }
485
497
 
498
+ _createLazyDeserialized(content, context) {
499
+ return SerializerMiddleware.createLazy(
500
+ memoize(() => this._deserialize(content, context)),
501
+ this,
502
+ undefined,
503
+ content
504
+ );
505
+ }
506
+
507
+ _deserializeLazy(fn, context) {
508
+ return SerializerMiddleware.deserializeLazy(fn, data =>
509
+ this._deserialize(data, context)
510
+ );
511
+ }
512
+
486
513
  /**
487
514
  * @param {SerializedType} data data
488
515
  * @param {Object} context context object
@@ -494,6 +521,8 @@ class BinaryMiddleware extends SerializerMiddleware {
494
521
  let currentIsBuffer = Buffer.isBuffer(currentBuffer);
495
522
  let currentPosition = 0;
496
523
 
524
+ const retainedBuffer = context.retainedBuffer || (x => x);
525
+
497
526
  const checkOverflow = () => {
498
527
  if (currentPosition >= currentBuffer.length) {
499
528
  currentPosition = 0;
@@ -607,23 +636,16 @@ class BinaryMiddleware extends SerializerMiddleware {
607
636
  do {
608
637
  const buf = readUpTo(l);
609
638
  l -= buf.length;
610
- content.push(buf);
639
+ content.push(retainedBuffer(buf));
611
640
  } while (l > 0);
612
641
  }
613
642
  }
614
- result.push(
615
- SerializerMiddleware.createLazy(
616
- memoize(() => this._deserialize(content, context)),
617
- this,
618
- undefined,
619
- content
620
- )
621
- );
643
+ result.push(this._createLazyDeserialized(content, context));
622
644
  };
623
645
  case BUFFER_HEADER:
624
646
  return () => {
625
647
  const len = readU32();
626
- result.push(read(len));
648
+ result.push(retainedBuffer(read(len)));
627
649
  };
628
650
  case TRUE_HEADER:
629
651
  return () => result.push(true);
@@ -849,14 +871,10 @@ class BinaryMiddleware extends SerializerMiddleware {
849
871
  });
850
872
 
851
873
  /** @type {DeserializedType} */
852
- const result = [];
874
+ let result = [];
853
875
  while (currentBuffer !== null) {
854
876
  if (typeof currentBuffer === "function") {
855
- result.push(
856
- SerializerMiddleware.deserializeLazy(currentBuffer, data =>
857
- this._deserialize(data, context)
858
- )
859
- );
877
+ result.push(this._deserializeLazy(currentBuffer, context));
860
878
  currentDataItem++;
861
879
  currentBuffer =
862
880
  currentDataItem < data.length ? data[currentDataItem] : null;
@@ -866,7 +884,11 @@ class BinaryMiddleware extends SerializerMiddleware {
866
884
  dispatchTable[header]();
867
885
  }
868
886
  }
869
- return result;
887
+
888
+ // avoid leaking memory in context
889
+ let _result = result;
890
+ result = undefined;
891
+ return _result;
870
892
  }
871
893
  }
872
894
 
@@ -5,13 +5,12 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const { validate } = require("schema-utils");
9
- const schema = require("../../schemas/plugins/sharing/ConsumeSharedPlugin.json");
10
8
  const ModuleNotFoundError = require("../ModuleNotFoundError");
11
9
  const RuntimeGlobals = require("../RuntimeGlobals");
12
10
  const WebpackError = require("../WebpackError");
13
11
  const { parseOptions } = require("../container/options");
14
12
  const LazySet = require("../util/LazySet");
13
+ const createSchemaValidation = require("../util/create-schema-validation");
15
14
  const { parseRange } = require("../util/semver");
16
15
  const ConsumeSharedFallbackDependency = require("./ConsumeSharedFallbackDependency");
17
16
  const ConsumeSharedModule = require("./ConsumeSharedModule");
@@ -30,6 +29,15 @@ const {
30
29
  /** @typedef {import("../ResolverFactory").ResolveOptionsWithDependencyType} ResolveOptionsWithDependencyType */
31
30
  /** @typedef {import("./ConsumeSharedModule").ConsumeOptions} ConsumeOptions */
32
31
 
32
+ const validate = createSchemaValidation(
33
+ require("../../schemas/plugins/sharing/ConsumeSharedPlugin.check.js"),
34
+ () => require("../../schemas/plugins/sharing/ConsumeSharedPlugin.json"),
35
+ {
36
+ name: "Consume Shared Plugin",
37
+ baseDataPath: "options"
38
+ }
39
+ );
40
+
33
41
  /** @type {ResolveOptionsWithDependencyType} */
34
42
  const RESOLVE_OPTIONS = { dependencyType: "esm" };
35
43
  const PLUGIN_NAME = "ConsumeSharedPlugin";
@@ -40,7 +48,7 @@ class ConsumeSharedPlugin {
40
48
  */
41
49
  constructor(options) {
42
50
  if (typeof options !== "string") {
43
- validate(schema, options, { name: "Consumes Shared Plugin" });
51
+ validate(options);
44
52
  }
45
53
 
46
54
  /** @type {[string, ConsumeOptions][]} */
@@ -5,10 +5,9 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const { validate } = require("schema-utils");
9
- const schema = require("../../schemas/plugins/sharing/ProvideSharedPlugin.json");
10
8
  const WebpackError = require("../WebpackError");
11
9
  const { parseOptions } = require("../container/options");
10
+ const createSchemaValidation = require("../util/create-schema-validation");
12
11
  const ProvideForSharedDependency = require("./ProvideForSharedDependency");
13
12
  const ProvideSharedDependency = require("./ProvideSharedDependency");
14
13
  const ProvideSharedModuleFactory = require("./ProvideSharedModuleFactory");
@@ -17,6 +16,15 @@ const ProvideSharedModuleFactory = require("./ProvideSharedModuleFactory");
17
16
  /** @typedef {import("../Compilation")} Compilation */
18
17
  /** @typedef {import("../Compiler")} Compiler */
19
18
 
19
+ const validate = createSchemaValidation(
20
+ require("../../schemas/plugins/sharing/ProvideSharedPlugin.check.js"),
21
+ () => require("../../schemas/plugins/sharing/ProvideSharedPlugin.json"),
22
+ {
23
+ name: "Provide Shared Plugin",
24
+ baseDataPath: "options"
25
+ }
26
+ );
27
+
20
28
  /**
21
29
  * @typedef {Object} ProvideOptions
22
30
  * @property {string} shareKey
@@ -32,7 +40,7 @@ class ProvideSharedPlugin {
32
40
  * @param {ProvideSharedPluginOptions} options options
33
41
  */
34
42
  constructor(options) {
35
- validate(schema, options, { name: "Provide Shared Plugin" });
43
+ validate(options);
36
44
 
37
45
  /** @type {[string, ProvideOptions][]} */
38
46
  this._provides = parseOptions(
@@ -34,9 +34,7 @@ const createCachedParameterizedComparator = fn => {
34
34
  * @param {T} b second item
35
35
  * @returns {-1|0|1} compare result
36
36
  */
37
- const result = (a, b) => {
38
- return fn(arg, a, b);
39
- };
37
+ const result = fn.bind(null, arg);
40
38
  map.set(arg, result);
41
39
  return result;
42
40
  };
@@ -0,0 +1,21 @@
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 memoize = require("./memoize");
9
+
10
+ const getValidate = memoize(() => require("schema-utils").validate);
11
+
12
+ const createSchemaValidation = (check = v => false, getSchema, options) => {
13
+ getSchema = memoize(getSchema);
14
+ return value => {
15
+ if (!check(value)) {
16
+ getValidate()(getSchema(), value, options);
17
+ }
18
+ };
19
+ };
20
+
21
+ module.exports = createSchemaValidation;
@@ -9,7 +9,7 @@ const { register } = require("./serialization");
9
9
 
10
10
  const Position = /** @type {TODO} */ (require("acorn")).Position;
11
11
  const SourceLocation = require("acorn").SourceLocation;
12
- const { ValidationError } = require("schema-utils");
12
+ const ValidationError = require("schema-utils/dist/ValidationError").default;
13
13
  const {
14
14
  CachedSource,
15
15
  ConcatSource,
@@ -24,7 +24,9 @@ class FetchCompileAsyncWasmPlugin {
24
24
  const isEnabledForChunk = chunk => {
25
25
  const options = chunk.getEntryOptions();
26
26
  const wasmLoading =
27
- (options && options.wasmLoading) || globalWasmLoading;
27
+ options && options.wasmLoading !== undefined
28
+ ? options.wasmLoading
29
+ : globalWasmLoading;
28
30
  return wasmLoading === "fetch";
29
31
  };
30
32
  const generateLoadBinaryCode = path =>
@@ -30,7 +30,9 @@ class FetchCompileWasmPlugin {
30
30
  const isEnabledForChunk = chunk => {
31
31
  const options = chunk.getEntryOptions();
32
32
  const wasmLoading =
33
- (options && options.wasmLoading) || globalWasmLoading;
33
+ options && options.wasmLoading !== undefined
34
+ ? options.wasmLoading
35
+ : globalWasmLoading;
34
36
  return wasmLoading === "fetch";
35
37
  };
36
38
  const generateLoadBinaryCode = path =>
@@ -24,7 +24,9 @@ class JsonpChunkLoadingPlugin {
24
24
  const isEnabledForChunk = chunk => {
25
25
  const options = chunk.getEntryOptions();
26
26
  const chunkLoading =
27
- (options && options.chunkLoading) || globalChunkLoading;
27
+ options && options.chunkLoading !== undefined
28
+ ? options.chunkLoading
29
+ : globalChunkLoading;
28
30
  return chunkLoading === "jsonp";
29
31
  };
30
32
  const onceForChunkSet = new WeakSet();
package/lib/webpack.js CHANGED
@@ -6,6 +6,7 @@
6
6
  "use strict";
7
7
 
8
8
  const util = require("util");
9
+ const webpackOptionsSchemaCheck = require("../schemas/WebpackOptions.check.js");
9
10
  const webpackOptionsSchema = require("../schemas/WebpackOptions.json");
10
11
  const Compiler = require("./Compiler");
11
12
  const MultiCompiler = require("./MultiCompiler");
@@ -16,7 +17,7 @@ const {
16
17
  } = require("./config/defaults");
17
18
  const { getNormalizedWebpackOptions } = require("./config/normalization");
18
19
  const NodeEnvironmentPlugin = require("./node/NodeEnvironmentPlugin");
19
- const validateSchema = require("./validateSchema");
20
+ const memoize = require("./util/memoize");
20
21
 
21
22
  /** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
22
23
  /** @typedef {import("./Compiler").WatchOptions} WatchOptions */
@@ -24,6 +25,8 @@ const validateSchema = require("./validateSchema");
24
25
  /** @typedef {import("./MultiStats")} MultiStats */
25
26
  /** @typedef {import("./Stats")} Stats */
26
27
 
28
+ const getValidateSchema = memoize(() => require("./validateSchema"));
29
+
27
30
  /**
28
31
  * @template T
29
32
  * @callback Callback
@@ -102,7 +105,9 @@ const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
102
105
  */
103
106
  (options, callback) => {
104
107
  const create = () => {
105
- validateSchema(webpackOptionsSchema, options);
108
+ if (!webpackOptionsSchemaCheck(options)) {
109
+ getValidateSchema()(webpackOptionsSchema, options);
110
+ }
106
111
  /** @type {MultiCompiler|Compiler} */
107
112
  let compiler;
108
113
  let watch = false;
@@ -29,7 +29,9 @@ class ImportScriptsChunkLoadingPlugin {
29
29
  const isEnabledForChunk = chunk => {
30
30
  const options = chunk.getEntryOptions();
31
31
  const chunkLoading =
32
- (options && options.chunkLoading) || globalChunkLoading;
32
+ options && options.chunkLoading !== undefined
33
+ ? options.chunkLoading
34
+ : globalChunkLoading;
33
35
  return chunkLoading === "import-scripts";
34
36
  };
35
37
  const onceForChunkSet = new WeakSet();
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.33.0",
3
+ "version": "5.35.0",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
6
6
  "license": "MIT",
7
7
  "dependencies": {
8
8
  "@types/eslint-scope": "^3.7.0",
9
- "@types/estree": "^0.0.46",
9
+ "@types/estree": "^0.0.47",
10
10
  "@webassemblyjs/ast": "1.11.0",
11
11
  "@webassemblyjs/wasm-edit": "1.11.0",
12
12
  "@webassemblyjs/wasm-parser": "1.11.0",
13
13
  "acorn": "^8.0.4",
14
14
  "browserslist": "^4.14.5",
15
15
  "chrome-trace-event": "^1.0.2",
16
- "enhanced-resolve": "^5.7.0",
16
+ "enhanced-resolve": "^5.8.0",
17
17
  "es-module-lexer": "^0.4.0",
18
18
  "eslint-scope": "^5.1.1",
19
19
  "events": "^3.2.0",
@@ -92,7 +92,7 @@
92
92
  "style-loader": "^2.0.0",
93
93
  "terser": "^5.5.0",
94
94
  "toml": "^3.0.0",
95
- "tooling": "webpack/tooling#v1.15.0",
95
+ "tooling": "webpack/tooling#v1.17.0",
96
96
  "ts-loader": "^8.0.2",
97
97
  "typescript": "^4.2.0-beta",
98
98
  "url-loader": "^4.1.0",
@@ -151,8 +151,8 @@
151
151
  "type-lint": "tsc",
152
152
  "typings-lint": "tsc -p tsconfig.test.json",
153
153
  "spellcheck": "cspell \"{.github,benchmark,bin,examples,hot,lib,schemas,setup,tooling}/**/*.{md,yml,yaml,js,json}\" \"*.md\"",
154
- "special-lint": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node tooling/generate-runtime-code.js && node node_modules/tooling/format-file-header && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/generate-types --no-template-literals",
155
- "special-lint-fix": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node tooling/generate-runtime-code.js --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/generate-types --no-template-literals --write",
154
+ "special-lint": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node tooling/generate-runtime-code.js && node node_modules/tooling/format-file-header && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/precompile-schemas && node node_modules/tooling/generate-types --no-template-literals",
155
+ "special-lint-fix": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node tooling/generate-runtime-code.js --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/precompile-schemas --write && node node_modules/tooling/generate-types --no-template-literals --write",
156
156
  "fix": "yarn code-lint --fix && yarn special-lint-fix && yarn pretty-lint-fix",
157
157
  "prepare": "husky install",
158
158
  "pretty-lint-base": "prettier \"*.{ts,json,yml,yaml,md}\" \"{setup,lib,bin,hot,benchmark,tooling,schemas}/**/*.json\" \"examples/*.md\"",
@@ -0,0 +1,7 @@
1
+ /*
2
+ * This file was automatically generated.
3
+ * DO NOT MODIFY BY HAND.
4
+ * Run `yarn special-lint-fix` to update
5
+ */
6
+ declare const check: (options: import("../declarations/WebpackOptions").WebpackOptions) => boolean;
7
+ export = check;