webpack 5.38.1 → 5.39.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 (43) hide show
  1. package/bin/webpack.js +20 -5
  2. package/lib/AsyncDependencyToInitialChunkError.js +0 -2
  3. package/lib/CaseSensitiveModulesWarning.js +0 -2
  4. package/lib/Chunk.js +6 -2
  5. package/lib/ChunkRenderError.js +0 -2
  6. package/lib/CodeGenerationError.js +0 -2
  7. package/lib/CommentCompilationWarning.js +0 -2
  8. package/lib/ConcurrentCompilationError.js +0 -2
  9. package/lib/ContextModule.js +2 -1
  10. package/lib/ContextModuleFactory.js +3 -1
  11. package/lib/DllReferencePlugin.js +0 -2
  12. package/lib/HarmonyLinkingError.js +0 -2
  13. package/lib/HookWebpackError.js +0 -1
  14. package/lib/InvalidDependenciesModuleWarning.js +0 -2
  15. package/lib/ModuleBuildError.js +0 -2
  16. package/lib/ModuleDependencyError.js +0 -2
  17. package/lib/ModuleDependencyWarning.js +0 -2
  18. package/lib/ModuleError.js +0 -2
  19. package/lib/ModuleNotFoundError.js +0 -2
  20. package/lib/ModuleParseError.js +0 -2
  21. package/lib/ModuleRestoreError.js +0 -2
  22. package/lib/ModuleStoreError.js +0 -2
  23. package/lib/ModuleWarning.js +0 -2
  24. package/lib/NoModeWarning.js +0 -2
  25. package/lib/NormalModule.js +0 -2
  26. package/lib/UnsupportedFeatureWarning.js +0 -2
  27. package/lib/WarnDeprecatedOptionPlugin.js +0 -2
  28. package/lib/WebpackError.js +0 -2
  29. package/lib/config/normalization.js +1 -0
  30. package/lib/dependencies/ContextElementDependency.js +6 -1
  31. package/lib/dependencies/CriticalDependencyWarning.js +0 -2
  32. package/lib/dependencies/ImportParserPlugin.js +1 -0
  33. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +0 -2
  34. package/lib/dependencies/SystemPlugin.js +0 -2
  35. package/lib/errors/BuildCycleError.js +0 -1
  36. package/lib/hmr/LazyCompilationPlugin.js +3 -1
  37. package/lib/performance/AssetsOverSizeLimitWarning.js +0 -2
  38. package/lib/performance/EntrypointsOverSizeLimitWarning.js +0 -2
  39. package/lib/performance/NoAsyncChunksWarning.js +0 -2
  40. package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +0 -2
  41. package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +0 -2
  42. package/package.json +1 -1
  43. package/types.d.ts +1 -0
