webpack 5.36.1 → 5.36.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


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

package/bin/webpack.js CHANGED
File without changes
package/lib/Compiler.js CHANGED
@@ -263,6 +263,8 @@ class Compiler {
263
263
  this._assetEmittingSourceCache = new WeakMap();
264
264
  /** @private @type {Map<string, number>} */
265
265
  this._assetEmittingWrittenFiles = new Map();
266
+ /** @private @type {Set<string>} */
267
+ this._assetEmittingPreviousFiles = new Set();
266
268
  }
267
269
 
268
270
  /**
@@ -556,6 +558,8 @@ class Compiler {
556
558
  compilation.assets = { ...compilation.assets };
557
559
  /** @type {Map<string, { path: string, source: Source, size: number, waiting: { cacheEntry: any, file: string }[] }>} */
558
560
  const caseInsensitiveMap = new Map();
561
+ /** @type {Set<string>} */
562
+ const allTargetPaths = new Set();
559
563
  asyncLib.forEachLimit(
560
564
  assets,
561
565
  15,
@@ -583,6 +587,7 @@ class Compiler {
583
587
  outputPath,
584
588
  targetFile
585
589
  );
590
+ allTargetPaths.add(targetPath);
586
591
 
587
592
  // check if the target file has already been written by this Compiler
588
593
  const targetFileGeneration = this._assetEmittingWrittenFiles.get(
@@ -775,18 +780,22 @@ ${other}`);
775
780
  // check if the Source has been written to this target file
776
781
  const writtenGeneration = cacheEntry.writtenTo.get(targetPath);
777
782
  if (writtenGeneration === targetFileGeneration) {
778
- // if yes, we skip writing the file
779
- // as it's already there
780
- // (we assume one doesn't remove files while the Compiler is running)
783
+ // if yes, we may skip writing the file
784
+ // if it's already there
785
+ // (we assume one doesn't modify files while the Compiler is running, other then removing them)
781
786
 
782
- compilation.updateAsset(file, cacheEntry.sizeOnlySource, {
783
- size: cacheEntry.sizeOnlySource.size()
784
- });
785
-
786
- return callback();
787
- }
787
+ if (this._assetEmittingPreviousFiles.has(targetPath)) {
788
+ // We assume that assets from the last compilation say intact on disk (they are not removed)
789
+ compilation.updateAsset(file, cacheEntry.sizeOnlySource, {
790
+ size: cacheEntry.sizeOnlySource.size()
791
+ });
788
792
 
789
- if (!immutable) {
793
+ return callback();
794
+ } else {
795
+ // Settings immutable will make it accept file content without comparing when file exist
796
+ immutable = true;
797
+ }
798
+ } else if (!immutable) {
790
799
  if (checkSimilarFile()) return;
791
800
  // We wrote to this file before which has very likely a different content
792
801
  // skip comparing and assume content is different for performance
@@ -822,7 +831,12 @@ ${other}`);
822
831
  err => {
823
832
  // Clear map to free up memory
824
833
  caseInsensitiveMap.clear();
825
- if (err) return callback(err);
834
+ if (err) {
835
+ this._assetEmittingPreviousFiles.clear();
836
+ return callback(err);
837
+ }
838
+
839
+ this._assetEmittingPreviousFiles = allTargetPaths;
826
840
 
827
841
  this.hooks.afterEmit.callAsync(compilation, err => {
828
842
  if (err) return callback(err);
@@ -520,29 +520,33 @@ class NormalModuleFactory extends ModuleFactory {
520
520
  )
521
521
  );
522
522
  }
523
- Object.assign(data.createData, {
524
- layer:
525
- layer === undefined ? contextInfo.issuerLayer || null : layer,
526
- request: stringifyLoadersAndResource(
527
- allLoaders,
528
- resourceData.resource
529
- ),
530
- userRequest,
531
- rawRequest: request,
532
- loaders: allLoaders,
533
- resource: resourceData.resource,
534
- matchResource: matchResourceData
535
- ? matchResourceData.resource
536
- : undefined,
537
- resourceResolveData: resourceData.data,
538
- settings,
539
- type,
540
- parser: this.getParser(type, settings.parser),
541
- parserOptions: settings.parser,
542
- generator: this.getGenerator(type, settings.generator),
543
- generatorOptions: settings.generator,
544
- resolveOptions
545
- });
523
+ try {
524
+ Object.assign(data.createData, {
525
+ layer:
526
+ layer === undefined ? contextInfo.issuerLayer || null : layer,
527
+ request: stringifyLoadersAndResource(
528
+ allLoaders,
529
+ resourceData.resource
530
+ ),
531
+ userRequest,
532
+ rawRequest: request,
533
+ loaders: allLoaders,
534
+ resource: resourceData.resource,
535
+ matchResource: matchResourceData
536
+ ? matchResourceData.resource
537
+ : undefined,
538
+ resourceResolveData: resourceData.data,
539
+ settings,
540
+ type,
541
+ parser: this.getParser(type, settings.parser),
542
+ parserOptions: settings.parser,
543
+ generator: this.getGenerator(type, settings.generator),
544
+ generatorOptions: settings.generator,
545
+ resolveOptions
546
+ });
547
+ } catch (e) {
548
+ return callback(e);
549
+ }
546
550
  callback();
547
551
  });
