webpack 5.65.0 → 5.66.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 (60) hide show
  1. package/lib/CacheFacade.js +2 -9
  2. package/lib/Chunk.js +2 -0
  3. package/lib/Compilation.js +79 -38
  4. package/lib/Dependency.js +10 -0
  5. package/lib/DependencyTemplate.js +9 -0
  6. package/lib/ExternalModule.js +92 -52
  7. package/lib/Generator.js +2 -0
  8. package/lib/Module.js +24 -1
  9. package/lib/ModuleFilenameHelpers.js +5 -1
  10. package/lib/NormalModule.js +3 -1
  11. package/lib/RuntimeGlobals.js +11 -1
  12. package/lib/RuntimePlugin.js +25 -0
  13. package/lib/RuntimeTemplate.js +21 -0
  14. package/lib/Template.js +2 -1
  15. package/lib/Watching.js +1 -1
  16. package/lib/WebpackOptionsApply.js +43 -2
  17. package/lib/asset/AssetGenerator.js +3 -1
  18. package/lib/asset/RawDataUrlModule.js +145 -0
  19. package/lib/config/defaults.js +59 -3
  20. package/lib/css/CssGenerator.js +106 -0
  21. package/lib/css/CssLoadingRuntimeModule.js +393 -0
  22. package/lib/css/CssModulesPlugin.js +444 -0
  23. package/lib/css/CssParser.js +618 -0
  24. package/lib/css/walkCssTokens.js +659 -0
  25. package/lib/dependencies/CssExportDependency.js +85 -0
  26. package/lib/dependencies/CssImportDependency.js +75 -0
  27. package/lib/dependencies/CssLocalIdentifierDependency.js +119 -0
  28. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +101 -0
  29. package/lib/dependencies/CssUrlDependency.js +132 -0
  30. package/lib/dependencies/URLDependency.js +3 -8
  31. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +1 -1
  32. package/lib/hmr/lazyCompilationBackend.js +3 -1
  33. package/lib/javascript/JavascriptGenerator.js +1 -0
  34. package/lib/javascript/StartupHelpers.js +3 -3
  35. package/lib/library/AssignLibraryPlugin.js +26 -3
  36. package/lib/library/EnableLibraryPlugin.js +11 -0
  37. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +1 -1
  38. package/lib/node/RequireChunkLoadingRuntimeModule.js +1 -1
  39. package/lib/optimize/ConcatenatedModule.js +10 -4
  40. package/lib/util/hash/xxhash64.js +2 -2
  41. package/lib/util/internalSerializables.js +11 -0
  42. package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -2
  43. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  44. package/package.json +2 -2
  45. package/schemas/WebpackOptions.check.js +1 -1
  46. package/schemas/WebpackOptions.json +55 -1
  47. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  48. package/schemas/plugins/container/ContainerPlugin.json +2 -1
  49. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  50. package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
  51. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  52. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  53. package/schemas/plugins/container/ModuleFederationPlugin.json +3 -1
  54. package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +7 -0
  55. package/schemas/plugins/css/CssGeneratorOptions.check.js +6 -0
  56. package/schemas/plugins/css/CssGeneratorOptions.json +3 -0
  57. package/schemas/plugins/css/CssParserOptions.check.d.ts +7 -0
  58. package/schemas/plugins/css/CssParserOptions.check.js +6 -0
  59. package/schemas/plugins/css/CssParserOptions.json +3 -0
  60. package/types.d.ts +86 -2
@@ -5,6 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const { forEachBail } = require("enhanced-resolve");
8
9
  const asyncLib = require("neo-async");
9
10
  const getLazyHashedEtag = require("./cache/getLazyHashedEtag");
10
11
  const mergeEtags = require("./cache/mergeEtags");