package/bin/webpack.js CHANGED
@@ -32,13 +32,28 @@ const runCommand = (command, args) => {
32
32
  * @returns {boolean} is the package installed?
33
33
  */
34
34
  const isInstalled = packageName => {
35
- try {
36
- require.resolve(packageName);
37
-
35
+ if (process.versions.pnp) {
38
36
  return true;
39
- } catch (err) {
40
- return false;
41
37
  }
38
+
39
+ const path = require("path");
40
+ const fs = require("graceful-fs");
41
+
42
+ let dir = __dirname;
43
+
44
+ do {
45
+ try {
46
+ if (
47
+ fs.statSync(path.join(dir, "node_modules", packageName)).isDirectory()
48
+ ) {
49
+ return true;
50
+ }
51
+ } catch (_error) {
52
+ // Nothing
53
+ }
54
+ } while (dir !== (dir = path.dirname(dir)));
55
+
56
+ return false;
42
57
  };
43
58
 
44
59
  /**
@@ -25,8 +25,6 @@ class AsyncDependencyToInitialChunkError extends WebpackError {
25
25
  this.name = "AsyncDependencyToInitialChunkError";
26
26
  this.module = module;
27
27
  this.loc = loc;
28
-
29
- Error.captureStackTrace(this, this.constructor);
30
28
  }
31
29
  }
32
30
 
@@ -65,8 +65,6 @@ ${modulesList}`);
65
65
 
66
66
  this.name = "CaseSensitiveModulesWarning";
67
67
  this.module = sortedModules[0];
68
-
69
- Error.captureStackTrace(this, this.constructor);
70
68
  }
71
69
  }
72
70
 
package/lib/Chunk.js CHANGED
@@ -598,8 +598,12 @@ class Chunk {
598
598
  */
599
599
  getAllInitialChunks() {
600
600
  const chunks = new Set();
601
- for (const group of this.groupsIterable) {
602
- for (const c of group.chunks) chunks.add(c);
601
+ const queue = new Set(this.groupsIterable);
602
+ for (const group of queue) {
603
+ if (group.isInitial()) {
604
+ for (const c of group.chunks) chunks.add(c);
605
+ for (const g of group.childrenIterable) queue.add(g);
606
+ }
603
607
  }
604
608
  return chunks;
605
609
  }
@@ -25,8 +25,6 @@ class ChunkRenderError extends WebpackError {
25
25
  this.details = error.stack;
26
26
  this.file = file;
27
27
  this.chunk = chunk;
28
-
29
- Error.captureStackTrace(this, this.constructor);
30
28
  }
31
29
  }
32
30
 
@@ -23,8 +23,6 @@ class CodeGenerationError extends WebpackError {
23
23
  this.message = error.message;
24
24
  this.details = error.stack;
25
25
  this.module = module;
26
-
27
- Error.captureStackTrace(this, this.constructor);
28
26
  }
29
27
  }
30
28
 
@@ -22,8 +22,6 @@ class CommentCompilationWarning extends WebpackError {
22
22
  this.name = "CommentCompilationWarning";
23
23
 
24
24
  this.loc = loc;
25
-
26
- Error.captureStackTrace(this, this.constructor);
27
25
  }
28
26
  }
29
27
 
@@ -14,7 +14,5 @@ module.exports = class ConcurrentCompilationError extends WebpackError {
14
14
  this.name = "ConcurrentCompilationError";
15
15
  this.message =
16
16
  "You ran Webpack twice. Each instance only supports a single concurrent compilation at a time.";
17
-
18
- Error.captureStackTrace(this, this.constructor);
19
17
  }
20
18
  };
@@ -54,6 +54,7 @@ const makeSerializable = require("./util/makeSerializable");
54
54
  * @property {RegExp=} include
55
55
  * @property {RegExp=} exclude
56
56
  * @property {RawChunkGroupOptions=} groupOptions
57
+ * @property {string=} typePrefix
57
58
  * @property {string=} category
