webpack 5.81.0 → 5.82.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.

Potentially problematic release.


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

Files changed (62) hide show
  1. package/bin/webpack.js +13 -2
  2. package/lib/Compilation.js +4 -1
  3. package/lib/CssModule.js +39 -7
  4. package/lib/DependenciesBlock.js +8 -0
  5. package/lib/FileSystemInfo.js +1 -1
  6. package/lib/HotModuleReplacementPlugin.js +3 -2
  7. package/lib/Module.js +3 -2
  8. package/lib/ModuleTypeConstants.js +90 -0
  9. package/lib/NormalModule.js +2 -1
  10. package/lib/RuntimeModule.js +4 -3
  11. package/lib/Template.js +2 -1
  12. package/lib/WebpackOptionsApply.js +33 -40
  13. package/lib/asset/AssetGenerator.js +4 -3
  14. package/lib/asset/AssetModulesPlugin.js +21 -11
  15. package/lib/asset/RawDataUrlModule.js +2 -1
  16. package/lib/cache/MemoryWithGcCachePlugin.js +2 -0
  17. package/lib/config/defaults.js +4 -2
  18. package/lib/container/FallbackModule.js +2 -1
  19. package/lib/container/RemoteModule.js +2 -1
  20. package/lib/css/CssGenerator.js +4 -0
  21. package/lib/css/CssLoadingRuntimeModule.js +9 -2
  22. package/lib/css/CssModulesPlugin.js +149 -39
  23. package/lib/css/CssParser.js +443 -319
  24. package/lib/css/walkCssTokens.js +118 -27
  25. package/lib/debug/ProfilingPlugin.js +2 -0
  26. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +1 -0
  27. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +4 -2
  28. package/lib/hmr/LazyCompilationPlugin.js +13 -4
  29. package/lib/javascript/BasicEvaluatedExpression.js +108 -1
  30. package/lib/javascript/JavascriptModulesPlugin.js +3 -2
  31. package/lib/javascript/JavascriptParser.js +132 -11
  32. package/lib/json/JsonData.js +25 -0
  33. package/lib/json/JsonGenerator.js +15 -3
  34. package/lib/json/JsonModulesPlugin.js +1 -0
  35. package/lib/json/JsonParser.js +2 -1
  36. package/lib/library/ModuleLibraryPlugin.js +2 -1
  37. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +3 -1
  38. package/lib/runtime/GetChunkFilenameRuntimeModule.js +4 -0
  39. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +22 -3
  40. package/lib/schemes/DataUriPlugin.js +4 -0
  41. package/lib/schemes/HttpUriPlugin.js +38 -0
  42. package/lib/sharing/ConsumeSharedModule.js +5 -2
  43. package/lib/sharing/ProvideSharedModule.js +2 -1
  44. package/lib/sharing/utils.js +293 -7
  45. package/lib/stats/DefaultStatsFactoryPlugin.js +7 -4
  46. package/lib/stats/DefaultStatsPrinterPlugin.js +25 -0
  47. package/lib/util/StackedCacheMap.js +6 -0
  48. package/lib/util/StringXor.js +51 -0
  49. package/lib/util/compileBooleanMatcher.js +31 -0
  50. package/lib/util/createHash.js +4 -3
  51. package/lib/util/deprecation.js +8 -0
  52. package/lib/util/identifier.js +4 -0
  53. package/lib/util/numberHash.js +75 -21
  54. package/lib/util/propertyAccess.js +5 -0
  55. package/lib/wasm/EnableWasmLoadingPlugin.js +4 -0
  56. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +1 -0
  57. package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
  58. package/lib/web/JsonpChunkLoadingRuntimeModule.js +8 -4
  59. package/package.json +3 -3
  60. package/schemas/WebpackOptions.check.js +1 -1
  61. package/schemas/WebpackOptions.json +25 -0
  62. package/types.d.ts +181 -39