@@ -46,15 +47,7 @@ class MultiItemCache {
46
47
  * @returns {void}
47
48
  */
48
49
  get(callback) {
49
- const next = i => {
50
- this._items[i].get((err, result) => {
51
- if (err) return callback(err);
52
- if (result !== undefined) return callback(null, result);
53
- if (++i >= this._items.length) return callback();
54
- next(i);
55
- });
56
- };
57
- next(0);
50
+ forEachBail(this._items, (item, callback) => item.get(callback), callback);
58
51
  }
59
52
 
60
53
  /**
package/lib/Chunk.js CHANGED
@@ -80,6 +80,8 @@ class Chunk {
80
80
  this.preventIntegration = false;
81
81
  /** @type {(string | function(PathData, AssetInfo=): string)?} */
82
82
  this.filenameTemplate = undefined;
83
+ /** @type {(string | function(PathData, AssetInfo=): string)?} */
84
+ this.cssFilenameTemplate = undefined;
83
85
  /** @private @type {SortableSet<ChunkGroup>} */
84
86
  this._groups = new SortableSet(undefined, compareChunkGroupsByIndex);
85
87
  /** @type {RuntimeSpec} */
@@ -3193,47 +3193,87 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3193
3193
  this;
3194
3194
  const results = this.codeGenerationResults;
3195
3195
  const errors = [];
3196
- asyncLib.eachLimit(
3197
- jobs,
3198
- this.options.parallelism,
3199
- ({ module, hash, runtime, runtimes }, callback) => {
3200
- this._codeGenerationModule(
3201
- module,
3202
- runtime,
3203
- runtimes,
3204
- hash,
3205
- dependencyTemplates,
3206
- chunkGraph,
3207
- moduleGraph,
3208
- runtimeTemplate,
3209
- errors,
3210
- results,
3211
- (err, codeGenerated) => {
3212
- if (codeGenerated) statModulesGenerated++;
3213
- else statModulesFromCache++;
3214
- callback(err);
3196
+ /** @type {Set<Module> | undefined} */
3197
+ let notCodeGeneratedModules = undefined;
3198
+ const runIteration = () => {
3199
+ let delayedJobs = [];
3200
+ let delayedModules = new Set();
3201
+ asyncLib.eachLimit(
3202
+ jobs,
3203
+ this.options.parallelism,
3204
+ (job, callback) => {
3205
+ const { module } = job;
3206
+ const { codeGenerationDependencies } = module;
3207
+ if (codeGenerationDependencies !== undefined) {
3208
+ if (
3209
+ notCodeGeneratedModules === undefined ||
3210
+ codeGenerationDependencies.some(dep => {
3211
+ const referencedModule = moduleGraph.getModule(dep);
3212
+ return notCodeGeneratedModules.has(referencedModule);
3213
+ })
3214
+ ) {
3215
+ delayedJobs.push(job);
3216
+ delayedModules.add(module);
3217
+ return callback();
3218
+ }
3215
3219
  }
3216
- );
3217
- },
3218
- err => {
3219
- if (err) return callback(err);
3220
- if (errors.length > 0) {
3221
- errors.sort(
3222
- compareSelect(err => err.module, compareModulesByIdentifier)
3220
+ const { hash, runtime, runtimes } = job;
3221
+ this._codeGenerationModule(
3222
+ module,
3223
+ runtime,
3224
+ runtimes,
3225
+ hash,
3226
+ dependencyTemplates,
3227
+ chunkGraph,
3228
+ moduleGraph,
3229
+ runtimeTemplate,
3230
+ errors,
3231
+ results,
3232
+ (err, codeGenerated) => {
3233
+ if (codeGenerated) statModulesGenerated++;
3234
+ else statModulesFromCache++;
3235
+ callback(err);
3236
+ }
3223
3237
  );
3224
- for (const error of errors) {
3225
- this.errors.push(error);
3238
+ },
3239
+ err => {
3240
+ if (err) return callback(err);
3241
+ if (delayedJobs.length > 0) {
3242
+ if (delayedJobs.length === jobs.length) {
3243
+ return callback(
3244
+ new Error(
3245
+ `Unable to make progress during code generation because of circular code generation dependency: ${Array.from(
3246
+ delayedModules,
3247
+ m => m.identifier()
3248
+ ).join(", ")}`
3249
+ )
3250
+ );
3251
+ }
3252
+ jobs = delayedJobs;
3253
+ delayedJobs = [];
3254
+ notCodeGeneratedModules = delayedModules;
3255
+ delayedModules = new Set();
3256
+ return runIteration();
3226
3257
  }
3258
+ if (errors.length > 0) {
3259
+ errors.sort(
3260
+ compareSelect(err => err.module, compareModulesByIdentifier)
3261
+ );
3262
+ for (const error of errors) {
3263
+ this.errors.push(error);
3264
+ }
3265
+ }
3266
+ this.logger.log(
3267
+ `${Math.round(
3268
+ (100 * statModulesGenerated) /
3269
+ (statModulesGenerated + statModulesFromCache)
3270
+ )}% code generated (${statModulesGenerated} generated, ${statModulesFromCache} from cache)`
3271
+ );
3272
+ callback();
3227
3273
  }
3228
- this.logger.log(
3229
- `${Math.round(
3230
- (100 * statModulesGenerated) /
3231
- (statModulesGenerated + statModulesFromCache)
3232
- )}% code generated (${statModulesGenerated} generated, ${statModulesFromCache} from cache)`
3233
- );
3234
- callback();
3235
- }
3236
- );
3274
+ );
3275
+ };
3276
+ runIteration();
3237
3277
  }
3238
3278
 
3239
3279
  /**
@@ -3283,7 +3323,8 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
3283
3323
  moduleGraph,
3284
3324
  dependencyTemplates,
3285
3325
  runtimeTemplate,
3286
- runtime
3326
+ runtime,
3327
+ codeGenerationResults: results
3287
3328
  });
3288
3329
  } catch (err) {
3289
3330
  errors.push(new CodeGenerationError(module, err));
package/lib/Dependency.js CHANGED
@@ -172,6 +172,16 @@ class Dependency {
172
172
  this._loc = loc;
173
173
  }
174
174
 
175
+ setLoc(startLine, startColumn, endLine, endColumn) {
176
+ this._locSL = startLine;
177
+ this._locSC = startColumn;
178
+ this._locEL = endLine;
179
+ this._locEC = endColumn;
180
+ this._locI = undefined;
181
+ this._locN = undefined;
182
+ this._loc = undefined;
183
+ }
184
+
175
185
  /**
176
186
  * @returns {string | null} an identifier to merge equal requests
177
187
  */
@@ -7,6 +7,7 @@
7
7
 
8
8
  /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
9
9
  /** @typedef {import("./ChunkGraph")} ChunkGraph */
10
+ /** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
10
11
  /** @typedef {import("./ConcatenationScope")} ConcatenationScope */
11
12
  /** @typedef {import("./Dependency")} Dependency */
12
13
  /** @typedef {import("./Dependency").RuntimeSpec} RuntimeSpec */
@@ -28,8 +29,16 @@
28
29
  * @property {RuntimeSpec} runtime current runtimes, for which code is generated
29
30
  * @property {InitFragment<GenerateContext>[]} initFragments mutable array of init fragments for the current module
30
31
  * @property {ConcatenationScope=} concatenationScope when in a concatenated module, information about other concatenated modules
32
+ * @property {CodeGenerationResults} codeGenerationResults the code generation results
31
33
  */
32
34
 
35
+ /**
36
+ * @typedef {Object} CssDependencyTemplateContextExtras
37
+ * @property {Map<string, string>} cssExports the css exports
38
+ */
39
+
40
+ /** @typedef {DependencyTemplateContext & CssDependencyTemplateContextExtras} CssDependencyTemplateContext */
41
+
33
42
  class DependencyTemplate {
34
43
  /* istanbul ignore next */
35
44
  /**
@@ -53,6 +53,7 @@ const { register } = require("./util/serialization");
53
53
  */
54
54
 
55
55
  const TYPES = new Set(["javascript"]);
56
+ const CSS_TYPES = new Set(["css-import"]);
56
57
  const RUNTIME_REQUIREMENTS = new Set([RuntimeGlobals.module]);
57
58
  const RUNTIME_REQUIREMENTS_FOR_SCRIPT = new Set([RuntimeGlobals.loadScript]);
58
59
  const RUNTIME_REQUIREMENTS_FOR_MODULE = new Set([
@@ -392,7 +393,7 @@ class ExternalModule extends Module {
392
393
  * @returns {Set<string>} types available (do not mutate)
393
394
  */
394
395
  getSourceTypes() {
395
- return TYPES;
396
+ return this.externalType === "css-import" ? CSS_TYPES : TYPES;
396
397
  }
397
398
 
398
399
  /**
@@ -409,7 +410,9 @@ class ExternalModule extends Module {
409
410
  * @returns {boolean} true, if the chunk is ok for the module
410
411
  */
411
412
  chunkCondition(chunk, { chunkGraph }) {
412
- return chunkGraph.getNumberOfEntryModules(chunk) > 0;
413
+ return this.externalType === "css-import"
414
+ ? true
415
+ : chunkGraph.getNumberOfEntryModules(chunk) > 0;
413
416
  }
414
417
 
415
418
  /**
@@ -526,8 +529,14 @@ class ExternalModule extends Module {
526
529
  return { request, externalType };
527
530
  }
528
531
 
529
- _getSourceData(runtimeTemplate, moduleGraph, chunkGraph, runtime) {
530
- const { request, externalType } = this._getRequestAndExternalType();
532
+ _getSourceData(
533
+ request,
534
+ externalType,
535
+ runtimeTemplate,
536
+ moduleGraph,
537
+ chunkGraph,
538
+ runtime
539
+ ) {
531
540
  switch (externalType) {
532
541
  case "this":
533
542
  case "window":
@@ -541,6 +550,7 @@ class ExternalModule extends Module {
541
550
  case "commonjs":
542
551
  case "commonjs2":
543
552
  case "commonjs-module":
553
+ case "commonjs-static":
544
554
  return getSourceForCommonJsExternal(request);
545
555
  case "node-commonjs":
546
556
  return this.buildInfo.module
@@ -613,60 +623,90 @@ class ExternalModule extends Module {
613
623
  runtime,
614
624
  concatenationScope
615
625
  }) {
616
- const sourceData = this._getSourceData(
617
- runtimeTemplate,
618
- moduleGraph,
619
- chunkGraph,
620
- runtime
621
- );
626
+ const { request, externalType } = this._getRequestAndExternalType();
627
+ switch (externalType) {
628
+ case "asset": {
629
+ const sources = new Map();
630
+ sources.set(
631
+ "javascript",
632
+ new RawSource(`module.exports = ${JSON.stringify(request)};`)
633
+ );
634
+ const data = new Map();
635
+ data.set("url", request);
636
+ return { sources, runtimeRequirements: RUNTIME_REQUIREMENTS, data };
637
+ }
638
+ case "css-import": {
639
+ const sources = new Map();
640
+ sources.set(
641
+ "css-import",
642
+ new RawSource(`@import url(${JSON.stringify(request)});`)
643
+ );
644
+ return {
645
+ sources,
646
+ runtimeRequirements: EMPTY_RUNTIME_REQUIREMENTS
647
+ };
648
+ }
649
+ default: {
650
+ const sourceData = this._getSourceData(
651
+ request,
652
+ externalType,
653
+ runtimeTemplate,
654
+ moduleGraph,
655
+ chunkGraph,
656
+ runtime
657
+ );
622
658
 
623
- let sourceString = sourceData.expression;
624
- if (sourceData.iife)
625
- sourceString = `(function() { return ${sourceString}; }())`;
626
- if (concatenationScope) {
627
- sourceString = `${runtimeTemplate.supportsConst() ? "const" : "var"} ${
628
- ConcatenationScope.NAMESPACE_OBJECT_EXPORT
629
- } = ${sourceString};`;
630
- concatenationScope.registerNamespaceExport(
631
- ConcatenationScope.NAMESPACE_OBJECT_EXPORT
632
- );
633
- } else {
634
- sourceString = `module.exports = ${sourceString};`;
635
- }
636
- if (sourceData.init) sourceString = `${sourceData.init}\n${sourceString}`;
659
+ let sourceString = sourceData.expression;
660
+ if (sourceData.iife)
661
+ sourceString = `(function() { return ${sourceString}; }())`;
662
+ if (concatenationScope) {
663
+ sourceString = `${
664
+ runtimeTemplate.supportsConst() ? "const" : "var"
665
+ } ${ConcatenationScope.NAMESPACE_OBJECT_EXPORT} = ${sourceString};`;
666
+ concatenationScope.registerNamespaceExport(
667
+ ConcatenationScope.NAMESPACE_OBJECT_EXPORT
668
+ );
669
+ } else {
670
+ sourceString = `module.exports = ${sourceString};`;
671
+ }
672
+ if (sourceData.init)
673
+ sourceString = `${sourceData.init}\n${sourceString}`;
637
674
 
638
- let data = undefined;
639
- if (sourceData.chunkInitFragments) {
640
- data = new Map();
641
- data.set("chunkInitFragments", sourceData.chunkInitFragments);
642
- }
675
+ let data = undefined;
676
+ if (sourceData.chunkInitFragments) {
677
+ data = new Map();
678
+ data.set("chunkInitFragments", sourceData.chunkInitFragments);
679
+ }
643
680
 
644
- const sources = new Map();
645
- if (this.useSourceMap || this.useSimpleSourceMap) {
646
- sources.set(
647
- "javascript",
648
- new OriginalSource(sourceString, this.identifier())
649
- );
650
- } else {
651
- sources.set("javascript", new RawSource(sourceString));
652
- }
681
+ const sources = new Map();
682
+ if (this.useSourceMap || this.useSimpleSourceMap) {
683
+ sources.set(
684
+ "javascript",
685
+ new OriginalSource(sourceString, this.identifier())
686
+ );
687
+ } else {
688
+ sources.set("javascript", new RawSource(sourceString));
689
+ }
690
+
691
+ let runtimeRequirements = sourceData.runtimeRequirements;
692
+ if (!concatenationScope) {
693
+ if (!runtimeRequirements) {
694
+ runtimeRequirements = RUNTIME_REQUIREMENTS;
695
+ } else {
696
+ const set = new Set(runtimeRequirements);
697
+ set.add(RuntimeGlobals.module);
698
+ runtimeRequirements = set;
699
+ }
700
+ }
653
701
 
654
- let runtimeRequirements = sourceData.runtimeRequirements;
655
- if (!concatenationScope) {
656
- if (!runtimeRequirements) {
657
- runtimeRequirements = RUNTIME_REQUIREMENTS;
658
- } else {
659
- const set = new Set(runtimeRequirements);
660
- set.add(RuntimeGlobals.module);
661
- runtimeRequirements = set;
702
+ return {
703
+ sources,
704
+ runtimeRequirements:
705
+ runtimeRequirements || EMPTY_RUNTIME_REQUIREMENTS,
706
+ data
707
+ };
662
708
  }
663
709
  }
664
-
665
- return {
666
- sources,
667
- runtimeRequirements: runtimeRequirements || EMPTY_RUNTIME_REQUIREMENTS,
668
- data
669
- };
670
710
  }
671
711
 
672
712
  /**
package/lib/Generator.js CHANGED
@@ -7,6 +7,7 @@
7
7
 
8
8
  /** @typedef {import("webpack-sources").Source} Source */
9
9
  /** @typedef {import("./ChunkGraph")} ChunkGraph */
10
+ /** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
10
11
  /** @typedef {import("./Compilation")} Compilation */
11
12
  /** @typedef {import("./ConcatenationScope")} ConcatenationScope */
12
13
  /** @typedef {import("./DependencyTemplate")} DependencyTemplate */
@@ -27,6 +28,7 @@
27
28
  * @property {Set<string>} runtimeRequirements the requirements for runtime
28
29
  * @property {RuntimeSpec} runtime the runtime
29
30
  * @property {ConcatenationScope=} concatenationScope when in concatenated module, information about other concatenated modules
31
+ * @property {CodeGenerationResults=} codeGenerationResults code generation results of other modules (need to have a codeGenerationDependency to use that)
30
32
  * @property {string} type which kind of code should be generated
31
33
  * @property {function(): Map<string, any>=} getData get access to the code generation data
32
34
  */
package/lib/Module.js CHANGED
@@ -19,6 +19,7 @@ const makeSerializable = require("./util/makeSerializable");
19
19
  /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
20
20
  /** @typedef {import("./Chunk")} Chunk */
21
21
  /** @typedef {import("./ChunkGroup")} ChunkGroup */
22
+ /** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
22
23
  /** @typedef {import("./Compilation")} Compilation */
23
24
  /** @typedef {import("./ConcatenationScope")} ConcatenationScope */
24
25
  /** @typedef {import("./Dependency")} Dependency */
@@ -56,6 +57,7 @@ const makeSerializable = require("./util/makeSerializable");
56
57
  * @property {ChunkGraph} chunkGraph the chunk graph
57
58
  * @property {RuntimeSpec} runtime the runtimes code should be generated for
58
59
  * @property {ConcatenationScope=} concatenationScope when in concatenated module, information about other concatenated modules
60
+ * @property {CodeGenerationResults} codeGenerationResults code generation results of other modules (need to have a codeGenerationDependency to use that)
59
61
  */
60
62
 
61
63
  /**
@@ -165,6 +167,8 @@ class Module extends DependenciesBlock {
165
167
  this.buildInfo = undefined;
166
168
  /** @type {Dependency[] | undefined} */
167
169
  this.presentationalDependencies = undefined;
170
+ /** @type {Dependency[] | undefined} */
171
+ this.codeGenerationDependencies = undefined;
168
172
  }
169
173
 
170
174
  // TODO remove in webpack 6
@@ -493,6 +497,19 @@ class Module extends DependenciesBlock {
493
497
  this.presentationalDependencies.push(presentationalDependency);
494
498
  }
495
499
 
500
+ /**
501
+ * @param {Dependency} codeGenerationDependency dependency being tied to module.
502
+ * This is a Dependency where the code generation result of the referenced module is needed during code generation.
503
+ * The Dependency should also be added to normal dependencies via addDependency.
504
+ * @returns {void}
505
+ */
506
+ addCodeGenerationDependency(codeGenerationDependency) {
507
+ if (this.codeGenerationDependencies === undefined) {
508
+ this.codeGenerationDependencies = [];
509
+ }
510
+ this.codeGenerationDependencies.push(codeGenerationDependency);
511
+ }
512
+
496
513
  /**
497
514
  * Removes all dependencies and blocks
498
515
  * @returns {void}
@@ -501,6 +518,9 @@ class Module extends DependenciesBlock {
501
518
  if (this.presentationalDependencies !== undefined) {
502
519
  this.presentationalDependencies.length = 0;
503
520
  }
521
+ if (this.codeGenerationDependencies !== undefined) {
522
+ this.codeGenerationDependencies.length = 0;
523
+ }
504
524
  super.clearDependenciesAndBlocks();
505
525
  }
506
526
 
@@ -799,7 +819,8 @@ class Module extends DependenciesBlock {
799
819
  runtimeTemplate,
800
820
  moduleGraph: chunkGraph.moduleGraph,
801
821
  chunkGraph,
802
- runtime: undefined
822
+ runtime: undefined,
823
+ codeGenerationResults: undefined
803
824
  };
804
825
  const sources = this.codeGeneration(codeGenContext).sources;
805
826
  return type ? sources.get(type) : sources.get(first(this.getSourceTypes()));
@@ -976,6 +997,7 @@ class Module extends DependenciesBlock {
976
997
  write(this.buildMeta);
977
998
  write(this.buildInfo);
978
999
  write(this.presentationalDependencies);
1000
+ write(this.codeGenerationDependencies);
979
1001
  super.serialize(context);
980
1002
  }
981
1003
 
@@ -993,6 +1015,7 @@ class Module extends DependenciesBlock {
993
1015
  this.buildMeta = read();
994
1016
  this.buildInfo = read();
995
1017
  this.presentationalDependencies = read();
1018
+ this.codeGenerationDependencies = read();
996
1019
  super.deserialize(context);
997
1020
  }
998
1021
  }
@@ -5,6 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const NormalModule = require("./NormalModule");
8
9
  const createHash = require("./util/createHash");
9
10
  const memoize = require("./util/memoize");
10
11
 
@@ -138,7 +139,10 @@ ModuleFilenameHelpers.createFilename = (
138
139
  );
139
140
  identifier = memoize(() => requestShortener.shorten(module.identifier()));
140
141
  moduleId = () => chunkGraph.getModuleId(module);
141
- absoluteResourcePath = () => module.identifier().split("!").pop();
142
+ absoluteResourcePath = () =>
143
+ module instanceof NormalModule
144
+ ? module.resource
145
+ : module.identifier().split("!").pop();
142
146
  hash = getHash(identifier, hashFunction);
143
147
  }
144
148
  const resource = memoize(() => shortIdentifier().split("!").pop());
@@ -1168,7 +1168,8 @@ class NormalModule extends Module {
1168
1168
  moduleGraph,
1169
1169
  chunkGraph,
1170
1170
  runtime,
1171
- concatenationScope
1171
+ concatenationScope,
1172
+ codeGenerationResults
1172
1173
  }) {
1173
1174
  /** @type {Set<string>} */
1174
1175
  const runtimeRequirements = new Set();
@@ -1200,6 +1201,7 @@ class NormalModule extends Module {
1200
1201
  runtimeRequirements,
1201
1202
  runtime,
1202
1203
  concatenationScope,
1204
+ codeGenerationResults,
1203
1205
  getData,
1204
1206
  type
1205
1207
  });
@@ -164,7 +164,7 @@ exports.scriptNonce = "__webpack_require__.nc";
164
164
  * function to load a script tag.
165
165
  * Arguments: (url: string, done: (event) => void), key?: string | number, chunkId?: string | number) => void
166
166
  * done function is called when loading has finished or timeout occurred.
167
- * It will attach to existing script tags with data-webpack == key or src == url.
167
+ * It will attach to existing script tags with data-webpack == uniqueName + ":" + key or src == url.
168
168
  */
169
169
  exports.loadScript = "__webpack_require__.l";
170
170
 
@@ -190,11 +190,21 @@ exports.runtimeId = "__webpack_require__.j";
190
190
  */
191
191
  exports.getChunkScriptFilename = "__webpack_require__.u";
192
192
 
193
+ /**
194
+ * the filename of the css part of the chunk
195
+ */
196
+ exports.getChunkCssFilename = "__webpack_require__.k";
197
+
193
198
  /**
194
199
  * the filename of the script part of the hot update chunk
195
200
  */
196
201
  exports.getChunkUpdateScriptFilename = "__webpack_require__.hu";
197
202
 
203
+ /**
204
+ * the filename of the css part of the hot update chunk
205
+ */
206
+ exports.getChunkUpdateCssFilename = "__webpack_require__.hk";
207
+
198
208
  /**
199
209
  * startup signal from runtime
200
210
  * This will be called when the runtime chunk has been loaded.
@@ -261,6 +261,31 @@ class RuntimePlugin {
261
261
  );
262
262
  return true;
263
263
  });
264
+ compilation.hooks.runtimeRequirementInTree
265
+ .for(RuntimeGlobals.getChunkCssFilename)
266
+ .tap("RuntimePlugin", (chunk, set) => {
267
+ if (
268
+ typeof compilation.outputOptions.cssChunkFilename === "string" &&
269
+ /\[(full)?hash(:\d+)?\]/.test(
270
+ compilation.outputOptions.cssChunkFilename
271
+ )
272
+ ) {
273
+ set.add(RuntimeGlobals.getFullHash);
274
+ }
275
+ compilation.addRuntimeModule(
276
+ chunk,
277
+ new GetChunkFilenameRuntimeModule(
278
+ "css",
279
+ "css",
280
+ RuntimeGlobals.getChunkCssFilename,
281
+ chunk =>
282
+ chunk.cssFilenameTemplate ||
283
+ compilation.outputOptions.cssChunkFilename,
284
+ false
285
+ )
286
+ );
287
+ return true;
288
+ });
264
289
  compilation.hooks.runtimeRequirementInTree
265
290
  .for(RuntimeGlobals.getChunkUpdateScriptFilename)
266
291
  .tap("RuntimePlugin", (chunk, set) => {
@@ -16,6 +16,7 @@ const { forEachRuntime, subtractRuntime } = require("./util/runtime");
16
16
  /** @typedef {import("../declarations/WebpackOptions").OutputNormalized} OutputOptions */
17
17
  /** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
18
18
  /** @typedef {import("./ChunkGraph")} ChunkGraph */
19
+ /** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
19
20
  /** @typedef {import("./Compilation")} Compilation */
20
21
  /** @typedef {import("./Dependency")} Dependency */
21
22
  /** @typedef {import("./Module")} Module */
@@ -1014,6 +1015,26 @@ class RuntimeTemplate {
1014
1015
  runtimeRequirements.add(RuntimeGlobals.exports);
1015
1016
  return `${RuntimeGlobals.makeNamespaceObject}(${exportsArgument});\n`;
1016
1017
  }
1018
+
1019
+ /**
1020
+ * @param {Object} options options object
1021
+ * @param {Module} options.module the module
1022
+ * @param {string} options.publicPath the public path
1023
+ * @param {RuntimeSpec=} options.runtime runtime
1024
+ * @param {CodeGenerationResults} options.codeGenerationResults the code generation results
1025
+ * @returns {string} the url of the asset
1026
+ */
1027
+ assetUrl({ publicPath, runtime, module, codeGenerationResults }) {
1028
+ if (!module) {
1029
+ return "data:,";
1030
+ }
1031
+ const codeGen = codeGenerationResults.get(module, runtime);
1032
+ const { data } = codeGen;
1033
+ const url = data.get("url");
1034
+ if (url) return url;
1035
+ const filename = data.get("filename");
1036
+ return publicPath + filename;
1037
+ }
1017
1038
  }
1018
1039
 
1019
1040
  module.exports = RuntimeTemplate;
package/lib/Template.js CHANGED
@@ -370,7 +370,8 @@ class Template {
370
370
  dependencyTemplates: renderContext.dependencyTemplates,
371
371
  moduleGraph: renderContext.moduleGraph,
372
372
  runtimeTemplate: renderContext.runtimeTemplate,
373
- runtime: renderContext.chunk.runtime
373
+ runtime: renderContext.chunk.runtime,
374
+ codeGenerationResults
374
375
  });
375
376
  if (!codeGenResult) continue;
376
377
  runtimeSource = codeGenResult.sources.get("runtime");
package/lib/Watching.js CHANGED
@@ -49,7 +49,7 @@ class Watching {
49
49
  this.watchOptions = {};
50
50
  }
51
51
  if (typeof this.watchOptions.aggregateTimeout !== "number") {
52
- this.watchOptions.aggregateTimeout = 200;
52
+ this.watchOptions.aggregateTimeout = 20;
53
53
  }
54
54
  this.compiler = compiler;
55
55
  this.running = false;