webpack 5.107.0 → 5.107.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.
Files changed (47) hide show
  1. package/lib/BannerPlugin.js +3 -4
  2. package/lib/Chunk.js +21 -25
  3. package/lib/ChunkGroup.js +57 -15
  4. package/lib/Compilation.js +33 -11
  5. package/lib/EvalSourceMapDevToolPlugin.js +0 -1
  6. package/lib/ExportsInfo.js +30 -34
  7. package/lib/ExternalModule.js +15 -11
  8. package/lib/ExternalModuleFactoryPlugin.js +2 -1
  9. package/lib/Module.js +1 -1
  10. package/lib/ModuleNotFoundError.js +10 -0
  11. package/lib/ModuleSourceTypeConstants.js +24 -22
  12. package/lib/NormalModule.js +106 -46
  13. package/lib/NormalModuleFactory.js +38 -26
  14. package/lib/RuntimePlugin.js +1 -1
  15. package/lib/SourceMapDevToolPlugin.js +250 -49
  16. package/lib/Template.js +1 -1
  17. package/lib/TemplatedPathPlugin.js +22 -4
  18. package/lib/asset/AssetBytesGenerator.js +6 -6
  19. package/lib/asset/AssetGenerator.js +14 -14
  20. package/lib/asset/AssetModulesPlugin.js +3 -7
  21. package/lib/asset/AssetSourceGenerator.js +6 -6
  22. package/lib/css/CssModulesPlugin.js +2 -2
  23. package/lib/dependencies/CommonJsImportsParserPlugin.js +108 -1
  24. package/lib/dependencies/CssUrlDependency.js +3 -2
  25. package/lib/dependencies/HarmonyDetectionParserPlugin.js +21 -1
  26. package/lib/dependencies/HtmlScriptSrcDependency.js +264 -25
  27. package/lib/dependencies/HtmlSourceDependency.js +3 -2
  28. package/lib/html/HtmlModulesPlugin.js +1 -5
  29. package/lib/html/walkHtmlTokens.js +641 -125
  30. package/lib/index.js +2 -0
  31. package/lib/javascript/JavascriptModulesPlugin.js +2 -2
  32. package/lib/optimize/SideEffectsFlagPlugin.js +1 -2
  33. package/lib/optimize/SplitChunksPlugin.js +4 -4
  34. package/lib/runtime/AutoPublicPathRuntimeModule.js +3 -3
  35. package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -5
  36. package/lib/sharing/ConsumeSharedPlugin.js +2 -8
  37. package/lib/sharing/ProvideSharedPlugin.js +4 -4
  38. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -2
  39. package/package.json +3 -3
  40. package/schemas/WebpackOptions.check.js +1 -1
  41. package/schemas/WebpackOptions.json +11 -9
  42. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  43. package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
  44. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  45. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  46. package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
  47. package/types.d.ts +355 -144
@@ -13,10 +13,9 @@ const Template = require("./Template");
13
13
  /** @typedef {import("webpack-sources").Source} Source */
14
14
  /** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginArgument} BannerPluginArgument */
15
15
  /** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginOptions} BannerPluginOptions */
16
- /** @typedef {import("./Compilation").PathData} PathData */
16
+ /** @typedef {import("./Compilation").PathDataChunk} PathDataChunk */
17
17
  /** @typedef {import("./Compiler")} Compiler */
18
18
  /** @typedef {import("./Chunk")} Chunk */
19
- /** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
20
19
 
21
20
  /** @typedef {(data: { hash?: string, chunk: Chunk, filename: string }) => string} BannerFunction */
22
21
 
@@ -117,11 +116,11 @@ class BannerPlugin {
117
116
  continue;
118
117
  }
119
118
 
120
- /** @type {PathData} */
119
+ /** @type {PathDataChunk} */
121
120
  const data = { chunk, filename: file };
122
121
 
123
122
  const comment = compilation.getPath(
124
- /** @type {TemplatePath} */
123
+ /** @type {string | import("./TemplatedPathPlugin").TemplatePathFn<PathDataChunk>} */
125
124
  (banner),
126
125
  data
127
126
  );
package/lib/Chunk.js CHANGED
@@ -26,7 +26,9 @@ const { mergeRuntime } = require("./util/runtime");
26
26
  /** @typedef {import("./ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */
27
27
  /** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
28
28
  /** @typedef {import("./Module")} Module */