@@ -944,6 +944,24 @@
944
944
  }
945
945
  }
946
946
  },
947
+ "Extends": {
948
+ "description": "Extend configuration from another configuration (only works when using webpack-cli).",
949
+ "anyOf": [
950
+ {
951
+ "type": "array",
952
+ "items": {
953
+ "$ref": "#/definitions/ExtendsItem"
954
+ }
955
+ },
956
+ {
957
+ "$ref": "#/definitions/ExtendsItem"
958
+ }
959
+ ]
960
+ },
961
+ "ExtendsItem": {
962
+ "description": "Path to the configuration to be extended (only works when using webpack-cli).",
963
+ "type": "string"
964
+ },
947
965
  "ExternalItem": {
948
966
  "description": "Specify dependency that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`.",
949
967
  "anyOf": [
@@ -5021,6 +5039,10 @@
5021
5039
  "type": "object",
5022
5040
  "additionalProperties": false,
5023
5041
  "properties": {
5042
+ "onPolicyCreationFailure": {
5043
+ "description": "If the call to `trustedTypes.createPolicy(...)` fails -- e.g., due to the policy name missing from the CSP `trusted-types` list, or it being a duplicate name, etc. -- controls whether to continue with loading in the hope that `require-trusted-types-for 'script'` isn't enforced yet, versus fail immediately. Default behavior is 'stop'.",
5044
+ "enum": ["continue", "stop"]
5045
+ },
5024
5046
  "policyName": {
5025
5047
  "description": "The name of the Trusted Types policy created by webpack to serve bundle chunks.",
5026
5048
  "type": "string",
@@ -5349,6 +5371,9 @@
5349
5371
  "experiments": {
5350
5372
  "$ref": "#/definitions/Experiments"
5351
5373
  },
5374
+ "extends": {
5375
+ "$ref": "#/definitions/Extends"
5376
+ },
5352
5377
  "externals": {
5353
5378
  "$ref": "#/definitions/Externals"
5354
5379
  },
package/types.d.ts CHANGED
@@ -482,9 +482,9 @@ declare abstract class BasicEvaluatedExpression {
482
482
  options?: BasicEvaluatedExpression[];
483
483
  prefix?: BasicEvaluatedExpression;
484
484
  postfix?: BasicEvaluatedExpression;
485
- wrappedInnerExpressions: any;
485
+ wrappedInnerExpressions: BasicEvaluatedExpression[];
486
486
  identifier?: string | VariableInfoInterface;
487
- rootInfo: VariableInfoInterface;
487
+ rootInfo: string | VariableInfoInterface;
488
488
  getMembers: () => string[];
489
489
  getMembersOptionals: () => boolean[];
490
490
  expression: NodeEstreeIndex;
@@ -525,43 +525,116 @@ declare abstract class BasicEvaluatedExpression {
525
525
  * Can this expression have side effects?
526
526
  */
527
527
  couldHaveSideEffects(): boolean;
528
- asBool(): any;
528
+
529
+ /**
530
+ * Creates a boolean representation of this evaluated expression.
531
+ */
532
+ asBool(): undefined | boolean;
533
+
534
+ /**
535
+ * Creates a nullish coalescing representation of this evaluated expression.
536
+ */
529
537
  asNullish(): undefined | boolean;
530
- asString(): any;
538
+
539
+ /**
540
+ * Creates a string representation of this evaluated expression.
541
+ */
542
+ asString(): undefined | string;
531
543
  setString(string?: any): BasicEvaluatedExpression;
532
544
  setUndefined(): BasicEvaluatedExpression;
533
545
  setNull(): BasicEvaluatedExpression;
534
- setNumber(number?: any): BasicEvaluatedExpression;
535
- setBigInt(bigint?: any): BasicEvaluatedExpression;
536
- setBoolean(bool?: any): BasicEvaluatedExpression;
537
- setRegExp(regExp?: any): BasicEvaluatedExpression;
546
+
547
+ /**
548
+ * Set's the value of this expression to a number
549
+ */
550
+ setNumber(number: number): BasicEvaluatedExpression;
551
+
552
+ /**
553
+ * Set's the value of this expression to a BigInt
554
+ */
555
+ setBigInt(bigint: bigint): BasicEvaluatedExpression;
556
+
557
+ /**
558
+ * Set's the value of this expression to a boolean
559
+ */
560
+ setBoolean(bool: boolean): BasicEvaluatedExpression;
561
+
562
+ /**
563
+ * Set's the value of this expression to a regular expression
564
+ */
565
+ setRegExp(regExp: RegExp): BasicEvaluatedExpression;
566
+
567
+ /**
568
+ * Set's the value of this expression to a particular identifier and its members.
569
+ */
538
570
  setIdentifier(
539
- identifier?: any,
540
- rootInfo?: any,
541
- getMembers?: any,
542
- getMembersOptionals?: any
571
+ identifier: string | VariableInfoInterface,
572
+ rootInfo: string | VariableInfoInterface,
573
+ getMembers: () => string[],
574
+ getMembersOptionals?: () => boolean[]
543
575
  ): BasicEvaluatedExpression;
576
+
577
+ /**
578
+ * Wraps an array of expressions with a prefix and postfix expression.
579
+ */
544
580
  setWrapped(
545
- prefix?: any,
546
- postfix?: any,
547
- innerExpressions?: any
581
+ prefix: null | BasicEvaluatedExpression,
582
+ postfix: BasicEvaluatedExpression,
583
+ innerExpressions: BasicEvaluatedExpression[]
548
584
  ): BasicEvaluatedExpression;
549
- setOptions(options?: any): BasicEvaluatedExpression;
550
- addOptions(options?: any): BasicEvaluatedExpression;
551
- setItems(items?: any): BasicEvaluatedExpression;
552
- setArray(array?: any): BasicEvaluatedExpression;
585
+
586
+ /**
587
+ * Stores the options of a conditional expression.
588
+ */
589
+ setOptions(options: BasicEvaluatedExpression[]): BasicEvaluatedExpression;
590
+
591
+ /**
592
+ * Adds options to a conditional expression.
593
+ */
594
+ addOptions(options: BasicEvaluatedExpression[]): BasicEvaluatedExpression;
595
+
596
+ /**
597
+ * Set's the value of this expression to an array of expressions.
598
+ */
599
+ setItems(items: BasicEvaluatedExpression[]): BasicEvaluatedExpression;
600
+
601
+ /**
602
+ * Set's the value of this expression to an array of strings.
603
+ */
604
+ setArray(array: string[]): BasicEvaluatedExpression;
605
+
606
+ /**
607
+ * Set's the value of this expression to a processed/unprocessed template string. Used
608
+ * for evaluating TemplateLiteral expressions in the JavaScript Parser.
609
+ */
553
610
  setTemplateString(
554
- quasis?: any,
555
- parts?: any,
556
- kind?: any
611
+ quasis: BasicEvaluatedExpression[],
612
+ parts: BasicEvaluatedExpression[],
613
+ kind: "raw" | "cooked"
557
614
  ): BasicEvaluatedExpression;
558
- templateStringKind: any;
615
+ templateStringKind?: "raw" | "cooked";
559
616
  setTruthy(): BasicEvaluatedExpression;
560
617
  setFalsy(): BasicEvaluatedExpression;
561
- setNullish(value?: any): BasicEvaluatedExpression;
562
- setRange(range?: any): BasicEvaluatedExpression;
618
+
619
+ /**
620
+ * Set's the value of the expression to nullish.
621
+ */
622
+ setNullish(value: boolean): BasicEvaluatedExpression;
623
+
624
+ /**
625
+ * Set's the range for the expression.
626
+ */
627
+ setRange(range: [number, number]): BasicEvaluatedExpression;
628
+
629
+ /**
630
+ * Set whether or not the expression has side effects.
631
+ */
563
632
  setSideEffects(sideEffects?: boolean): BasicEvaluatedExpression;
564
- setExpression(expression?: any): BasicEvaluatedExpression;
633
+
634
+ /**
635
+ * Set the expression node for the expression.
636
+ */
637
+ setExpression(expression: NodeEstreeIndex): BasicEvaluatedExpression;
565
638
  }
566
639
  type BuildMeta = KnownBuildMeta & Record<string, any>;
567
640
  declare abstract class ByTypeGenerator extends Generator {
@@ -2123,6 +2196,11 @@ declare interface Configuration {
2123
2196
  */
2124
2197
  experiments?: Experiments;
2125
2198
 
2199
+ /**
2200
+ * Extend configuration from another configuration (only works when using webpack-cli).
2201
+ */
2202
+ extends?: string | string[];
2203
+
2126
2204
  /**
2127
2205
  * Specify dependencies that shouldn't be resolved by webpack, but should become dependencies of the resulting bundle. The kind of the dependency depends on `output.libraryTarget`.
2128
2206
  */
@@ -3428,6 +3506,7 @@ declare class EnvironmentPlugin {
3428
3506
  */
3429
3507
  apply(compiler: Compiler): void;
3430
3508
  }
3509
+ type ErrorWithDetail = Error & { details?: string };
3431
3510
  declare interface Etag {
3432
3511
  toString: () => string;
3433
3512
  }
@@ -6793,8 +6872,54 @@ declare interface MinChunkSizePluginOptions {
6793
6872
  minChunkSize: number;
6794
6873
  }
6795
6874
  declare class Module extends DependenciesBlock {
6796
- constructor(type: string, context?: string, layer?: string);
6797
- type: string;
6875
+ constructor(
6876
+ type:
6877
+ | ""
6878
+ | "runtime"
6879
+ | "javascript/auto"
6880
+ | "javascript/dynamic"
6881
+ | "javascript/esm"
6882
+ | "json"
6883
+ | "webassembly/async"
6884
+ | "webassembly/sync"
6885
+ | "css"
6886
+ | "css/global"
6887
+ | "css/module"
6888
+ | "asset"
6889
+ | "asset/inline"
6890
+ | "asset/resource"
6891
+ | "asset/source"
6892
+ | "asset/raw-data-url"
6893
+ | "fallback-module"
6894
+ | "remote-module"
6895
+ | "provide-module"
6896
+ | "consume-shared-module"
6897
+ | "lazy-compilation-proxy",
6898
+ context?: string,
6899
+ layer?: string
6900
+ );
6901
+ type:
6902
+ | ""
6903
+ | "runtime"
6904
+ | "javascript/auto"
6905
+ | "javascript/dynamic"
6906
+ | "javascript/esm"
6907
+ | "json"
6908
+ | "webassembly/async"
6909
+ | "webassembly/sync"
6910
+ | "css"
6911
+ | "css/global"
6912
+ | "css/module"
6913
+ | "asset"
6914
+ | "asset/inline"
6915
+ | "asset/resource"
6916
+ | "asset/source"
6917
+ | "asset/raw-data-url"
6918
+ | "fallback-module"
6919
+ | "remote-module"
6920
+ | "provide-module"
6921
+ | "consume-shared-module"
6922
+ | "lazy-compilation-proxy";
6798
6923
  context: null | string;
6799
6924
  layer: null | string;
6800
6925
  needId: boolean;
@@ -7753,9 +7878,9 @@ declare interface NormalModuleCreateData {
7753
7878
  layer?: string;
7754
7879
 
7755
7880
  /**
7756
- * module type
7881
+ * module type. When deserializing, this is set to an empty string "".
7757
7882
  */
7758
- type: string;
7883
+ type: "" | "javascript/auto" | "javascript/dynamic" | "javascript/esm";
7759
7884
 
7760
7885
  /**
7761
7886
  * request string
@@ -7899,9 +8024,9 @@ declare interface NormalModuleLoaderContext<OptionsType> {
7899
8024
  context: string,
7900
8025
  request: string,
7901
8026
  callback: (
7902
- arg0: null | Error,
7903
- arg1?: string | false,
7904
- arg2?: ResolveRequest
8027
+ err: null | ErrorWithDetail,
8028
+ res?: string | false,
8029
+ req?: ResolveRequest
7905
8030
  ) => void
7906
8031
  ): any;
7907
8032
  getResolve(options?: ResolveOptionsWithDependencyType): {
@@ -7909,9 +8034,9 @@ declare interface NormalModuleLoaderContext<OptionsType> {
7909
8034
  context: string,
7910
8035
  request: string,
7911
8036
  callback: (
7912
- arg0: null | Error,
7913
- arg1?: string | false,
7914
- arg2?: ResolveRequest
8037
+ err: null | ErrorWithDetail,
8038
+ res?: string | false,
8039
+ req?: ResolveRequest
7915
8040
  ) => void
7916
8041
  ): void;
7917
8042
  (context: string, request: string): Promise<string>;
@@ -10010,9 +10135,9 @@ declare abstract class Resolver {
10010
10135
  request: string,
10011
10136
  resolveContext: ResolveContext,
10012
10137
  callback: (
10013
- arg0: null | Error,
10014
- arg1?: string | false,
10015
- arg2?: ResolveRequest
10138
+ err: null | ErrorWithDetail,
10139
+ res?: string | false,
10140
+ req?: ResolveRequest
10016
10141
  ) => void
10017
10142
  ): void;
10018
10143
  doResolve(
@@ -10938,6 +11063,12 @@ declare interface RuntimeValueOptions {
10938
11063
  buildDependencies?: string[];
10939
11064
  version?: string | (() => string);
10940
11065
  }
11066
+
11067
+ /**
11068
+ * Helper function for joining two ranges into a single range. This is useful
11069
+ * when working with AST nodes, as it allows you to combine the ranges of child nodes
11070
+ * to create the range of the _parent node_.
11071
+ */
10941
11072
  declare interface ScopeInfo {
10942
11073
  definitions: StackedMap<string, ScopeInfo | VariableInfo>;
10943
11074
  topLevelScope: boolean | "arrow";
@@ -11975,6 +12106,12 @@ declare interface SyntheticDependencyLocation {
11975
12106
  declare const TOMBSTONE: unique symbol;
11976
12107
  declare const TRANSITIVE: unique symbol;
11977
12108
  declare const TRANSITIVE_ONLY: unique symbol;
12109
+
12110
+ /**
12111
+ * Helper function for joining two ranges into a single range. This is useful
12112
+ * when working with AST nodes, as it allows you to combine the ranges of child nodes
12113
+ * to create the range of the _parent node_.
12114
+ */
11978
12115
  declare interface TagInfo {
11979
12116
  tag: any;
11980
12117
  data: any;
@@ -12026,6 +12163,11 @@ declare class TopLevelSymbol {
12026
12163
  * Use a Trusted Types policy to create urls for chunks.
12027
12164
  */
12028
12165
  declare interface TrustedTypes {
12166
+ /**
12167
+ * If the call to `trustedTypes.createPolicy(...)` fails -- e.g., due to the policy name missing from the CSP `trusted-types` list, or it being a duplicate name, etc. -- controls whether to continue with loading in the hope that `require-trusted-types-for 'script'` isn't enforced yet, versus fail immediately. Default behavior is 'stop'.
12168
+ */
12169
+ onPolicyCreationFailure?: "continue" | "stop";
12170
+
12029
12171
  /**
12030
12172
  * The name of the Trusted Types policy created by webpack to serve bundle chunks.
12031
12173
  */