webpack 5.2.1 → 5.3.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.

@@ -280,6 +280,68 @@ exports.intersectRuntime = (a, b) => {
280
280
  }
281
281
  };
282
282
 
283
+ exports.subtractRuntime = (a, b) => {
284
+ if (a === undefined) {
285
+ return undefined;
286
+ } else if (b === undefined) {
287
+ return a;
288
+ } else if (a === b) {
289
+ return undefined;
290
+ } else if (typeof a === "string") {
291
+ if (typeof b === "string") {
292
+ return undefined;
293
+ } else if (b.has(a)) {
294
+ return undefined;
295
+ } else {
296
+ return a;
297
+ }
298
+ } else {
299
+ if (typeof b === "string") {
300
+ if (!a.has(b)) return a;
301
+ if (a.size === 2) {
302
+ for (const item of a) {
303
+ if (item !== b) return item;
304
+ }
305
+ }
306
+ const set = new SortableSet(a);
307
+ set.delete(b);
308
+ } else {
309
+ const set = new SortableSet();
310
+ for (const item of a) {
311
+ if (!b.has(item)) set.add(item);
312
+ }
313
+ if (set.size === 0) return undefined;
314
+ if (set.size === 1) for (const item of set) return item;
315
+ return set;
316
+ }
317
+ }
318
+ };
319
+
320
+ /**
321
+ * @param {RuntimeSpec} runtime runtime
322
+ * @param {function(RuntimeSpec): boolean} filter filter function
323
+ * @returns {boolean | RuntimeSpec} true/false if filter is constant for all runtimes, otherwise runtimes that are active
324
+ */
325
+ exports.filterRuntime = (runtime, filter) => {
326
+ if (runtime === undefined) return filter(undefined);
327
+ if (typeof runtime === "string") return filter(runtime);
328
+ let some = false;
329
+ let every = true;
330
+ let result = undefined;
331
+ for (const r of runtime) {
332
+ const v = filter(r);
333
+ if (v) {
334
+ some = true;
335
+ result = mergeRuntimeOwned(result, r);
336
+ } else {
337
+ every = false;
338
+ }
339
+ }
340
+ if (!some) return false;
341
+ if (every) return true;
342
+ return result;
343
+ };
344
+
283
345
  /**
284
346
  * @template T
285
347
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.2.1",
3
+ "version": "5.3.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",
@@ -1350,8 +1350,15 @@
1350
1350
  "$ref": "#/definitions/OptimizationRuntimeChunk"
1351
1351
  },
1352
1352
  "sideEffects": {
1353
- "description": "Skip over modules which are flagged to contain no side effects when exports are not used.",
1354
- "type": "boolean"
1353
+ "description": "Skip over modules which contain no side effects when exports are not used (false: disabled, 'flag': only use manually placed side effects flag, true: also analyse source code for side effects).",
1354
+ "anyOf": [
1355
+ {
1356
+ "enum": ["flag"]
1357
+ },
1358
+ {
1359
+ "type": "boolean"
1360
+ }
1361
+ ]
1355
1362
  },
1356
1363
  "splitChunks": {
1357
1364
  "description": "Optimize duplication and caching by splitting chunks by shared modules and cache group.",
package/types.d.ts CHANGED
@@ -784,6 +784,8 @@ declare class ChunkGraph {
784
784
  disconnectChunkGroup(chunkGroup: ChunkGroup): void;
785
785
  getModuleId(module: Module): string | number;
786
786
  setModuleId(module: Module, id: string | number): void;
787
+ getRuntimeId(runtime: string): string | number;
788
+ setRuntimeId(runtime: string, id: string | number): void;
787
789
  hasModuleHashes(
788
790
  module: Module,
789
791
  runtime: string | SortableSet<string>
@@ -1450,6 +1452,7 @@ declare class Compilation {
1450
1452
  ): void;
1451
1453
  patchChunksAfterReasonRemoval(module: Module, chunk: Chunk): void;
1452
1454
  removeChunkFromDependencies(block: DependenciesBlock, chunk: Chunk): void;
1455
+ assignRuntimeIds(): void;
1453
1456
  sortItemsWithChunkIds(): void;
1454
1457
  summarizeDependencies(): void;
1455
1458
  createModuleHashes(): void;
@@ -5844,9 +5847,9 @@ declare interface Optimization {
5844
5847
  runtimeChunk?: OptimizationRuntimeChunk;
5845
5848
 
5846
5849
  /**
5847
- * Skip over modules which are flagged to contain no side effects when exports are not used.
5850
+ * Skip over modules which contain no side effects when exports are not used (false: disabled, 'flag': only use manually placed side effects flag, true: also analyse source code for side effects).
5848
5851
  */