29
- /** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
29
+ /** @typedef {import("./Compilation").PathDataChunk} PathDataChunk */
30
+ /** @typedef {import("./TemplatedPathPlugin").TemplatePathFn<PathDataChunk>} ChunkFilenameTemplateFn */
31
+ /** @typedef {string | ChunkFilenameTemplateFn} ChunkFilenameTemplate */
30
32
  /** @typedef {import("./util/Hash")} Hash */
31
33
  /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
32
34
 
@@ -98,9 +100,9 @@ class Chunk {
98
100
  this.idNameHints = new SortableSet();
99
101
  /** @type {boolean} */
100
102
  this.preventIntegration = false;
101
- /** @type {TemplatePath | undefined} */
103
+ /** @type {ChunkFilenameTemplate | undefined} */
102
104
  this.filenameTemplate = undefined;
103
- /** @type {TemplatePath | undefined} */
105
+ /** @type {ChunkFilenameTemplate | undefined} */
104
106
  this.cssFilenameTemplate = undefined;
105
107
  /**
106
108
  * @private
@@ -792,26 +794,21 @@ class Chunk {
792
794
  for (const group of this.groupsIterable) {
793
795
  if (group.chunks[group.chunks.length - 1] === this) {
794
796
  for (const childGroup of group.childrenIterable) {
795
- for (const key of Object.keys(childGroup.options)) {
796
- if (key.endsWith("Order")) {
797
- const name = key.slice(0, key.length - "Order".length);
798
- let list = lists.get(name);
799
- if (list === undefined) {
800
- list = [];
801
- lists.set(name, list);
802
- }
803
- list.push({
804
- order:
805
- /** @type {number} */
806
- (
807
- childGroup.options[
808
- /** @type {keyof ChunkGroupOptions} */
809
- (key)
810
- ]
811
- ),
812
- group: childGroup
813
- });
797
+ const edgeOptions = group.getChildOrderOptions(
798
+ childGroup,
799
+ chunkGraph
800
+ );
801
+ for (const key of Object.keys(edgeOptions)) {
802
+ const name = key.slice(0, key.length - "Order".length);
803
+ let list = lists.get(name);
804
+ if (list === undefined) {
805
+ list = [];
806
+ lists.set(name, list);
814
807
  }
808
+ list.push({
809
+ order: edgeOptions[key],
810
+ group: childGroup
811
+ });
815
812
  }
816
813
  }
817
814
  }