548
552
  this.resolveRequestArray(
@@ -997,10 +997,15 @@ const visitModules = (
997
997
  };
998
998
 
999
999
  const processChunkGroupsForCombining = () => {
1000
- loop: for (const info of chunkGroupsForCombining) {
1000
+ for (const info of chunkGroupsForCombining) {
1001
1001
  for (const source of info.availableSources) {
1002
- if (!source.minAvailableModules) continue loop;
1002
+ if (!source.minAvailableModules) {
1003
+ chunkGroupsForCombining.delete(info);
1004
+ break;
1005
+ }
1003
1006
  }
1007
+ }
1008
+ for (const info of chunkGroupsForCombining) {
1004
1009
  const availableModules = /** @type {ModuleSetPlus} */ (new Set());
1005
1010
  availableModules.plus = EMPTY_SET;
1006
1011
  const mergeSet = set => {
@@ -9,9 +9,9 @@ const { pathToFileURL } = require("url");
9
9
  const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
10
10
  const CommentCompilationWarning = require("../CommentCompilationWarning");
11
11
  const UnsupportedFeatureWarning = require("../UnsupportedFeatureWarning");
12
- const formatLocation = require("../formatLocation");
13
12
  const EnableChunkLoadingPlugin = require("../javascript/EnableChunkLoadingPlugin");
14
13
  const { equals } = require("../util/ArrayHelpers");
14
+ const createHash = require("../util/createHash");
15
15
  const { contextify } = require("../util/identifier");
16
16
  const EnableWasmLoadingPlugin = require("../wasm/EnableWasmLoadingPlugin");
17
17
  const ConstDependency = require("./ConstDependency");
@@ -27,6 +27,7 @@ const WorkerDependency = require("./WorkerDependency");
27
27
  /** @typedef {import("estree").SpreadElement} SpreadElement */
28
28
  /** @typedef {import("../Compiler")} Compiler */
29
29
  /** @typedef {import("../Entrypoint").EntryOptions} EntryOptions */
30
+ /** @typedef {import("../Parser").ParserState} ParserState */
30
31
  /** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
31
32
  /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
32
33
  /** @typedef {import("./HarmonyImportDependencyParserPlugin").HarmonySettings} HarmonySettings */
@@ -42,6 +43,9 @@ const DEFAULT_SYNTAX = [
42
43
  "Worker from worker_threads"
43
44
  ];
44
45
 
46
+ /** @type {WeakMap<ParserState, number>} */
47
+ const workerIndexMap = new WeakMap();
48
+
45
49
  class WorkerPlugin {
46
50
  constructor(chunkLoading, wasmLoading) {
47
51
  this._chunkLoading = chunkLoading;
@@ -264,9 +268,20 @@ class WorkerPlugin {
264
268
  }
265
269
 
266
270
  if (!entryOptions.runtime) {
267
- entryOptions.runtime = `${cachedContextify(
271
+ let i = workerIndexMap.get(parser.state) || 0;
272
+ workerIndexMap.set(parser.state, i + 1);
273
+ let name = `${cachedContextify(
268
274
  parser.state.module.identifier()
269
- )}|${formatLocation(expr.loc)}`;
275
+ )}|${i}`;
276
+ const hash = createHash(compilation.outputOptions.hashFunction);
277
+ hash.update(name);
278
+ const digest = /** @type {string} */ (hash.digest(
279
+ compilation.outputOptions.hashDigest
280
+ ));
281
+ entryOptions.runtime = digest.slice(
282
+ 0,
283
+ compilation.outputOptions.hashDigestLength
284
+ );
270
285
  }
271
286
 
272
287
  const block = new AsyncDependenciesBlock({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.36.1",
3
+ "version": "5.36.2",
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",
@@ -55,7 +55,7 @@
55
55
  "eslint": "^7.14.0",
56
56
  "eslint-config-prettier": "^8.1.0",
57
57
  "eslint-plugin-jest": "^24.1.3",
58
- "eslint-plugin-jsdoc": "^32.0.2",
58
+ "eslint-plugin-jsdoc": "^33.0.0",
59
59
  "eslint-plugin-node": "^11.0.0",
60
60
  "eslint-plugin-prettier": "^3.1.4",
61
61
  "file-loader": "^6.0.0",