webpack 5.102.1 → 5.104.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.
Files changed (220) hide show
  1. package/README.md +121 -134
  2. package/hot/dev-server.js +18 -3
  3. package/hot/emitter-event-target.js +7 -0
  4. package/hot/lazy-compilation-node.js +45 -29
  5. package/hot/lazy-compilation-universal.js +18 -0
  6. package/hot/lazy-compilation-web.js +15 -5
  7. package/hot/load-http.js +7 -0
  8. package/hot/only-dev-server.js +19 -4
  9. package/lib/APIPlugin.js +6 -0
  10. package/lib/Chunk.js +1 -1
  11. package/lib/ChunkGraph.js +9 -7
  12. package/lib/ChunkGroup.js +8 -5
  13. package/lib/CleanPlugin.js +6 -3
  14. package/lib/CodeGenerationResults.js +2 -1
  15. package/lib/CompatibilityPlugin.js +28 -2
  16. package/lib/Compilation.js +58 -21
  17. package/lib/Compiler.js +3 -3
  18. package/lib/ConcatenationScope.js +0 -15
  19. package/lib/ContextModule.js +6 -3
  20. package/lib/ContextModuleFactory.js +6 -4
  21. package/lib/CssModule.js +6 -1
  22. package/lib/DefinePlugin.js +45 -14
  23. package/lib/DelegatedModule.js +7 -4
  24. package/lib/Dependency.js +8 -1
  25. package/lib/DependencyTemplate.js +1 -0
  26. package/lib/DllModule.js +6 -3
  27. package/lib/DotenvPlugin.js +462 -0
  28. package/lib/EnvironmentPlugin.js +19 -16
  29. package/lib/EvalSourceMapDevToolPlugin.js +16 -0
  30. package/lib/ExportsInfo.js +6 -2
  31. package/lib/ExternalModule.js +28 -35
  32. package/lib/ExternalModuleFactoryPlugin.js +11 -9
  33. package/lib/ExternalsPlugin.js +2 -1
  34. package/lib/FileSystemInfo.js +1 -1
  35. package/lib/Generator.js +10 -7
  36. package/lib/HookWebpackError.js +33 -4
  37. package/lib/HotModuleReplacementPlugin.js +22 -0
  38. package/lib/ManifestPlugin.js +235 -0
  39. package/lib/Module.js +27 -15
  40. package/lib/ModuleBuildError.js +1 -1
  41. package/lib/ModuleError.js +1 -1
  42. package/lib/ModuleFilenameHelpers.js +1 -1
  43. package/lib/ModuleGraph.js +29 -13
  44. package/lib/ModuleGraphConnection.js +2 -2
  45. package/lib/ModuleSourceTypeConstants.js +189 -0
  46. package/lib/ModuleTypeConstants.js +1 -4
  47. package/lib/ModuleWarning.js +1 -1
  48. package/lib/MultiCompiler.js +1 -1
  49. package/lib/NodeStuffPlugin.js +424 -116
  50. package/lib/NormalModule.js +23 -20
  51. package/lib/NormalModuleFactory.js +7 -10
  52. package/lib/Parser.js +1 -1
  53. package/lib/RawModule.js +7 -4
  54. package/lib/RuntimeGlobals.js +22 -4
  55. package/lib/RuntimeModule.js +1 -1
  56. package/lib/RuntimePlugin.js +27 -6
  57. package/lib/RuntimeTemplate.js +120 -57
  58. package/lib/SourceMapDevToolPlugin.js +26 -1
  59. package/lib/Template.js +17 -6
  60. package/lib/TemplatedPathPlugin.js +5 -6
  61. package/lib/WebpackError.js +0 -1
  62. package/lib/WebpackOptionsApply.js +67 -15
  63. package/lib/asset/AssetBytesGenerator.js +16 -12
  64. package/lib/asset/AssetGenerator.js +31 -26
  65. package/lib/asset/AssetSourceGenerator.js +16 -12
  66. package/lib/asset/RawDataUrlModule.js +6 -3
  67. package/lib/buildChunkGraph.js +4 -2
  68. package/lib/cache/PackFileCacheStrategy.js +6 -5
  69. package/lib/cli.js +2 -43
  70. package/lib/config/browserslistTargetHandler.js +24 -0
  71. package/lib/config/defaults.js +226 -61
  72. package/lib/config/normalization.js +4 -3
  73. package/lib/config/target.js +11 -0
  74. package/lib/container/ContainerEntryModule.js +6 -3
  75. package/lib/container/FallbackModule.js +6 -3
  76. package/lib/container/RemoteModule.js +1 -3
  77. package/lib/css/CssGenerator.js +304 -76
  78. package/lib/css/CssLoadingRuntimeModule.js +14 -4
  79. package/lib/css/CssMergeStyleSheetsRuntimeModule.js +56 -0
  80. package/lib/css/CssModulesPlugin.js +72 -67
  81. package/lib/css/CssParser.js +1726 -732
  82. package/lib/css/walkCssTokens.js +128 -11
  83. package/lib/dependencies/CachedConstDependency.js +24 -10
  84. package/lib/dependencies/CommonJsImportsParserPlugin.js +0 -9
  85. package/lib/dependencies/CommonJsPlugin.js +12 -0
  86. package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
  87. package/lib/dependencies/ContextDependencyHelpers.js +2 -2
  88. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +3 -1
  89. package/lib/dependencies/CssIcssExportDependency.js +389 -12
  90. package/lib/dependencies/CssIcssImportDependency.js +114 -51
  91. package/lib/dependencies/CssIcssSymbolDependency.js +31 -33
  92. package/lib/dependencies/CssImportDependency.js +17 -6
  93. package/lib/dependencies/CssUrlDependency.js +3 -2
  94. package/lib/dependencies/DynamicExports.js +7 -7
  95. package/lib/dependencies/ExternalModuleDependency.js +7 -4
  96. package/lib/dependencies/ExternalModuleInitFragment.js +3 -2
  97. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +96 -0
  98. package/lib/dependencies/HarmonyAcceptDependency.js +6 -1
  99. package/lib/dependencies/HarmonyAcceptImportDependency.js +2 -1
  100. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +12 -1
  101. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +35 -23
  102. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +13 -9
  103. package/lib/dependencies/HarmonyExports.js +4 -4
  104. package/lib/dependencies/HarmonyImportDependency.js +28 -27
  105. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +28 -69
  106. package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -3
  107. package/lib/dependencies/HarmonyImportSpecifierDependency.js +10 -8
  108. package/lib/dependencies/ImportDependency.js +8 -2
  109. package/lib/dependencies/ImportEagerDependency.js +6 -3
  110. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
  111. package/lib/dependencies/ImportMetaPlugin.js +154 -9
  112. package/lib/dependencies/ImportParserPlugin.js +21 -23
  113. package/lib/dependencies/ImportPhase.js +121 -0
  114. package/lib/dependencies/ImportWeakDependency.js +6 -3
  115. package/lib/dependencies/LocalModulesHelpers.js +3 -3
  116. package/lib/dependencies/ModuleDependency.js +5 -1
  117. package/lib/dependencies/ModuleHotAcceptDependency.js +1 -1
  118. package/lib/dependencies/WorkerPlugin.js +2 -2
  119. package/lib/dependencies/getFunctionExpression.js +1 -1
  120. package/lib/esm/ExportWebpackRequireRuntimeModule.js +1 -8
  121. package/lib/esm/ModuleChunkFormatPlugin.js +5 -4
  122. package/lib/hmr/HotModuleReplacement.runtime.js +2 -1
  123. package/lib/hmr/LazyCompilationPlugin.js +5 -3
  124. package/lib/ids/IdHelpers.js +20 -8
  125. package/lib/index.js +6 -0
  126. package/lib/javascript/ChunkHelpers.js +16 -5
  127. package/lib/javascript/JavascriptGenerator.js +105 -104
  128. package/lib/javascript/JavascriptModulesPlugin.js +80 -37
  129. package/lib/javascript/JavascriptParser.js +161 -44
  130. package/lib/json/JsonGenerator.js +5 -4
  131. package/lib/json/JsonParser.js +9 -2
  132. package/lib/library/AbstractLibraryPlugin.js +1 -1
  133. package/lib/library/AmdLibraryPlugin.js +4 -1
  134. package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
  135. package/lib/library/ModuleLibraryPlugin.js +41 -23
  136. package/lib/library/SystemLibraryPlugin.js +8 -1
  137. package/lib/library/UmdLibraryPlugin.js +2 -2
  138. package/lib/logging/Logger.js +5 -4
  139. package/lib/logging/createConsoleLogger.js +2 -2
  140. package/lib/node/NodeTargetPlugin.js +9 -1
  141. package/lib/node/ReadFileCompileWasmPlugin.js +0 -2
  142. package/lib/optimize/ConcatenatedModule.js +208 -167
  143. package/lib/optimize/ModuleConcatenationPlugin.js +5 -4
  144. package/lib/optimize/SideEffectsFlagPlugin.js +3 -2
  145. package/lib/optimize/SplitChunksPlugin.js +60 -46
  146. package/lib/rules/RuleSetCompiler.js +1 -1
  147. package/lib/runtime/AsyncModuleRuntimeModule.js +28 -18
  148. package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
  149. package/lib/runtime/GetChunkFilenameRuntimeModule.js +3 -2
  150. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +89 -55
  151. package/lib/schemes/HttpUriPlugin.js +78 -7
  152. package/lib/serialization/AggregateErrorSerializer.js +1 -2
  153. package/lib/serialization/ObjectMiddleware.js +0 -2
  154. package/lib/serialization/SingleItemMiddleware.js +1 -1
  155. package/lib/sharing/ConsumeSharedModule.js +1 -1
  156. package/lib/sharing/ConsumeSharedPlugin.js +5 -3
  157. package/lib/sharing/ProvideSharedModule.js +1 -1
  158. package/lib/sharing/resolveMatchedConfigs.js +15 -9
  159. package/lib/sharing/utils.js +1 -1
  160. package/lib/stats/DefaultStatsFactoryPlugin.js +8 -5
  161. package/lib/stats/DefaultStatsPresetPlugin.js +1 -1
  162. package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
  163. package/lib/util/StringXor.js +1 -1
  164. package/lib/util/URLAbsoluteSpecifier.js +2 -2
  165. package/lib/util/binarySearchBounds.js +2 -2
  166. package/lib/util/comparators.js +54 -76
  167. package/lib/util/compileBooleanMatcher.js +78 -6
  168. package/lib/util/createHash.js +20 -199
  169. package/lib/util/deprecation.js +1 -1
  170. package/lib/util/deterministicGrouping.js +6 -3
  171. package/lib/util/fs.js +75 -75
  172. package/lib/util/hash/BatchedHash.js +10 -9
  173. package/lib/util/hash/BulkUpdateHash.js +138 -0
  174. package/lib/util/hash/DebugHash.js +75 -0
  175. package/lib/util/hash/hash-digest.js +216 -0
  176. package/lib/util/identifier.js +82 -17
  177. package/lib/util/internalSerializables.js +2 -6
  178. package/lib/util/runtime.js +3 -3
  179. package/lib/util/source.js +2 -2
  180. package/lib/wasm/EnableWasmLoadingPlugin.js +10 -4
  181. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +3 -2
  182. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +11 -7
  183. package/lib/wasm-sync/WebAssemblyGenerator.js +9 -6
  184. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +11 -6
  185. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +6 -2
  186. package/lib/web/FetchCompileWasmPlugin.js +0 -2
  187. package/lib/webpack.js +85 -82
  188. package/module.d.ts +5 -0
  189. package/package.json +34 -28
  190. package/schemas/WebpackOptions.check.js +1 -1
  191. package/schemas/WebpackOptions.json +160 -101
  192. package/schemas/plugins/{css/CssAutoParserOptions.check.d.ts → ManifestPlugin.check.d.ts} +1 -1
  193. package/schemas/plugins/ManifestPlugin.check.js +6 -0
  194. package/schemas/plugins/ManifestPlugin.json +98 -0
  195. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  196. package/schemas/plugins/SourceMapDevToolPlugin.json +16 -3
  197. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  198. package/schemas/plugins/container/ContainerReferencePlugin.json +4 -1
  199. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  200. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  201. package/schemas/plugins/container/ModuleFederationPlugin.json +4 -1
  202. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
  203. package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
  204. package/schemas/plugins/css/CssParserOptions.check.js +1 -1
  205. package/schemas/plugins/json/JsonModulesPluginParser.check.js +1 -1
  206. package/types.d.ts +771 -436
  207. package/lib/ModuleSourceTypesConstants.js +0 -123
  208. package/lib/dependencies/CssLocalIdentifierDependency.js +0 -250
  209. package/lib/dependencies/CssSelfLocalIdentifierDependency.js +0 -112
  210. package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +0 -7
  211. package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +0 -6
  212. package/schemas/plugins/css/CssAutoGeneratorOptions.json +0 -3
  213. package/schemas/plugins/css/CssAutoParserOptions.check.js +0 -6
  214. package/schemas/plugins/css/CssAutoParserOptions.json +0 -3
  215. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.d.ts +0 -7
  216. package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +0 -6
  217. package/schemas/plugins/css/CssGlobalGeneratorOptions.json +0 -3
  218. package/schemas/plugins/css/CssGlobalParserOptions.check.d.ts +0 -7
  219. package/schemas/plugins/css/CssGlobalParserOptions.check.js +0 -6
  220. package/schemas/plugins/css/CssGlobalParserOptions.json +0 -3