@@ -850,9 +847,8 @@ class Chunk {
850
847
  const list = [];
851
848
  for (const group of this.groupsIterable) {
852
849
  for (const childGroup of group.childrenIterable) {
853
- const order =
854
- /** @type {number} */
855
- (childGroup.options[/** @type {keyof ChunkGroupOptions} */ (type)]);
850
+ const edgeOptions = group.getChildOrderOptions(childGroup, chunkGraph);
851
+ const order = edgeOptions[type];
856
852
  if (order === undefined) continue;
857
853
  list.push({
858
854
  order,
package/lib/ChunkGroup.js CHANGED
@@ -544,6 +544,53 @@ class ChunkGroup {
544
544
  );
545
545
  }
546
546
 
547
+ /**
548
+ * Aggregates per-block `*Order` options for the blocks that bridge this
549
+ * chunk group to the given child chunk group. `*Order` options are tied to
550
+ * the originating `import()` call and must not be sourced from the child's
551
+ * shared options, otherwise a webpackPrefetch/Preload directive from one
552
+ * parent would leak into other parents that share the child by name.
553
+ * @param {ChunkGroup} childGroup the child chunk group
554
+ * @param {ChunkGraph} chunkGraph the chunk graph
555
+ * @returns {Record<string, number>} merged `*Order` options for the edge from this group to `childGroup`
556
+ */
557
+ getChildOrderOptions(childGroup, chunkGraph) {
558
+ /** @type {Record<string, number>} */
559
+ const result = Object.create(null);
560
+ let bridged = false;
561
+ for (const block of childGroup.blocksIterable) {
562
+ const rootModule = /** @type {Module} */ (block.getRootBlock());
563
+ if (!chunkGraph.isModuleInChunkGroup(rootModule, this)) continue;
564
+ bridged = true;
565
+ const opts = block.groupOptions;
566
+ if (!opts) continue;
567
+ for (const key of Object.keys(opts)) {
568
+ if (!key.endsWith("Order")) continue;
569
+ const value =
570
+ /** @type {number} */
571
+ (opts[/** @type {keyof ChunkGroupOptions} */ (key)]);
572
+ if (typeof value !== "number") continue;
573
+ if (result[key] === undefined || value > result[key]) {
574
+ result[key] = value;
575
+ }
576
+ }
577
+ }
578
+ // Fall back to the child's own options only when no block bridges
579
+ // this edge (e.g. a chunk group created by APIs that don't go through
580
+ // an AsyncDependenciesBlock). Otherwise we'd reintroduce the leak.
581
+ if (!bridged) {
582
+ for (const key of Object.keys(childGroup.options)) {
583
+ if (!key.endsWith("Order")) continue;
584
+ const value =
585
+ childGroup.options[/** @type {keyof ChunkGroupOptions} */ (key)];
586
+ if (typeof value === "number") {
587
+ result[key] = value;
588
+ }
589
+ }
590
+ }
591
+ return result;
592
+ }
593
+
547
594
  /**
548
595
  * Groups child chunk groups by their `*Order` options and sorts each group
549
596
  * by descending order and deterministic chunk-group comparison.
@@ -555,22 +602,17 @@ class ChunkGroup {
555
602
  /** @type {Map<string, { order: number, group: ChunkGroup }[]>} */
556
603
  const lists = new Map();
557
604
  for (const childGroup of this._children) {
558
- for (const key of Object.keys(childGroup.options)) {
559
- if (key.endsWith("Order")) {
560
- const name = key.slice(0, key.length - "Order".length);
561
- let list = lists.get(name);
562
- if (list === undefined) {
563
- lists.set(name, (list = []));
564
- }
565
- list.push({
566
- order:
567
- /** @type {number} */
568
- (
569
- childGroup.options[/** @type {keyof ChunkGroupOptions} */ (key)]
570
- ),
571
- group: childGroup
572
- });
605
+ const edgeOptions = this.getChildOrderOptions(childGroup, chunkGraph);
606
+ for (const key of Object.keys(edgeOptions)) {
607
+ const name = key.slice(0, key.length - "Order".length);
608
+ let list = lists.get(name);
609
+ if (list === undefined) {
610
+ lists.set(name, (list = []));
573
611
  }
612
+ list.push({
613
+ order: edgeOptions[key],
614
+ group: childGroup
615
+ });
574
616
  }
575
617
  }
576
618
  /** @type {Record<string, ChunkGroup[]>} */
@@ -372,6 +372,24 @@ const { isSourceEqual } = require("./util/source");
372
372
  * @property {PrepareIdFunction=} prepareId
373
373
  */
374
374
 
375
+ /**
376
+ * Path data narrowed for the chunk filename / chunk asset interpolation context,
377
+ * where `chunk` is always provided. Use as the type parameter to `TemplatePathFn`
378
+ * for callbacks that receive a chunk context (for example `output.filename`,
379
+ * `output.chunkFilename`, `output.cssFilename`, `output.cssChunkFilename`,
380
+ * `optimization.splitChunks.cacheGroups[*].filename`).
381
+ * @typedef {PathData & { chunk: Chunk | ChunkPathData }} PathDataChunk
382
+ */
383
+
384
+ /**
385
+ * Path data narrowed for the module asset interpolation context, where `module`
386
+ * and `chunkGraph` are always provided. Use as the type parameter to
387
+ * `TemplatePathFn` for callbacks that receive a module context (for example
388
+ * `output.assetModuleFilename`, the per-module `generator.filename` /
389
+ * `generator.outputPath`, and `module.parser.css.localIdentName`).
390
+ * @typedef {PathData & { module: Module | ModulePathData, chunkGraph: ChunkGraph }} PathDataModule
391
+ */
392
+
375
393
  /** @typedef {"module" | "chunk" | "root-of-chunk" | "nested"} ExcludeModulesType */
376
394
 
377
395
  /**
@@ -5239,7 +5257,7 @@ This prevents using hashes of each other and should be avoided.`);
5239
5257
  );
5240
5258
 
5241
5259
  assetCacheItem.get((err, sourceFromCache) => {
5242
- /** @type {TemplatePath} */
5260
+ /** @type {string | import("./TemplatedPathPlugin").TemplatePathFn<EXPECTED_ANY>} */
5243
5261
  let filenameTemplate;
5244
5262
  /** @type {string} */
5245
5263
  let file;
@@ -5357,11 +5375,12 @@ This prevents using hashes of each other and should be avoided.`);
5357
5375
 
5358
5376
  /**
5359
5377
  * Returns interpolated path.
5360
- * @param {TemplatePath} filename used to get asset path with hash
5361
- * @param {PathData} data context data
5378
+ * @template {PathData} [T=PathData]
5379
+ * @param {string | import("./TemplatedPathPlugin").TemplatePathFn<T>} filename used to get asset path with hash
5380
+ * @param {T=} data context data
5362
5381
  * @returns {string} interpolated path
5363
5382
  */
5364
- getPath(filename, data = {}) {
5383
+ getPath(filename, data = /** @type {T} */ ({})) {
5365
5384
  if (!data.hash) {
5366
5385
  data = {
5367
5386
  hash: this.hash,
@@ -5373,11 +5392,12 @@ This prevents using hashes of each other and should be avoided.`);
5373
5392
 
5374
5393
  /**
5375
5394
  * Gets path with info.
5376
- * @param {TemplatePath} filename used to get asset path with hash
5377
- * @param {PathData} data context data
5395
+ * @template {PathData} [T=PathData]
5396
+ * @param {string | import("./TemplatedPathPlugin").TemplatePathFn<T>} filename used to get asset path with hash
5397
+ * @param {T=} data context data
5378
5398
  * @returns {InterpolatedPathAndAssetInfo} interpolated path and asset info
5379
5399
  */
5380
- getPathWithInfo(filename, data = {}) {
5400
+ getPathWithInfo(filename, data = /** @type {T} */ ({})) {
5381
5401
  if (!data.hash) {
5382
5402
  data = {
5383
5403
  hash: this.hash,
@@ -5389,8 +5409,9 @@ This prevents using hashes of each other and should be avoided.`);
5389
5409
 
5390
5410
  /**
5391
5411
  * Returns interpolated path.
5392
- * @param {TemplatePath} filename used to get asset path with hash
5393
- * @param {PathData} data context data
5412
+ * @template {PathData} [T=PathData]
5413
+ * @param {string | import("./TemplatedPathPlugin").TemplatePathFn<T>} filename used to get asset path with hash
5414
+ * @param {T} data context data
5394
5415
  * @returns {string} interpolated path
5395
5416
  */
5396
5417
  getAssetPath(filename, data) {
@@ -5403,8 +5424,9 @@ This prevents using hashes of each other and should be avoided.`);
5403
5424
 
5404
5425
  /**
5405
5426
  * Gets asset path with info.
5406
- * @param {TemplatePath} filename used to get asset path with hash
5407
- * @param {PathData} data context data
5427
+ * @template {PathData} [T=PathData]
5428
+ * @param {string | import("./TemplatedPathPlugin").TemplatePathFn<T>} filename used to get asset path with hash
5429
+ * @param {T} data context data
5408
5430
  * @returns {InterpolatedPathAndAssetInfo} interpolated path and asset info
5409
5431
  */
5410
5432
  getAssetPathWithInfo(filename, data) {
@@ -23,7 +23,6 @@ const { makePathsAbsolute } = require("./util/identifier");
23
23
  /** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").Rules} Rules */
24
24
  /** @typedef {import("./Compiler")} Compiler */
25
25
  /** @typedef {import("./ChunkGraph").ModuleId} ModuleId */
26
- /** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
27
26
 
28
27
  /** @type {WeakMap<Source, Source>} */
29
28
  const cache = new WeakMap();
@@ -114,6 +114,21 @@ class ExportsInfo {
114
114
  constructor() {
115
115
  /** @type {Exports} */
116
116
  this._exports = new Map();
117
+
118
+ // `_otherExportsInfo` is a fallback entry for unlisted exports. Two roles:
119
+ // 1. factory template — `getExportInfo` creates `new ExportInfo(name, this)`,
120
+ // so created export info extends its properties.
121
+ // 2. flags whether the whole exportsInfo can be statically analyzed.
122
+ // Its `used` reachable values:
123
+ // - NoInfo: no use analysis yet (`optimization#usedExports` off), or used without info
124
+ // - Unused: analyzed, no unlisted export needed
125
+ // - Unknown: used in unknown way
126
+ // - Used/OnlyPropertiesUsed: never reached
127
+ // Its `provided` reachable values:
128
+ // - undefined: provision not determined yet
129
+ // - false: determined, no unlisted export is provided
130
+ // - null: only runtime knows (dynamic/unknown exports)
131
+ // - true: never reached
117
132
  /** @type {ExportInfo} */
118
133
  this._otherExportsInfo = new ExportInfo(null);
119
134
  /** @type {ExportInfo} */
@@ -239,22 +254,12 @@ class ExportsInfo {
239
254
 
240
255
  setHasProvideInfo() {
241
256
  for (const exportInfo of this._exports.values()) {
242
- if (exportInfo.provided === undefined) {
243
- exportInfo.provided = false;
244
- }
245
- if (exportInfo.canMangleProvide === undefined) {
246
- exportInfo.canMangleProvide = true;
247
- }
257
+ exportInfo.setHasProvideInfo();
248
258
  }
249
259
  if (this._redirectTo !== undefined) {
250
260
  this._redirectTo.setHasProvideInfo();
251
261
  } else {
252
- if (this._otherExportsInfo.provided === undefined) {
253
- this._otherExportsInfo.provided = false;
254
- }
255
- if (this._otherExportsInfo.canMangleProvide === undefined) {
256
- this._otherExportsInfo.canMangleProvide = true;
257
- }
262
+ this._otherExportsInfo.setHasProvideInfo();
258
263
  }
259
264
  }
260
265
 
@@ -436,20 +441,8 @@ class ExportsInfo {
436
441
  if (this._redirectTo.setUsedInUnknownWay(runtime)) {
437
442
  changed = true;
438
443
  }
439
- } else {
440
- if (
441
- this._otherExportsInfo.setUsedConditionally(
442
- (used) => used < UsageState.Unknown,
443
- UsageState.Unknown,
444
- runtime
445
- )
446
- ) {
447
- changed = true;
448
- }
449
- if (this._otherExportsInfo.canMangleUse !== false) {
450
- this._otherExportsInfo.canMangleUse = false;
451
- changed = true;
452
- }
444
+ } else if (this._otherExportsInfo.setUsedInUnknownWay(runtime)) {
445
+ changed = true;
453
446
  }
454
447
  return changed;
455
448
  }
@@ -470,14 +463,8 @@ class ExportsInfo {
470
463
  if (this._redirectTo.setUsedWithoutInfo(runtime)) {
471
464
  changed = true;
472
465
  }
473
- } else {
474
- if (this._otherExportsInfo.setUsed(UsageState.NoInfo, runtime)) {
475
- changed = true;
476
- }
477
- if (this._otherExportsInfo.canMangleUse !== false) {
478
- this._otherExportsInfo.canMangleUse = false;
479
- changed = true;
480
- }
466
+ } else if (this._otherExportsInfo.setUsedWithoutInfo(runtime)) {
467
+ changed = true;
481
468
  }
482
469
  return changed;
483
470
  }
@@ -1030,6 +1017,15 @@ class ExportInfo {
1030
1017
  return changed;
1031
1018
  }
1032
1019
 
1020
+ setHasProvideInfo() {
1021
+ if (this.provided === undefined) {
1022
+ this.provided = false;
1023
+ }
1024
+ if (this.canMangleProvide === undefined) {
1025
+ this.canMangleProvide = true;
1026
+ }
1027
+ }
1028
+
1033
1029
  setHasUseInfo() {
1034
1030
  if (!this._hasUseInRuntimeInfo) {
1035
1031
  this._hasUseInRuntimeInfo = true;
@@ -12,8 +12,9 @@ const { UsageState } = require("./ExportsInfo");
12
12
  const InitFragment = require("./InitFragment");
13
13
  const Module = require("./Module");
14
14
  const {
15
+ ASSET_URL_TYPE,
16
+ ASSET_URL_TYPES,
15
17
  CSS_IMPORT_TYPES,
16
- CSS_URL_TYPES,
17
18
  JAVASCRIPT_TYPE,
18
19
  JAVASCRIPT_TYPES
19
20
  } = require("./ModuleSourceTypeConstants");
@@ -72,7 +73,7 @@ const { register } = require("./util/serialization");
72
73
 
73
74
  /** @typedef {{ attributes?: ImportAttributes, phase?: ImportPhaseType, externalType: "import" | "module" | undefined }} ImportDependencyMeta */
74
75
  /** @typedef {{ layer?: string, supports?: string, media?: string }} CssImportDependencyMeta */
75
- /** @typedef {{ sourceType: "css-url" }} AssetDependencyMeta */
76
+ /** @typedef {{ sourceType: "asset-url" | "css-url" }} AssetDependencyMeta */
76
77
 
77
78
  /** @typedef {ImportDependencyMeta | CssImportDependencyMeta | AssetDependencyMeta} DependencyMeta */
78
79
 
@@ -736,13 +737,14 @@ class ExternalModule extends Module {
736
737
  * @returns {SourceTypes} types available (do not mutate)
737
738
  */
738
739
  getSourceTypes() {
739
- if (
740
- this.externalType === "asset" &&
741
- this.dependencyMeta &&
742
- /** @type {AssetDependencyMeta} */
743
- (this.dependencyMeta).sourceType === "css-url"
744
- ) {
745
- return CSS_URL_TYPES;
740
+ if (this.externalType === "asset" && this.dependencyMeta) {
741
+ const sourceType =
742
+ /** @type {AssetDependencyMeta} */
743
+ (this.dependencyMeta).sourceType;
744
+ // TODO webpack 6 drop "css-url" once the alias is removed
745
+ if (sourceType === ASSET_URL_TYPE || sourceType === "css-url") {
746
+ return ASSET_URL_TYPES;
747
+ }
746
748
  } else if (this.externalType === "css-import") {
747
749
  return CSS_IMPORT_TYPES;
748
750
  }
@@ -1113,12 +1115,14 @@ class ExternalModule extends Module {
1113
1115
  data.set("url", { javascript: /** @type {string} */ (request) });
1114
1116
  return { sources, runtimeRequirements: RUNTIME_REQUIREMENTS, data };
1115
1117
  }
1116
- case "css-url": {
1118
+ // TODO webpack 6 remove "css-url" alias
1119
+ case "css-url":
1120
+ case "asset-url": {
1117
1121
  /** @type {Sources} */
1118
1122
  const sources = new Map();
1119
1123
  /** @type {CodeGenerationResultData} */
1120
1124
  const data = new Map();
1121
- data.set("url", { "css-url": /** @type {string} */ (request) });
1125
+ data.set("url", { [ASSET_URL_TYPE]: /** @type {string} */ (request) });
1122
1126
  return { sources, runtimeRequirements: RUNTIME_REQUIREMENTS, data };
1123
1127
  }
1124
1128
  case "css-import": {
@@ -7,6 +7,7 @@
7
7
 
8
8
  const util = require("util");
9
9
  const ExternalModule = require("./ExternalModule");
10
+ const { ASSET_URL_TYPE } = require("./ModuleSourceTypeConstants");
10
11
  const ContextElementDependency = require("./dependencies/ContextElementDependency");
11
12
  const CssImportDependency = require("./dependencies/CssImportDependency");
12
13
  const CssUrlDependency = require("./dependencies/CssUrlDependency");
@@ -212,7 +213,7 @@ class ExternalModuleFactoryPlugin {
212
213
  resolvedType === "asset" &&
213
214
  dependency instanceof CssUrlDependency
214
215
  ) {
215
- dependencyMeta = { sourceType: "css-url" };
216
+ dependencyMeta = { sourceType: ASSET_URL_TYPE };
216
217
  }
217
218
 
218
219
  callback(
package/lib/Module.js CHANGED
@@ -119,7 +119,7 @@ const makeSerializable = require("./util/makeSerializable");
119
119
  * @typedef {object} AllCodeGenerationSchemas
120
120
  * @property {Set<string>} topLevelDeclarations top level declarations for javascript modules
121
121
  * @property {InitFragment<EXPECTED_ANY>[]} chunkInitFragments chunk init fragments for javascript modules
122
- * @property {{ javascript?: string, ["css-url"]?: string }} url url for css and javascript modules
122
+ * @property {{ javascript?: string, ["asset-url"]?: string }} url url for asset modules
123
123
  * @property {string} filename a filename for asset modules
124
124
  * @property {AssetInfo} assetInfo an asset info for asset modules
125
125
  * @property {string} fullContentHash a full content hash for asset modules
@@ -0,0 +1,10 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Tobias Koppers @sokra
4
+ */
5
+
6
+ "use strict";
7
+
8
+ // TODO remove in webpack 6
9
+ // Some old plugins use `require("webpack/lib/ModuleNotFoundError")`, in webpack@6 developer should migrate to `compiler.webpack.ModuleNotFoundError`
10
+ module.exports = require("./errors/ModuleNotFoundError");
@@ -25,6 +25,11 @@ const WEBASSEMBLY_TYPE = "webassembly";
25
25
  */
26
26
  const ASSET_TYPE = "asset";
27
27
 
28
+ /**
29
+ * @type {Readonly<"asset-url">}
30
+ */
31
+ const ASSET_URL_TYPE = "asset-url";
32
+
28
33
  /**
29
34
  * @type {Readonly<"css">}
30
35
  */
@@ -35,11 +40,6 @@ const CSS_TYPE = "css";
35
40
  */
36
41
  const CSS_IMPORT_TYPE = "css-import";
37
42
 
38
- /**
39
- * @type {Readonly<"css-url">}
40
- */
41
- const CSS_URL_TYPE = "css-url";
42
-
43
43
  /**
44
44
  * @type {Readonly<"css-text">}
45
45
  */
@@ -72,7 +72,7 @@ const UNKNOWN_TYPE = "unknown";
72
72
 
73
73
  /**
74
74
  * Defines the all types type used by this module.
75
- * @typedef {JAVASCRIPT_TYPE | RUNTIME_TYPE | WEBASSEMBLY_TYPE | ASSET_TYPE | CSS_TYPE | CSS_IMPORT_TYPE | CSS_URL_TYPE | CSS_TEXT_TYPE | HTML_TYPE | SHARED_INIT_TYPE | REMOTE_GENERATOR_TYPE | CONSUME_SHARED_GENERATOR_TYPE | UNKNOWN_TYPE} AllTypes
75
+ * @typedef {JAVASCRIPT_TYPE | RUNTIME_TYPE | WEBASSEMBLY_TYPE | ASSET_TYPE | ASSET_URL_TYPE | CSS_TYPE | CSS_IMPORT_TYPE | CSS_TEXT_TYPE | HTML_TYPE | SHARED_INIT_TYPE | REMOTE_GENERATOR_TYPE | CONSUME_SHARED_GENERATOR_TYPE | UNKNOWN_TYPE} AllTypes
76
76
  */
77
77
 
78
78
  /**
@@ -91,17 +91,17 @@ const ASSET_TYPES = new Set([ASSET_TYPE]);
91
91
  const ASSET_AND_JAVASCRIPT_TYPES = new Set([ASSET_TYPE, JAVASCRIPT_TYPE]);
92
92
 
93
93
  /**
94
- * @type {ReadonlySet<"css-url" | "asset">}
94
+ * @type {ReadonlySet<"asset-url" | "asset">}
95
95
  */
96
- const ASSET_AND_CSS_URL_TYPES = new Set([ASSET_TYPE, CSS_URL_TYPE]);
96
+ const ASSET_AND_ASSET_URL_TYPES = new Set([ASSET_TYPE, ASSET_URL_TYPE]);
97
97
 
98
98
  /**
99
- * @type {ReadonlySet<"javascript" | "css-url" | "asset">}
99
+ * @type {ReadonlySet<"javascript" | "asset-url" | "asset">}
100
100
  */
101
- const ASSET_AND_JAVASCRIPT_AND_CSS_URL_TYPES = new Set([
101
+ const ASSET_AND_JAVASCRIPT_AND_ASSET_URL_TYPES = new Set([
102
102
  ASSET_TYPE,
103
103
  JAVASCRIPT_TYPE,
104
- CSS_URL_TYPE
104
+ ASSET_URL_TYPE
105
105
  ]);
106
106
 
107
107
  /**
@@ -110,9 +110,12 @@ const ASSET_AND_JAVASCRIPT_AND_CSS_URL_TYPES = new Set([
110
110
  const JAVASCRIPT_TYPES = new Set([JAVASCRIPT_TYPE]);
111
111
 
112
112
  /**
113
- * @type {ReadonlySet<"javascript" | "css-url">}
113
+ * @type {ReadonlySet<"javascript" | "asset-url">}
114
114
  */
115
- const JAVASCRIPT_AND_CSS_URL_TYPES = new Set([JAVASCRIPT_TYPE, CSS_URL_TYPE]);
115
+ const JAVASCRIPT_AND_ASSET_URL_TYPES = new Set([
116
+ JAVASCRIPT_TYPE,
117
+ ASSET_URL_TYPE
118
+ ]);
116
119
 
117
120
  /**
118
121
  * @type {ReadonlySet<"javascript" | "css">}
@@ -125,9 +128,9 @@ const JAVASCRIPT_AND_CSS_TYPES = new Set([JAVASCRIPT_TYPE, CSS_TYPE]);
125
128
  const CSS_TYPES = new Set([CSS_TYPE]);
126
129
 
127
130
  /**
128
- * @type {ReadonlySet<"css-url">}
131
+ * @type {ReadonlySet<"asset-url">}
129
132
  */
130
- const CSS_URL_TYPES = new Set([CSS_URL_TYPE]);
133
+ const ASSET_URL_TYPES = new Set([ASSET_URL_TYPE]);
131
134
 
132
135
  /**
133
136
  * @type {ReadonlySet<"css-text">}
@@ -176,27 +179,26 @@ const CONSUME_SHARED_TYPES = new Set([CONSUME_SHARED_GENERATOR_TYPE]);
176
179
  */
177
180
  const SHARED_INIT_TYPES = new Set([SHARED_INIT_TYPE]);
178
181
 
179
- module.exports.ASSET_AND_CSS_URL_TYPES = ASSET_AND_CSS_URL_TYPES;
180
- module.exports.ASSET_AND_JAVASCRIPT_AND_CSS_URL_TYPES =
181
- ASSET_AND_JAVASCRIPT_AND_CSS_URL_TYPES;
182
+ module.exports.ASSET_AND_ASSET_URL_TYPES = ASSET_AND_ASSET_URL_TYPES;
183
+ module.exports.ASSET_AND_JAVASCRIPT_AND_ASSET_URL_TYPES =
184
+ ASSET_AND_JAVASCRIPT_AND_ASSET_URL_TYPES;
182
185
  module.exports.ASSET_AND_JAVASCRIPT_TYPES = ASSET_AND_JAVASCRIPT_TYPES;
183
186
  module.exports.ASSET_TYPE = ASSET_TYPE;
184
187
  module.exports.ASSET_TYPES = ASSET_TYPES;
188
+ module.exports.ASSET_URL_TYPE = ASSET_URL_TYPE;
189
+ module.exports.ASSET_URL_TYPES = ASSET_URL_TYPES;
185
190
  module.exports.CONSUME_SHARED_TYPES = CONSUME_SHARED_TYPES;
186
191
  module.exports.CSS_IMPORT_TYPE = CSS_IMPORT_TYPE;
187
192
  module.exports.CSS_IMPORT_TYPES = CSS_IMPORT_TYPES;
188
193
  module.exports.CSS_TEXT_TYPE = CSS_TEXT_TYPE;
189
194
  module.exports.CSS_TEXT_TYPES = CSS_TEXT_TYPES;
190
195
  module.exports.CSS_TYPE = CSS_TYPE;
191
- module.exports.CSS_TYPE = CSS_TYPE;
192
196
  module.exports.CSS_TYPES = CSS_TYPES;
193
- module.exports.CSS_URL_TYPE = CSS_URL_TYPE;
194
- module.exports.CSS_URL_TYPES = CSS_URL_TYPES;
195
197
  module.exports.HTML_TYPE = HTML_TYPE;
196
198
  module.exports.HTML_TYPES = HTML_TYPES;
199
+ module.exports.JAVASCRIPT_AND_ASSET_URL_TYPES = JAVASCRIPT_AND_ASSET_URL_TYPES;
197
200
  module.exports.JAVASCRIPT_AND_CSS_TEXT_TYPES = JAVASCRIPT_AND_CSS_TEXT_TYPES;
198
201
  module.exports.JAVASCRIPT_AND_CSS_TYPES = JAVASCRIPT_AND_CSS_TYPES;
199
- module.exports.JAVASCRIPT_AND_CSS_URL_TYPES = JAVASCRIPT_AND_CSS_URL_TYPES;
200
202
  module.exports.JAVASCRIPT_TYPE = JAVASCRIPT_TYPE;
201
203
  module.exports.JAVASCRIPT_TYPES = JAVASCRIPT_TYPES;
202
204
  module.exports.NO_TYPES = NO_TYPES;