5849
- sideEffects?: boolean;
5852
+ sideEffects?: boolean | "flag";
5850
5853
 
5851
5854
  /**
5852
5855
  * Optimize duplication and caching by splitting chunks by shared modules and cache group.
@@ -8234,6 +8237,24 @@ declare abstract class RuntimeTemplate {
8234
8237
  */
8235
8238
  runtimeRequirements: Set<string>;
8236
8239
  }): string;
8240
+ runtimeConditionExpression(__0: {
8241
+ /**
8242
+ * the chunk graph
8243
+ */
8244
+ chunkGraph: ChunkGraph;
8245
+ /**
8246
+ * runtime for which this code will be generated
8247
+ */
8248
+ runtime?: string | SortableSet<string>;
8249
+ /**
8250
+ * only execute the statement in some runtimes
8251
+ */
8252
+ runtimeCondition?: string | boolean | SortableSet<string>;
8253
+ /**
8254
+ * if set, will be filled with runtime requirements
8255
+ */
8256
+ runtimeRequirements: Set<string>;
8257
+ }): string;
8237
8258
  importStatement(__0: {
8238
8259
  /**
8239
8260
  * whether a new variable should be created or the existing one updated
@@ -8263,6 +8284,14 @@ declare abstract class RuntimeTemplate {
8263
8284
  * true, if this is a weak dependency
8264
8285
  */
8265
8286
  weak?: boolean;
8287
+ /**
8288
+ * runtime for which this code will be generated
8289
+ */
8290
+ runtime?: string | SortableSet<string>;
8291
+ /**
8292
+ * only execute the statement in some runtimes
8293
+ */
8294
+ runtimeCondition?: string | boolean | SortableSet<string>;
8266
8295
  /**
8267
8296
  * if set, will be filled with runtime requirements
8268
8297
  */
@@ -8490,7 +8519,7 @@ declare interface SharedObject {
8490
8519
  [index: string]: string | SharedConfig;
8491
8520
  }
8492
8521
  declare class SideEffectsFlagPlugin {
8493
- constructor();
8522
+ constructor(analyseSource?: boolean);
8494
8523
 
8495
8524
  /**
8496
8525
  * Apply the plugin
@@ -9324,6 +9353,7 @@ declare const UNDEFINED_MARKER: unique symbol;
9324
9353
  declare interface UpdateHashContextDependency {
9325
9354
  chunkGraph: ChunkGraph;
9326
9355
  runtime: string | SortableSet<string>;
9356
+ runtimeTemplate?: RuntimeTemplate;
9327
9357
  }
9328
9358
  declare interface UpdateHashContextGenerator {
9329
9359
  /**
@@ -10112,6 +10142,7 @@ declare namespace exports {
10112
10142
  export let scriptNonce: string;
10113
10143
  export let loadScript: string;
10114
10144
  export let chunkName: string;
10145
+ export let runtimeId: string;
10115
10146
  export let getChunkScriptFilename: string;
10116
10147
  export let getChunkUpdateScriptFilename: string;
10117
10148
  export let startup: string;