58
59
  * @property {string[][]=} referencedExports exports referenced from modules (won't be mangled)
59
60
  */
@@ -577,7 +578,7 @@ class ContextModule extends Module {
577
578
  fakeMapDataExpression = "fakeMap[id]"
578
579
  ) {
579
580
  if (typeof fakeMap === "number") {
580
- return `return ${this.getReturn(fakeMap)};`;
581
+ return `return ${this.getReturn(fakeMap, asyncModule)};`;
581
582
  }
582
583
  return `return ${
583
584
  RuntimeGlobals.createFakeNamespaceObject
@@ -273,7 +273,8 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
273
273
  include,
274
274
  exclude,
275
275
  referencedExports,
276
- category
276
+ category,
277
+ typePrefix
277
278
  } = options;
278
279
  if (!regExp || !resource) return callback(null, []);
279
280
 
@@ -346,6 +347,7 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
346
347
  const dep = new ContextElementDependency(
347
348
  obj.request + resourceQuery + resourceFragment,
348
349
  obj.request,
350
+ typePrefix,
349
351
  category,
350
352
  referencedExports
351
353
  );
@@ -156,8 +156,6 @@ class DllManifestError extends WebpackError {
156
156
 
157
157
  this.name = "DllManifestError";
158
158
  this.message = `Dll manifest ${filename}\n${message}`;
159
-
160
- Error.captureStackTrace(this, this.constructor);
161
159
  }
162
160
  }
163
161
 
@@ -12,7 +12,5 @@ module.exports = class HarmonyLinkingError extends WebpackError {
12
12
  super(message);
13
13
  this.name = "HarmonyLinkingError";
14
14
  this.hideStack = true;
15
-
16
- Error.captureStackTrace(this, this.constructor);
17
15
  }
18
16
  };
@@ -32,7 +32,6 @@ class HookWebpackError extends WebpackError {
32
32
  this.hideStack = true;
33
33
  this.details = `caused by plugins in ${hook}\n${error.stack}`;
34
34
 
35
- Error.captureStackTrace(this, this.constructor);
36
35
  this.stack += `\n-- inner error --\n${error.stack}`;
37
36
  }
38
37
  }
@@ -33,8 +33,6 @@ ${depsList.slice(0, 3).join("\n")}${
33
33
  this.name = "InvalidDependenciesModuleWarning";
34
34
  this.details = depsList.slice(3).join("\n");
35
35
  this.module = module;
36
-
37
- Error.captureStackTrace(this, this.constructor);
38
36
  }
39
37
  }
40
38
 
@@ -53,8 +53,6 @@ class ModuleBuildError extends WebpackError {
53
53
  this.name = "ModuleBuildError";
54
54
  this.details = details;
55
55
  this.error = err;
56
-
57
- Error.captureStackTrace(this, this.constructor);
58
56
  }
59
57
 
60
58
  serialize(context) {
@@ -30,8 +30,6 @@ class ModuleDependencyError extends WebpackError {
30
30
  /** error is not (de)serialized, so it might be undefined after deserialization */
31
31
  this.error = err;
32
32
 
33
- Error.captureStackTrace(this, this.constructor);
34
-
35
33
  if (err && /** @type {any} */ (err).hideStack) {
36
34
  this.stack =
37
35
  err.stack.split("\n").slice(1).join("\n") + "\n\n" + this.stack;
@@ -30,8 +30,6 @@ class ModuleDependencyWarning extends WebpackError {
30
30
  /** error is not (de)serialized, so it might be undefined after deserialization */
31
31
  this.error = err;
32
32
 
33
- Error.captureStackTrace(this, this.constructor);
34
-
35
33
  if (err && /** @type {any} */ (err).hideStack) {
36
34
  this.stack =
37
35
  err.stack.split("\n").slice(1).join("\n") + "\n\n" + this.stack;
@@ -37,8 +37,6 @@ class ModuleError extends WebpackError {
37
37
  err && typeof err === "object" && err.stack
38
38
  ? cleanUp(err.stack, this.message)
39
39
  : undefined;
40
-
41
- Error.captureStackTrace(this, this.constructor);
42
40
  }
43
41
 
44
42
  serialize(context) {
@@ -80,8 +80,6 @@ class ModuleNotFoundError extends WebpackError {
80
80
  this.module = module;
81
81
  this.error = err;
82
82
  this.loc = loc;
83
-
84
- Error.captureStackTrace(this, this.constructor);
85
83
  }
86
84
  }
87
85
 
@@ -85,8 +85,6 @@ class ModuleParseError extends WebpackError {
85
85
  this.name = "ModuleParseError";
86
86
  this.loc = loc;
87
87
  this.error = err;
88
-
89
- Error.captureStackTrace(this, this.constructor);
90
88
  }
91
89
 
92
90
  serialize(context) {
@@ -36,8 +36,6 @@ class ModuleRestoreError extends WebpackError {
36
36
  this.details = details;
37
37
  this.module = module;
38
38
  this.error = err;
39
-
40
- Error.captureStackTrace(this, this.constructor);
41
39
  }
42
40
  }
43
41
 
@@ -36,8 +36,6 @@ class ModuleStoreError extends WebpackError {
36
36
  this.details = details;
37
37
  this.module = module;
38
38
  this.error = err;
39
-
40
- Error.captureStackTrace(this, this.constructor);
41
39
  }
42
40
  }
43
41
 
@@ -37,8 +37,6 @@ class ModuleWarning extends WebpackError {
37
37
  warning && typeof warning === "object" && warning.stack
38
38
  ? cleanUp(warning.stack, this.message)
39
39
  : undefined;
40
-
41
- Error.captureStackTrace(this, this.constructor);
42
40
  }
43
41
 
44
42
  serialize(context) {
@@ -18,7 +18,5 @@ module.exports = class NoModeWarning extends WebpackError {
18
18
  "Set 'mode' option to 'development' or 'production' to enable defaults for each environment.\n" +
19
19
  "You can also set it to 'none' to disable any default behavior. " +
20
20
  "Learn more: https://webpack.js.org/configuration/mode/";
21
-
22
- Error.captureStackTrace(this, this.constructor);
23
21
  }
24
22
  };
@@ -164,8 +164,6 @@ class NonErrorEmittedError extends WebpackError {
164
164
 
165
165
  this.name = "NonErrorEmittedError";
166
166
  this.message = "(Emitted value instead of an instance of Error) " + error;
167
-
168
- Error.captureStackTrace(this, this.constructor);
169
167
  }
170
168
  }
171
169
 
@@ -21,8 +21,6 @@ class UnsupportedFeatureWarning extends WebpackError {
21
21
  this.name = "UnsupportedFeatureWarning";
22
22
  this.loc = loc;
23
23
  this.hideStack = true;
24
-
25
- Error.captureStackTrace(this, this.constructor);
26
24
  }
27
25
  }
28
26
 
@@ -48,8 +48,6 @@ class DeprecatedOptionWarning extends WebpackError {
48
48
  "configuration\n" +
49
49
  `The value '${value}' for option '${option}' is deprecated. ` +
50
50
  `Use '${suggestion}' instead.`;
51
-
52
- Error.captureStackTrace(this, this.constructor);
53
51
  }
54
52
  }
55
53
 
@@ -31,8 +31,6 @@ class WebpackError extends Error {
31
31
  this.chunk = undefined;
32
32
  /** @type {string} */
33
33
  this.file = undefined;
34
-
35
- Error.captureStackTrace(this, this.constructor);
36
34
  }
37
35
 
38
36
  [inspect]() {
@@ -129,6 +129,7 @@ const getNormalizedWebpackOptions = config => {
129
129
  case "filesystem":
130
130
  return {
131
131
  type: "filesystem",
132
+ allowCollectingMemory: cache.allowCollectingMemory,
132
133
  maxMemoryGenerations: cache.maxMemoryGenerations,
133
134
  maxAge: cache.maxAge,
134
135
  profile: cache.profile,
@@ -14,9 +14,10 @@ const ModuleDependency = require("./ModuleDependency");
14
14
  /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
15
15
 
16
16
  class ContextElementDependency extends ModuleDependency {
17
- constructor(request, userRequest, category, referencedExports) {
17
+ constructor(request, userRequest, typePrefix, category, referencedExports) {
18
18
  super(request);
19
19
  this.referencedExports = referencedExports;
20
+ this._typePrefix = typePrefix;
20
21
  this._category = category;
21
22
 
22
23
  if (userRequest) {
@@ -25,6 +26,10 @@ class ContextElementDependency extends ModuleDependency {
25
26
  }
26
27
 
27
28
  get type() {
29
+ if (this._typePrefix) {
30
+ return `${this._typePrefix} context element`;
31
+ }
32
+
28
33
  return "context element";
29
34
  }
30
35
 
@@ -14,8 +14,6 @@ class CriticalDependencyWarning extends WebpackError {
14
14
 
15
15
  this.name = "CriticalDependencyWarning";
16
16
  this.message = "Critical dependency: " + message;
17
-
18
- Error.captureStackTrace(this, this.constructor);
19
17
  }
20
18
  }
21
19
 
@@ -248,6 +248,7 @@ class ImportParserPlugin {
248
248
  namespaceObject: parser.state.module.buildMeta.strictHarmonyModule
249
249
  ? "strict"
250
250
  : true,
251
+ typePrefix: "import()",
251
252
  category: "esm",
252
253
  referencedExports: exports
253
254
  },
@@ -67,8 +67,6 @@ class RequireIncludeDeprecationWarning extends WebpackError {
67
67
  this.name = "RequireIncludeDeprecationWarning";
68
68
 
69
69
  this.loc = loc;
70
-
71
- Error.captureStackTrace(this, this.constructor);
72
70
  }
73
71
  }
74
72
 
@@ -127,8 +127,6 @@ class SystemImportDeprecationWarning extends WebpackError {
127
127
  this.name = "SystemImportDeprecationWarning";
128
128
 
129
129
  this.loc = loc;
130
-
131
- Error.captureStackTrace(this, this.constructor);
132
130
  }
133
131
  }
134
132
 
@@ -21,7 +21,6 @@ class BuildCycleError extends WebpackError {
21
21
 
22
22
  this.name = "BuildCycleError";
23
23
  this.module = module;
24
- Error.captureStackTrace(this, this.constructor);
25
24
  }
26
25
  }
27
26
 
@@ -350,7 +350,9 @@ class LazyCompilationPlugin {
350
350
  resolveData.dependencies.every(
351
351
  dep =>
352
352
  IGNORED_DEPENDENCY_TYPES.has(dep.type) ||
353
- (this.imports && dep.type === "import()") ||
353
+ (this.imports &&
354
+ (dep.type === "import()" ||
355
+ dep.type === "import() context element")) ||
354
356
  (this.entries && dep.type === "entry")
355
357
  ) &&
356
358
  !/webpack[/\\]hot[/\\]|webpack-dev-server[/\\]client/.test(
@@ -28,7 +28,5 @@ Assets: ${assetLists}`);
28
28
 
29
29
  this.name = "AssetsOverSizeLimitWarning";
30
30
  this.assets = assetsOverSizeLimit;
31
-
32
- Error.captureStackTrace(this, this.constructor);
33
31
  }