@@ -1,123 +0,0 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Alexander Akait @alexander-akait
4
- */
5
-
6
- "use strict";
7
-
8
- /**
9
- * @type {ReadonlySet<never>}
10
- */
11
- const NO_TYPES = new Set();
12
-
13
- /**
14
- * @type {ReadonlySet<"asset">}
15
- */
16
- const ASSET_TYPES = new Set(["asset"]);
17
-
18
- /**
19
- * @type {ReadonlySet<"asset" | "javascript" | "asset">}
20
- */
21
- const ASSET_AND_JS_TYPES = new Set(["asset", "javascript"]);
22
-
23
- /**
24
- * @type {ReadonlySet<"css-url" | "asset">}
25
- */
26
- const ASSET_AND_CSS_URL_TYPES = new Set(["asset", "css-url"]);
27
-
28
- /**
29
- * @type {ReadonlySet<"javascript" | "css-url" | "asset">}
30
- */
31
- const ASSET_AND_JS_AND_CSS_URL_TYPES = new Set([
32
- "asset",
33
- "javascript",
34
- "css-url"
35
- ]);
36
-
37
- /**
38
- * @type {"javascript"}
39
- */
40
- const JS_TYPE = "javascript";
41
-
42
- /**
43
- * @type {ReadonlySet<"javascript">}
44
- */
45
- const JS_TYPES = new Set(["javascript"]);
46
-
47
- /**
48
- * @type {ReadonlySet<"javascript" | "css-export">}
49
- */
50
- const JS_AND_CSS_EXPORT_TYPES = new Set(["javascript", "css-export"]);
51
-
52
- /**
53
- * @type {ReadonlySet<"javascript" | "css-url">}
54
- */
55
- const JS_AND_CSS_URL_TYPES = new Set(["javascript", "css-url"]);
56
-
57
- /**
58
- * @type {ReadonlySet<"javascript" | "css">}
59
- */
60
- const JS_AND_CSS_TYPES = new Set(["javascript", "css"]);
61
-
62
- /**
63
- * @type {"css"}
64
- */
65
- const CSS_TYPE = "css";
66
- /**
67
- * @type {ReadonlySet<"css">}
68
- */
69
- const CSS_TYPES = new Set(["css"]);
70
-
71
- /**
72
- * @type {ReadonlySet<"css-url">}
73
- */
74
- const CSS_URL_TYPES = new Set(["css-url"]);
75
- /**
76
- * @type {ReadonlySet<"css-import">}
77
- */
78
- const CSS_IMPORT_TYPES = new Set(["css-import"]);
79
-
80
- /**
81
- * @type {ReadonlySet<"webassembly">}
82
- */
83
- const WEBASSEMBLY_TYPES = new Set(["webassembly"]);
84
-
85
- /**
86
- * @type {ReadonlySet<"runtime">}
87
- */
88
- const RUNTIME_TYPES = new Set(["runtime"]);
89
-
90
- /**
91
- * @type {ReadonlySet<"remote" | "share-init">}
92
- */
93
- const REMOTE_AND_SHARE_INIT_TYPES = new Set(["remote", "share-init"]);
94
-
95
- /**
96
- * @type {ReadonlySet<"consume-shared">}
97
- */
98
- const CONSUME_SHARED_TYPES = new Set(["consume-shared"]);
99
-
100
- /**
101
- * @type {ReadonlySet<"share-init">}
102
- */
103
- const SHARED_INIT_TYPES = new Set(["share-init"]);
104
-
105
- module.exports.ASSET_AND_CSS_URL_TYPES = ASSET_AND_CSS_URL_TYPES;
106
- module.exports.ASSET_AND_JS_AND_CSS_URL_TYPES = ASSET_AND_JS_AND_CSS_URL_TYPES;
107
- module.exports.ASSET_AND_JS_TYPES = ASSET_AND_JS_TYPES;
108
- module.exports.ASSET_TYPES = ASSET_TYPES;
109
- module.exports.CONSUME_SHARED_TYPES = CONSUME_SHARED_TYPES;
110
- module.exports.CSS_IMPORT_TYPES = CSS_IMPORT_TYPES;
111
- module.exports.CSS_TYPE = CSS_TYPE;
112
- module.exports.CSS_TYPES = CSS_TYPES;
113
- module.exports.CSS_URL_TYPES = CSS_URL_TYPES;
114
- module.exports.JS_AND_CSS_EXPORT_TYPES = JS_AND_CSS_EXPORT_TYPES;
115
- module.exports.JS_AND_CSS_TYPES = JS_AND_CSS_TYPES;
116
- module.exports.JS_AND_CSS_URL_TYPES = JS_AND_CSS_URL_TYPES;
117
- module.exports.JS_TYPE = JS_TYPE;
118
- module.exports.JS_TYPES = JS_TYPES;
119
- module.exports.NO_TYPES = NO_TYPES;
120
- module.exports.REMOTE_AND_SHARE_INIT_TYPES = REMOTE_AND_SHARE_INIT_TYPES;
121
- module.exports.RUNTIME_TYPES = RUNTIME_TYPES;
122
- module.exports.SHARED_INIT_TYPES = SHARED_INIT_TYPES;
123
- module.exports.WEBASSEMBLY_TYPES = WEBASSEMBLY_TYPES;
@@ -1,250 +0,0 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Ivan Kopeykin @vankop
4
- */
5
-
6
- "use strict";
7
-
8
- const { cssExportConvention } = require("../util/conventions");
9
- const createHash = require("../util/createHash");
10
- const { makePathsRelative } = require("../util/identifier");
11
- const makeSerializable = require("../util/makeSerializable");
12
- const memoize = require("../util/memoize");
13
- const NullDependency = require("./NullDependency");
14
-
15
- /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
16
- /** @typedef {import("../../declarations/WebpackOptions").CssGeneratorExportsConvention} CssGeneratorExportsConvention */
17
- /** @typedef {import("../../declarations/WebpackOptions").CssGeneratorLocalIdentName} CssGeneratorLocalIdentName */
18
- /** @typedef {import("../ChunkGraph")} ChunkGraph */
19
- /** @typedef {import("../CssModule")} CssModule */
20
- /** @typedef {import("../Dependency")} Dependency */
21
- /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
22
- /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
23
- /** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
24
- /** @typedef {import("../ModuleGraph")} ModuleGraph */
25
- /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
26
- /** @typedef {import("../css/CssGenerator")} CssGenerator */
27
- /** @typedef {import("../css/CssParser").Range} Range */
28
- /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
29
- /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
30
- /** @typedef {import("../util/Hash")} Hash */
31
-
32
- const getCssParser = memoize(() => require("../css/CssParser"));
33
-
34
- /**
35
- * @param {string} local css local
36
- * @param {CssModule} module module
37
- * @param {ChunkGraph} chunkGraph chunk graph
38
- * @param {RuntimeTemplate} runtimeTemplate runtime template
39
- * @returns {string} local ident
40
- */
41
- const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
42
- const generator = /** @type {CssGenerator} */ (module.generator);
43
- const localIdentName =
44
- /** @type {CssGeneratorLocalIdentName} */
45
- (generator.localIdentName);
46
- const relativeResourcePath = makePathsRelative(
47
- /** @type {string} */
48
- (module.context),
49
- /** @type {string} */
50
- (module.getResource()),
51
- runtimeTemplate.compilation.compiler.root
52
- );
53
- const { hashFunction, hashDigest, hashDigestLength, hashSalt, uniqueName } =
54
- runtimeTemplate.outputOptions;
55
- const hash = createHash(hashFunction);
56
-
57
- if (hashSalt) {
58
- hash.update(hashSalt);
59
- }
60
-
61
- hash.update(relativeResourcePath);
62
-
63
- if (!/\[local\]/.test(localIdentName)) {
64
- hash.update(local);
65
- }
66
-
67
- const localIdentHash = hash.digest(hashDigest).slice(0, hashDigestLength);
68
-
69
- return runtimeTemplate.compilation
70
- .getPath(localIdentName, {
71
- filename: relativeResourcePath,
72
- hash: localIdentHash,
73
- contentHash: localIdentHash,
74
- chunkGraph,
75
- module
76
- })
77
- .replace(/\[local\]/g, local)
78
- .replace(/\[uniqueName\]/g, /** @type {string} */ (uniqueName))
79
- .replace(/^((-?[0-9])|--)/, "_$1");
80
- };
81
-
82
- class CssLocalIdentifierDependency extends NullDependency {
83
- /**
84
- * @param {string} name name
85
- * @param {Range} range range
86
- * @param {string=} prefix prefix
87
- */
88
- constructor(name, range, prefix = "") {
89
- super();
90
- this.name = name;
91
- this.range = range;
92
- this.prefix = prefix;
93
- this._conventionNames = undefined;
94
- this._hashUpdate = undefined;
95
- }
96
-
97
- get type() {
98
- return "css local identifier";
99
- }
100
-
101
- /**
102
- * @param {string} name export name
103
- * @param {CssGeneratorExportsConvention} convention convention of the export name
104
- * @returns {string[]} convention results
105
- */
106
- getExportsConventionNames(name, convention) {
107
- if (this._conventionNames) {
108
- return this._conventionNames;
109
- }
110
- this._conventionNames = cssExportConvention(this.name, convention);
111
- return this._conventionNames;
112
- }
113
-
114
- /**
115
- * Returns the exported names
116
- * @param {ModuleGraph} moduleGraph module graph
117
- * @returns {ExportsSpec | undefined} export names
118
- */
119
- getExports(moduleGraph) {
120
- const module = /** @type {CssModule} */ (moduleGraph.getParentModule(this));
121
- const generator = /** @type {CssGenerator} */ (module.generator);
122
- const names = this.getExportsConventionNames(
123
- this.name,
124
- /** @type {CssGeneratorExportsConvention} */ (generator.convention)
125
- );
126
- return {
127
- exports: names.map((name) => ({
128
- name,
129
- canMangle: true
130
- })),
131
- dependencies: undefined
132
- };
133
- }
134
-
135
- /**
136
- * Update the hash
137
- * @param {Hash} hash hash to be updated
138
- * @param {UpdateHashContext} context context
139
- * @returns {void}
140
- */
141
- updateHash(hash, { chunkGraph }) {
142
- if (this._hashUpdate === undefined) {
143
- const module =
144
- /** @type {CssModule} */
145
- (chunkGraph.moduleGraph.getParentModule(this));
146
- const generator = /** @type {CssGenerator} */ (module.generator);
147
- const names = this.getExportsConventionNames(
148
- this.name,
149
- /** @type {CssGeneratorExportsConvention} */
150
- (generator.convention)
151
- );
152
- this._hashUpdate = `exportsConvention|${JSON.stringify(names)}|localIdentName|${JSON.stringify(generator.localIdentName)}`;
153
- }
154
- hash.update(this._hashUpdate);
155
- }
156
-
157
- /**
158
- * @param {ObjectSerializerContext} context context
159
- */
160
- serialize(context) {
161
- const { write } = context;
162
- write(this.name);
163
- write(this.range);
164
- write(this.prefix);
165
- super.serialize(context);
166
- }
167
-
168
- /**
169
- * @param {ObjectDeserializerContext} context context
170
- */
171
- deserialize(context) {
172
- const { read } = context;
173
- this.name = read();
174
- this.range = read();
175
- this.prefix = read();
176
- super.deserialize(context);
177
- }
178
- }
179
-
180
- CssLocalIdentifierDependency.Template = class CssLocalIdentifierDependencyTemplate extends (
181
- NullDependency.Template
182
- ) {
183
- /**
184
- * @param {Dependency} dependency the dependency for which the template should be applied
185
- * @param {string} local local name
186
- * @param {DependencyTemplateContext} templateContext the context object
187
- * @returns {string} identifier
188
- */
189
- static getIdentifier(
190
- dependency,
191
- local,
192
- { module: m, chunkGraph, runtimeTemplate }
193
- ) {
194
- const dep = /** @type {CssLocalIdentifierDependency} */ (dependency);
195
- const module = /** @type {CssModule} */ (m);
196
-
197
- return (
198
- dep.prefix +
199
- getCssParser().escapeIdentifier(
200
- getLocalIdent(local, module, chunkGraph, runtimeTemplate)
201
- )
202
- );
203
- }
204
-
205
- /**
206
- * @param {Dependency} dependency the dependency for which the template should be applied
207
- * @param {ReplaceSource} source the current replace source which can be modified
208
- * @param {DependencyTemplateContext} templateContext the context object
209
- * @returns {void}
210
- */
211
- apply(dependency, source, templateContext) {
212
- const { module: m, moduleGraph, runtime, cssData } = templateContext;
213
- const dep = /** @type {CssLocalIdentifierDependency} */ (dependency);
214
- const module = /** @type {CssModule} */ (m);
215
- const generator = /** @type {CssGenerator} */ (module.generator);
216
- const names = dep.getExportsConventionNames(
217
- dep.name,
218
- /** @type {CssGeneratorExportsConvention} */
219
- (generator.convention)
220
- );
221
- const usedNames =
222
- /** @type {string[]} */
223
- (
224
- names
225
- .map((name) =>
226
- moduleGraph.getExportInfo(module, name).getUsedName(name, runtime)
227
- )
228
- .filter(Boolean)
229
- );
230
- const local = usedNames.length === 0 ? names[0] : usedNames[0];
231
- const identifier = CssLocalIdentifierDependencyTemplate.getIdentifier(
232
- dep,
233
- local,
234
- templateContext
235
- );
236
-
237
- source.replace(dep.range[0], dep.range[1] - 1, identifier);
238
-
239
- for (const used of [...usedNames, ...names]) {
240
- cssData.exports.set(used, getCssParser().unescapeIdentifier(identifier));
241
- }
242
- }
243
- };
244
-
245
- makeSerializable(
246
- CssLocalIdentifierDependency,
247
- "webpack/lib/dependencies/CssLocalIdentifierDependency"
248
- );
249
-
250
- module.exports = CssLocalIdentifierDependency;
@@ -1,112 +0,0 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Ivan Kopeykin @vankop
4
- */
5
-
6
- "use strict";
7
-
8
- const Dependency = require("../Dependency");
9
- const makeSerializable = require("../util/makeSerializable");
10
- const CssLocalIdentifierDependency = require("./CssLocalIdentifierDependency");
11
-
12
- /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
13
- /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
14
- /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
15
- /** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
16
- /** @typedef {import("../ModuleGraph")} ModuleGraph */
17
- /** @typedef {import("../css/CssParser").Range} Range */
18
- /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
19
- /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
20
- /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
21
-
22
- class CssSelfLocalIdentifierDependency extends CssLocalIdentifierDependency {
23
- /**
24
- * @param {string} name name
25
- * @param {Range} range range
26
- * @param {string=} prefix prefix
27
- * @param {Set<string>=} declaredSet set of declared names (will only be active when in declared set)
28
- */
29
- constructor(name, range, prefix = "", declaredSet = undefined) {
30
- super(name, range, prefix);
31
- this.declaredSet = declaredSet;
32
- }
33
-
34
- get type() {
35
- return "css self local identifier";
36
- }
37
-
38
- get category() {
39
- return "self";
40
- }
41
-
42
- /**
43
- * @returns {string | null} an identifier to merge equal requests
44
- */
45
- getResourceIdentifier() {
46
- return "self";
47
- }
48
-
49
- /**
50
- * Returns the exported names
51
- * @param {ModuleGraph} moduleGraph module graph
52
- * @returns {ExportsSpec | undefined} export names
53
- */
54
- getExports(moduleGraph) {
55
- if (this.declaredSet && !this.declaredSet.has(this.name)) return;
56
- return super.getExports(moduleGraph);
57
- }
58
-
59
- /**
60
- * Returns list of exports referenced by this dependency
61
- * @param {ModuleGraph} moduleGraph module graph
62
- * @param {RuntimeSpec} runtime the runtime for which the module is analysed
63
- * @returns {ReferencedExports} referenced exports
64
- */
65
- getReferencedExports(moduleGraph, runtime) {
66
- if (this.declaredSet && !this.declaredSet.has(this.name)) {
67
- return Dependency.NO_EXPORTS_REFERENCED;
68
- }
69
- return [[this.name]];
70
- }
71
-
72
- /**
73
- * @param {ObjectSerializerContext} context context
74
- */
75
- serialize(context) {
76
- const { write } = context;
77
- write(this.declaredSet);
78
- super.serialize(context);
79
- }
80
-
81
- /**
82
- * @param {ObjectDeserializerContext} context context
83
- */
84
- deserialize(context) {
85
- const { read } = context;
86
- this.declaredSet = read();
87
- super.deserialize(context);
88
- }
89
- }
90
-
91
- CssSelfLocalIdentifierDependency.Template = class CssSelfLocalIdentifierDependencyTemplate extends (
92
- CssLocalIdentifierDependency.Template
93
- ) {
94
- /**
95
- * @param {Dependency} dependency the dependency for which the template should be applied
96
- * @param {ReplaceSource} source the current replace source which can be modified
97
- * @param {DependencyTemplateContext} templateContext the context object
98
- * @returns {void}
99
- */
100
- apply(dependency, source, templateContext) {
101
- const dep = /** @type {CssSelfLocalIdentifierDependency} */ (dependency);
102
- if (dep.declaredSet && !dep.declaredSet.has(dep.name)) return;
103
- super.apply(dependency, source, templateContext);
104
- }
105
- };
106
-
107
- makeSerializable(
108
- CssSelfLocalIdentifierDependency,
109
- "webpack/lib/dependencies/CssSelfLocalIdentifierDependency"
110
- );
111
-
112
- module.exports = CssSelfLocalIdentifierDependency;
@@ -1,7 +0,0 @@
1
- /*
2
- * This file was automatically generated.
3
- * DO NOT MODIFY BY HAND.
4
- * Run `yarn fix:special` to update
5
- */
6
- declare const check: (options: any) => boolean;
7
- export = check;
@@ -1,6 +0,0 @@
1
- /*
2
- * This file was automatically generated.
3
- * DO NOT MODIFY BY HAND.
4
- * Run `yarn fix:special` to update
5
- */
6
- "use strict";function e(r,{instancePath:t="",parentData:o,parentDataProperty:n,rootData:a=r}={}){let s=null,l=0;if(0===l){if(!r||"object"!=typeof r||Array.isArray(r))return e.errors=[{params:{type:"object"}}],!1;{const t=l;for(const t in r)if("esModule"!==t&&"exportsConvention"!==t&&"exportsOnly"!==t&&"localIdentName"!==t)return e.errors=[{params:{additionalProperty:t}}],!1;if(t===l){if(void 0!==r.esModule){const t=l;if("boolean"!=typeof r.esModule)return e.errors=[{params:{type:"boolean"}}],!1;var i=t===l}else i=!0;if(i){if(void 0!==r.exportsConvention){let t=r.exportsConvention;const o=l,n=l;let a=!1;const c=l;if("as-is"!==t&&"camel-case"!==t&&"camel-case-only"!==t&&"dashes"!==t&&"dashes-only"!==t){const e={params:{}};null===s?s=[e]:s.push(e),l++}var p=c===l;if(a=a||p,!a){const e=l;if(!(t instanceof Function)){const e={params:{}};null===s?s=[e]:s.push(e),l++}p=e===l,a=a||p}if(!a){const r={params:{}};return null===s?s=[r]:s.push(r),l++,e.errors=s,!1}l=n,null!==s&&(n?s.length=n:s=null),i=o===l}else i=!0;if(i){if(void 0!==r.exportsOnly){const t=l;if("boolean"!=typeof r.exportsOnly)return e.errors=[{params:{type:"boolean"}}],!1;i=t===l}else i=!0;if(i)if(void 0!==r.localIdentName){const t=l;if("string"!=typeof r.localIdentName)return e.errors=[{params:{type:"string"}}],!1;i=t===l}else i=!0}}}}}return e.errors=s,0===l}function r(t,{instancePath:o="",parentData:n,parentDataProperty:a,rootData:s=t}={}){let l=null,i=0;return e(t,{instancePath:o,parentData:n,parentDataProperty:a,rootData:s})||(l=null===l?e.errors:l.concat(e.errors),i=l.length),r.errors=l,0===i}module.exports=r,module.exports.default=r;
@@ -1,3 +0,0 @@
1
- {
2
- "$ref": "../../WebpackOptions.json#/definitions/CssAutoGeneratorOptions"
3
- }
@@ -1,6 +0,0 @@
1
- /*
2
- * This file was automatically generated.
3
- * DO NOT MODIFY BY HAND.
4
- * Run `yarn fix:special` to update
5
- */
6
- "use strict";function r(t,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:n=t}={}){if(!t||"object"!=typeof t||Array.isArray(t))return r.errors=[{params:{type:"object"}}],!1;{const e=0;for(const e in t)if("import"!==e&&"namedExports"!==e&&"url"!==e)return r.errors=[{params:{additionalProperty:e}}],!1;if(0===e){if(void 0!==t.import){const e=0;if("boolean"!=typeof t.import)return r.errors=[{params:{type:"boolean"}}],!1;var s=0===e}else s=!0;if(s){if(void 0!==t.namedExports){const e=0;if("boolean"!=typeof t.namedExports)return r.errors=[{params:{type:"boolean"}}],!1;s=0===e}else s=!0;if(s)if(void 0!==t.url){const e=0;if("boolean"!=typeof t.url)return r.errors=[{params:{type:"boolean"}}],!1;s=0===e}else s=!0}}}return r.errors=null,!0}function t(e,{instancePath:o="",parentData:a,parentDataProperty:n,rootData:s=e}={}){let p=null,i=0;return r(e,{instancePath:o,parentData:a,parentDataProperty:n,rootData:s})||(p=null===p?r.errors:p.concat(r.errors),i=p.length),t.errors=p,0===i}module.exports=t,module.exports.default=t;
@@ -1,3 +0,0 @@
1
- {
2
- "$ref": "../../WebpackOptions.json#/definitions/CssAutoParserOptions"
3
- }
@@ -1,7 +0,0 @@
1
- /*
2
- * This file was automatically generated.
3
- * DO NOT MODIFY BY HAND.
4
- * Run `yarn fix:special` to update
5
- */
6
- declare const check: (options: any) => boolean;
7
- export = check;
@@ -1,6 +0,0 @@
1
- /*
2
- * This file was automatically generated.
3
- * DO NOT MODIFY BY HAND.
4
- * Run `yarn fix:special` to update
5
- */
6
- "use strict";function e(r,{instancePath:t="",parentData:o,parentDataProperty:n,rootData:a=r}={}){let s=null,l=0;if(0===l){if(!r||"object"!=typeof r||Array.isArray(r))return e.errors=[{params:{type:"object"}}],!1;{const t=l;for(const t in r)if("esModule"!==t&&"exportsConvention"!==t&&"exportsOnly"!==t&&"localIdentName"!==t)return e.errors=[{params:{additionalProperty:t}}],!1;if(t===l){if(void 0!==r.esModule){const t=l;if("boolean"!=typeof r.esModule)return e.errors=[{params:{type:"boolean"}}],!1;var i=t===l}else i=!0;if(i){if(void 0!==r.exportsConvention){let t=r.exportsConvention;const o=l,n=l;let a=!1;const c=l;if("as-is"!==t&&"camel-case"!==t&&"camel-case-only"!==t&&"dashes"!==t&&"dashes-only"!==t){const e={params:{}};null===s?s=[e]:s.push(e),l++}var p=c===l;if(a=a||p,!a){const e=l;if(!(t instanceof Function)){const e={params:{}};null===s?s=[e]:s.push(e),l++}p=e===l,a=a||p}if(!a){const r={params:{}};return null===s?s=[r]:s.push(r),l++,e.errors=s,!1}l=n,null!==s&&(n?s.length=n:s=null),i=o===l}else i=!0;if(i){if(void 0!==r.exportsOnly){const t=l;if("boolean"!=typeof r.exportsOnly)return e.errors=[{params:{type:"boolean"}}],!1;i=t===l}else i=!0;if(i)if(void 0!==r.localIdentName){const t=l;if("string"!=typeof r.localIdentName)return e.errors=[{params:{type:"string"}}],!1;i=t===l}else i=!0}}}}}return e.errors=s,0===l}function r(t,{instancePath:o="",parentData:n,parentDataProperty:a,rootData:s=t}={}){let l=null,i=0;return e(t,{instancePath:o,parentData:n,parentDataProperty:a,rootData:s})||(l=null===l?e.errors:l.concat(e.errors),i=l.length),r.errors=l,0===i}module.exports=r,module.exports.default=r;
@@ -1,3 +0,0 @@
1
- {
2
- "$ref": "../../WebpackOptions.json#/definitions/CssGlobalGeneratorOptions"
3
- }
@@ -1,7 +0,0 @@
1
- /*
2
- * This file was automatically generated.
3
- * DO NOT MODIFY BY HAND.
4
- * Run `yarn fix:special` to update
5
- */
6
- declare const check: (options: any) => boolean;
7
- export = check;
@@ -1,6 +0,0 @@
1
- /*
2
- * This file was automatically generated.
3
- * DO NOT MODIFY BY HAND.
4
- * Run `yarn fix:special` to update
5
- */
6
- "use strict";function r(t,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:n=t}={}){if(!t||"object"!=typeof t||Array.isArray(t))return r.errors=[{params:{type:"object"}}],!1;{const e=0;for(const e in t)if("import"!==e&&"namedExports"!==e&&"url"!==e)return r.errors=[{params:{additionalProperty:e}}],!1;if(0===e){if(void 0!==t.import){const e=0;if("boolean"!=typeof t.import)return r.errors=[{params:{type:"boolean"}}],!1;var s=0===e}else s=!0;if(s){if(void 0!==t.namedExports){const e=0;if("boolean"!=typeof t.namedExports)return r.errors=[{params:{type:"boolean"}}],!1;s=0===e}else s=!0;if(s)if(void 0!==t.url){const e=0;if("boolean"!=typeof t.url)return r.errors=[{params:{type:"boolean"}}],!1;s=0===e}else s=!0}}}return r.errors=null,!0}function t(e,{instancePath:o="",parentData:a,parentDataProperty:n,rootData:s=e}={}){let p=null,i=0;return r(e,{instancePath:o,parentData:a,parentDataProperty:n,rootData:s})||(p=null===p?r.errors:p.concat(r.errors),i=p.length),t.errors=p,0===i}module.exports=t,module.exports.default=t;
@@ -1,3 +0,0 @@
1
- {
2
- "$ref": "../../WebpackOptions.json#/definitions/CssGlobalParserOptions"
3
- }