34
32
  };
@@ -31,7 +31,5 @@ Entrypoints:${entrypointList}\n`);
31
31
 
32
32
  this.name = "EntrypointsOverSizeLimitWarning";
33
33
  this.entrypoints = entrypoints;
34
-
35
- Error.captureStackTrace(this, this.constructor);
36
34
  }
37
35
  };
@@ -16,7 +16,5 @@ module.exports = class NoAsyncChunksWarning extends WebpackError {
16
16
  );
17
17
 
18
18
  this.name = "NoAsyncChunksWarning";
19
-
20
- Error.captureStackTrace(this, this.constructor);
21
19
  }
22
20
  };
@@ -12,7 +12,5 @@ module.exports = class UnsupportedWebAssemblyFeatureError extends WebpackError {
12
12
  super(message);
13
13
  this.name = "UnsupportedWebAssemblyFeatureError";
14
14
  this.hideStack = true;
15
-
16
- Error.captureStackTrace(this, this.constructor);
17
15
  }
18
16
  };
@@ -102,7 +102,5 @@ ${moduleChains.map(s => `* ${s}`).join("\n")}`;
102
102
  this.name = "WebAssemblyInInitialChunkError";
103
103
  this.hideStack = true;
104
104
  this.module = module;
105
-
106
- Error.captureStackTrace(this, this.constructor);
107
105
  }
108
106
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.38.1",
3
+ "version": "5.39.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",
package/types.d.ts CHANGED
@@ -2375,6 +2375,7 @@ declare interface ContextModuleOptions {
2375
2375
  include?: RegExp;
2376
2376
  exclude?: RegExp;
2377
2377
  groupOptions?: RawChunkGroupOptions;
2378
+ typePrefix?: string;
2378
2379
  category?: string;
2379
2380
 
2380
2381
  /**