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.
- package/README.md +121 -134
- package/hot/dev-server.js +18 -3
- package/hot/emitter-event-target.js +7 -0
- package/hot/lazy-compilation-node.js +45 -29
- package/hot/lazy-compilation-universal.js +18 -0
- package/hot/lazy-compilation-web.js +15 -5
- package/hot/load-http.js +7 -0
- package/hot/only-dev-server.js +19 -4
- package/lib/APIPlugin.js +6 -0
- package/lib/Chunk.js +1 -1
- package/lib/ChunkGraph.js +9 -7
- package/lib/ChunkGroup.js +8 -5
- package/lib/CleanPlugin.js +6 -3
- package/lib/CodeGenerationResults.js +2 -1
- package/lib/CompatibilityPlugin.js +28 -2
- package/lib/Compilation.js +58 -21
- package/lib/Compiler.js +3 -3
- package/lib/ConcatenationScope.js +0 -15
- package/lib/ContextModule.js +6 -3
- package/lib/ContextModuleFactory.js +6 -4
- package/lib/CssModule.js +6 -1
- package/lib/DefinePlugin.js +45 -14
- package/lib/DelegatedModule.js +7 -4
- package/lib/Dependency.js +8 -1
- package/lib/DependencyTemplate.js +1 -0
- package/lib/DllModule.js +6 -3
- package/lib/DotenvPlugin.js +462 -0
- package/lib/EnvironmentPlugin.js +19 -16
- package/lib/EvalSourceMapDevToolPlugin.js +16 -0
- package/lib/ExportsInfo.js +6 -2
- package/lib/ExternalModule.js +28 -35
- package/lib/ExternalModuleFactoryPlugin.js +11 -9
- package/lib/ExternalsPlugin.js +2 -1
- package/lib/FileSystemInfo.js +1 -1
- package/lib/Generator.js +10 -7
- package/lib/HookWebpackError.js +33 -4
- package/lib/HotModuleReplacementPlugin.js +22 -0
- package/lib/ManifestPlugin.js +235 -0
- package/lib/Module.js +27 -15
- package/lib/ModuleBuildError.js +1 -1
- package/lib/ModuleError.js +1 -1
- package/lib/ModuleFilenameHelpers.js +1 -1
- package/lib/ModuleGraph.js +29 -13
- package/lib/ModuleGraphConnection.js +2 -2
- package/lib/ModuleSourceTypeConstants.js +189 -0
- package/lib/ModuleTypeConstants.js +1 -4
- package/lib/ModuleWarning.js +1 -1
- package/lib/MultiCompiler.js +1 -1
- package/lib/NodeStuffPlugin.js +424 -116
- package/lib/NormalModule.js +23 -20
- package/lib/NormalModuleFactory.js +7 -10
- package/lib/Parser.js +1 -1
- package/lib/RawModule.js +7 -4
- package/lib/RuntimeGlobals.js +22 -4
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +27 -6
- package/lib/RuntimeTemplate.js +120 -57
- package/lib/SourceMapDevToolPlugin.js +26 -1
- package/lib/Template.js +17 -6
- package/lib/TemplatedPathPlugin.js +5 -6
- package/lib/WebpackError.js +0 -1
- package/lib/WebpackOptionsApply.js +67 -15
- package/lib/asset/AssetBytesGenerator.js +16 -12
- package/lib/asset/AssetGenerator.js +31 -26
- package/lib/asset/AssetSourceGenerator.js +16 -12
- package/lib/asset/RawDataUrlModule.js +6 -3
- package/lib/buildChunkGraph.js +4 -2
- package/lib/cache/PackFileCacheStrategy.js +6 -5
- package/lib/cli.js +2 -43
- package/lib/config/browserslistTargetHandler.js +24 -0
- package/lib/config/defaults.js +226 -61
- package/lib/config/normalization.js +4 -3
- package/lib/config/target.js +11 -0
- package/lib/container/ContainerEntryModule.js +6 -3
- package/lib/container/FallbackModule.js +6 -3
- package/lib/container/RemoteModule.js +1 -3
- package/lib/css/CssGenerator.js +304 -76
- package/lib/css/CssLoadingRuntimeModule.js +14 -4
- package/lib/css/CssMergeStyleSheetsRuntimeModule.js +56 -0
- package/lib/css/CssModulesPlugin.js +72 -67
- package/lib/css/CssParser.js +1726 -732
- package/lib/css/walkCssTokens.js +128 -11
- package/lib/dependencies/CachedConstDependency.js +24 -10
- package/lib/dependencies/CommonJsImportsParserPlugin.js +0 -9
- package/lib/dependencies/CommonJsPlugin.js +12 -0
- package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +2 -2
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +3 -1
- package/lib/dependencies/CssIcssExportDependency.js +389 -12
- package/lib/dependencies/CssIcssImportDependency.js +114 -51
- package/lib/dependencies/CssIcssSymbolDependency.js +31 -33
- package/lib/dependencies/CssImportDependency.js +17 -6
- package/lib/dependencies/CssUrlDependency.js +3 -2
- package/lib/dependencies/DynamicExports.js +7 -7
- package/lib/dependencies/ExternalModuleDependency.js +7 -4
- package/lib/dependencies/ExternalModuleInitFragment.js +3 -2
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +96 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +6 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +2 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +12 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +35 -23
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +13 -9
- package/lib/dependencies/HarmonyExports.js +4 -4
- package/lib/dependencies/HarmonyImportDependency.js +28 -27
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +28 -69
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -3
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +10 -8
- package/lib/dependencies/ImportDependency.js +8 -2
- package/lib/dependencies/ImportEagerDependency.js +6 -3
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/ImportMetaPlugin.js +154 -9
- package/lib/dependencies/ImportParserPlugin.js +21 -23
- package/lib/dependencies/ImportPhase.js +121 -0
- package/lib/dependencies/ImportWeakDependency.js +6 -3
- package/lib/dependencies/LocalModulesHelpers.js +3 -3
- package/lib/dependencies/ModuleDependency.js +5 -1
- package/lib/dependencies/ModuleHotAcceptDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +2 -2
- package/lib/dependencies/getFunctionExpression.js +1 -1
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +1 -8
- package/lib/esm/ModuleChunkFormatPlugin.js +5 -4
- package/lib/hmr/HotModuleReplacement.runtime.js +2 -1
- package/lib/hmr/LazyCompilationPlugin.js +5 -3
- package/lib/ids/IdHelpers.js +20 -8
- package/lib/index.js +6 -0
- package/lib/javascript/ChunkHelpers.js +16 -5
- package/lib/javascript/JavascriptGenerator.js +105 -104
- package/lib/javascript/JavascriptModulesPlugin.js +80 -37
- package/lib/javascript/JavascriptParser.js +161 -44
- package/lib/json/JsonGenerator.js +5 -4
- package/lib/json/JsonParser.js +9 -2
- package/lib/library/AbstractLibraryPlugin.js +1 -1
- package/lib/library/AmdLibraryPlugin.js +4 -1
- package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
- package/lib/library/ModuleLibraryPlugin.js +41 -23
- package/lib/library/SystemLibraryPlugin.js +8 -1
- package/lib/library/UmdLibraryPlugin.js +2 -2
- package/lib/logging/Logger.js +5 -4
- package/lib/logging/createConsoleLogger.js +2 -2
- package/lib/node/NodeTargetPlugin.js +9 -1
- package/lib/node/ReadFileCompileWasmPlugin.js +0 -2
- package/lib/optimize/ConcatenatedModule.js +208 -167
- package/lib/optimize/ModuleConcatenationPlugin.js +5 -4
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -2
- package/lib/optimize/SplitChunksPlugin.js +60 -46
- package/lib/rules/RuleSetCompiler.js +1 -1
- package/lib/runtime/AsyncModuleRuntimeModule.js +28 -18
- package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +3 -2
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +89 -55
- package/lib/schemes/HttpUriPlugin.js +78 -7
- package/lib/serialization/AggregateErrorSerializer.js +1 -2
- package/lib/serialization/ObjectMiddleware.js +0 -2
- package/lib/serialization/SingleItemMiddleware.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +1 -1
- package/lib/sharing/ConsumeSharedPlugin.js +5 -3
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/resolveMatchedConfigs.js +15 -9
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +8 -5
- package/lib/stats/DefaultStatsPresetPlugin.js +1 -1
- package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
- package/lib/util/StringXor.js +1 -1
- package/lib/util/URLAbsoluteSpecifier.js +2 -2
- package/lib/util/binarySearchBounds.js +2 -2
- package/lib/util/comparators.js +54 -76
- package/lib/util/compileBooleanMatcher.js +78 -6
- package/lib/util/createHash.js +20 -199
- package/lib/util/deprecation.js +1 -1
- package/lib/util/deterministicGrouping.js +6 -3
- package/lib/util/fs.js +75 -75
- package/lib/util/hash/BatchedHash.js +10 -9
- package/lib/util/hash/BulkUpdateHash.js +138 -0
- package/lib/util/hash/DebugHash.js +75 -0
- package/lib/util/hash/hash-digest.js +216 -0
- package/lib/util/identifier.js +82 -17
- package/lib/util/internalSerializables.js +2 -6
- package/lib/util/runtime.js +3 -3
- package/lib/util/source.js +2 -2
- package/lib/wasm/EnableWasmLoadingPlugin.js +10 -4
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +3 -2
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +11 -7
- package/lib/wasm-sync/WebAssemblyGenerator.js +9 -6
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +11 -6
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +6 -2
- package/lib/web/FetchCompileWasmPlugin.js +0 -2
- package/lib/webpack.js +85 -82
- package/module.d.ts +5 -0
- package/package.json +34 -28
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +160 -101
- package/schemas/plugins/{css/CssAutoParserOptions.check.d.ts → ManifestPlugin.check.d.ts} +1 -1
- package/schemas/plugins/ManifestPlugin.check.js +6 -0
- package/schemas/plugins/ManifestPlugin.json +98 -0
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +16 -3
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +4 -1
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +4 -1
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/schemas/plugins/json/JsonModulesPluginParser.check.js +1 -1
- package/types.d.ts +771 -436
- package/lib/ModuleSourceTypesConstants.js +0 -123
- package/lib/dependencies/CssLocalIdentifierDependency.js +0 -250
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +0 -112
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +0 -6
- package/schemas/plugins/css/CssAutoGeneratorOptions.json +0 -3
- package/schemas/plugins/css/CssAutoParserOptions.check.js +0 -6
- package/schemas/plugins/css/CssAutoParserOptions.json +0 -3
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +0 -6
- package/schemas/plugins/css/CssGlobalGeneratorOptions.json +0 -3
- package/schemas/plugins/css/CssGlobalParserOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssGlobalParserOptions.check.js +0 -6
- package/schemas/plugins/css/CssGlobalParserOptions.json +0 -3
|
@@ -9,16 +9,20 @@ const { RawSource } = require("webpack-sources");
|
|
|
9
9
|
const ConcatenationScope = require("../ConcatenationScope");
|
|
10
10
|
const Generator = require("../Generator");
|
|
11
11
|
const {
|
|
12
|
+
CSS_TYPE,
|
|
13
|
+
CSS_URL_TYPE,
|
|
12
14
|
CSS_URL_TYPES,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
JAVASCRIPT_AND_CSS_URL_TYPES,
|
|
16
|
+
JAVASCRIPT_TYPE,
|
|
17
|
+
JAVASCRIPT_TYPES,
|
|
15
18
|
NO_TYPES
|
|
16
|
-
} = require("../
|
|
19
|
+
} = require("../ModuleSourceTypeConstants");
|
|
17
20
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
18
21
|
|
|
19
22
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
20
23
|
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
|
21
24
|
/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
|
25
|
+
/** @typedef {import("../Module").SourceType} SourceType */
|
|
22
26
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
23
27
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
24
28
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
@@ -46,7 +50,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
46
50
|
const data = getData ? getData() : undefined;
|
|
47
51
|
|
|
48
52
|
switch (type) {
|
|
49
|
-
case
|
|
53
|
+
case JAVASCRIPT_TYPE: {
|
|
50
54
|
if (!originalSource) {
|
|
51
55
|
return new RawSource("");
|
|
52
56
|
}
|
|
@@ -66,13 +70,13 @@ class AssetSourceGenerator extends Generator {
|
|
|
66
70
|
} = ${RuntimeGlobals.toBinary}(${JSON.stringify(encodedSource)});`;
|
|
67
71
|
} else {
|
|
68
72
|
runtimeRequirements.add(RuntimeGlobals.module);
|
|
69
|
-
sourceContent = `${
|
|
73
|
+
sourceContent = `${module.moduleArgument}.exports = ${RuntimeGlobals.toBinary}(${JSON.stringify(
|
|
70
74
|
encodedSource
|
|
71
75
|
)});`;
|
|
72
76
|
}
|
|
73
77
|
return new RawSource(sourceContent);
|
|
74
78
|
}
|
|
75
|
-
case
|
|
79
|
+
case CSS_URL_TYPE: {
|
|
76
80
|
if (!originalSource) {
|
|
77
81
|
return null;
|
|
78
82
|
}
|
|
@@ -99,7 +103,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
99
103
|
*/
|
|
100
104
|
generateError(error, module, generateContext) {
|
|
101
105
|
switch (generateContext.type) {
|
|
102
|
-
case
|
|
106
|
+
case JAVASCRIPT_TYPE: {
|
|
103
107
|
return new RawSource(
|
|
104
108
|
`throw new Error(${JSON.stringify(error.message)});`
|
|
105
109
|
);
|
|
@@ -136,12 +140,12 @@ class AssetSourceGenerator extends Generator {
|
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
if (sourceTypes.size > 0) {
|
|
139
|
-
if (sourceTypes.has(
|
|
140
|
-
return
|
|
141
|
-
} else if (sourceTypes.has(
|
|
143
|
+
if (sourceTypes.has(JAVASCRIPT_TYPE) && sourceTypes.has(CSS_TYPE)) {
|
|
144
|
+
return JAVASCRIPT_AND_CSS_URL_TYPES;
|
|
145
|
+
} else if (sourceTypes.has(CSS_TYPE)) {
|
|
142
146
|
return CSS_URL_TYPES;
|
|
143
147
|
}
|
|
144
|
-
return
|
|
148
|
+
return JAVASCRIPT_TYPES;
|
|
145
149
|
}
|
|
146
150
|
|
|
147
151
|
return NO_TYPES;
|
|
@@ -149,7 +153,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
149
153
|
|
|
150
154
|
/**
|
|
151
155
|
* @param {NormalModule} module the module
|
|
152
|
-
* @param {
|
|
156
|
+
* @param {SourceType=} type source type
|
|
153
157
|
* @returns {number} estimate size of the module
|
|
154
158
|
*/
|
|
155
159
|
getSize(module, type) {
|
|
@@ -11,14 +11,17 @@ const ConcatenationScope = require("../ConcatenationScope");
|
|
|
11
11
|
const Generator = require("../Generator");
|
|
12
12
|
const {
|
|
13
13
|
ASSET_AND_CSS_URL_TYPES,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
ASSET_AND_JAVASCRIPT_AND_CSS_URL_TYPES,
|
|
15
|
+
ASSET_AND_JAVASCRIPT_TYPES,
|
|
16
16
|
ASSET_TYPES,
|
|
17
|
+
CSS_TYPE,
|
|
18
|
+
CSS_URL_TYPE,
|
|
17
19
|
CSS_URL_TYPES,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
JAVASCRIPT_AND_CSS_URL_TYPES,
|
|
21
|
+
JAVASCRIPT_TYPE,
|
|
22
|
+
JAVASCRIPT_TYPES,
|
|
20
23
|
NO_TYPES
|
|
21
|
-
} = require("../
|
|
24
|
+
} = require("../ModuleSourceTypeConstants");
|
|
22
25
|
const { ASSET_MODULE_TYPE } = require("../ModuleTypeConstants");
|
|
23
26
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
24
27
|
const CssUrlDependency = require("../dependencies/CssUrlDependency");
|
|
@@ -43,6 +46,7 @@ const getMimeTypes = memoize(() => require("mime-types"));
|
|
|
43
46
|
/** @typedef {import("../Module").NameForCondition} NameForCondition */
|
|
44
47
|
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
45
48
|
/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
|
49
|
+
/** @typedef {import("../Module").SourceType} SourceType */
|
|
46
50
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
47
51
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
48
52
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
@@ -331,7 +335,7 @@ class AssetGenerator extends Generator {
|
|
|
331
335
|
|
|
332
336
|
let assetPath;
|
|
333
337
|
|
|
334
|
-
if (generatorOptions.publicPath !== undefined && type ===
|
|
338
|
+
if (generatorOptions.publicPath !== undefined && type === JAVASCRIPT_TYPE) {
|
|
335
339
|
const { path, info } = runtimeTemplate.compilation.getAssetPathWithInfo(
|
|
336
340
|
generatorOptions.publicPath,
|
|
337
341
|
{
|
|
@@ -346,7 +350,7 @@ class AssetGenerator extends Generator {
|
|
|
346
350
|
assetPath = JSON.stringify(path + filename);
|
|
347
351
|
} else if (
|
|
348
352
|
generatorOptions.publicPath !== undefined &&
|
|
349
|
-
type ===
|
|
353
|
+
type === CSS_URL_TYPE
|
|
350
354
|
) {
|
|
351
355
|
const { path, info } = runtimeTemplate.compilation.getAssetPathWithInfo(
|
|
352
356
|
generatorOptions.publicPath,
|
|
@@ -360,14 +364,14 @@ class AssetGenerator extends Generator {
|
|
|
360
364
|
);
|
|
361
365
|
assetInfo = mergeAssetInfo(assetInfo, info);
|
|
362
366
|
assetPath = path + filename;
|
|
363
|
-
} else if (type ===
|
|
367
|
+
} else if (type === JAVASCRIPT_TYPE) {
|
|
364
368
|
// add __webpack_require__.p
|
|
365
369
|
runtimeRequirements.add(RuntimeGlobals.publicPath);
|
|
366
370
|
assetPath = runtimeTemplate.concatenation(
|
|
367
371
|
{ expr: RuntimeGlobals.publicPath },
|
|
368
372
|
filename
|
|
369
373
|
);
|
|
370
|
-
} else if (type ===
|
|
374
|
+
} else if (type === CSS_URL_TYPE) {
|
|
371
375
|
const compilation = runtimeTemplate.compilation;
|
|
372
376
|
const path =
|
|
373
377
|
compilation.outputOptions.publicPath === "auto"
|
|
@@ -380,7 +384,6 @@ class AssetGenerator extends Generator {
|
|
|
380
384
|
}
|
|
381
385
|
|
|
382
386
|
return {
|
|
383
|
-
// eslint-disable-next-line object-shorthand
|
|
384
387
|
assetPath: /** @type {string} */ (assetPath),
|
|
385
388
|
assetInfo: { sourceFilename, ...assetInfo }
|
|
386
389
|
};
|
|
@@ -519,7 +522,7 @@ class AssetGenerator extends Generator {
|
|
|
519
522
|
|
|
520
523
|
let content;
|
|
521
524
|
|
|
522
|
-
const needContent = type ===
|
|
525
|
+
const needContent = type === JAVASCRIPT_TYPE || type === CSS_URL_TYPE;
|
|
523
526
|
|
|
524
527
|
const data = getData ? getData() : undefined;
|
|
525
528
|
|
|
@@ -530,7 +533,9 @@ class AssetGenerator extends Generator {
|
|
|
530
533
|
) {
|
|
531
534
|
const encodedSource = this.generateDataUri(module);
|
|
532
535
|
content =
|
|
533
|
-
type ===
|
|
536
|
+
type === JAVASCRIPT_TYPE
|
|
537
|
+
? JSON.stringify(encodedSource)
|
|
538
|
+
: encodedSource;
|
|
534
539
|
|
|
535
540
|
if (data) {
|
|
536
541
|
data.set("url", { [type]: content, ...data.get("url") });
|
|
@@ -571,7 +576,7 @@ class AssetGenerator extends Generator {
|
|
|
571
576
|
contentHash
|
|
572
577
|
);
|
|
573
578
|
|
|
574
|
-
if (data && (type ===
|
|
579
|
+
if (data && (type === JAVASCRIPT_TYPE || type === CSS_URL_TYPE)) {
|
|
575
580
|
data.set("url", { [type]: assetPath, ...data.get("url") });
|
|
576
581
|
}
|
|
577
582
|
|
|
@@ -599,7 +604,7 @@ class AssetGenerator extends Generator {
|
|
|
599
604
|
content = assetPath;
|
|
600
605
|
}
|
|
601
606
|
|
|
602
|
-
if (type ===
|
|
607
|
+
if (type === JAVASCRIPT_TYPE) {
|
|
603
608
|
if (concatenationScope) {
|
|
604
609
|
concatenationScope.registerNamespaceExport(
|
|
605
610
|
ConcatenationScope.NAMESPACE_OBJECT_EXPORT
|
|
@@ -614,8 +619,8 @@ class AssetGenerator extends Generator {
|
|
|
614
619
|
|
|
615
620
|
runtimeRequirements.add(RuntimeGlobals.module);
|
|
616
621
|
|
|
617
|
-
return new RawSource(`${
|
|
618
|
-
} else if (type ===
|
|
622
|
+
return new RawSource(`${module.moduleArgument}.exports = ${content};`);
|
|
623
|
+
} else if (type === CSS_URL_TYPE) {
|
|
619
624
|
return null;
|
|
620
625
|
}
|
|
621
626
|
|
|
@@ -633,7 +638,7 @@ class AssetGenerator extends Generator {
|
|
|
633
638
|
case "asset": {
|
|
634
639
|
return new RawSource(error.message);
|
|
635
640
|
}
|
|
636
|
-
case
|
|
641
|
+
case JAVASCRIPT_TYPE: {
|
|
637
642
|
return new RawSource(
|
|
638
643
|
`throw new Error(${JSON.stringify(error.message)});`
|
|
639
644
|
);
|
|
@@ -662,24 +667,24 @@ class AssetGenerator extends Generator {
|
|
|
662
667
|
|
|
663
668
|
if ((module.buildInfo && module.buildInfo.dataUrl) || this.emit === false) {
|
|
664
669
|
if (sourceTypes.size > 0) {
|
|
665
|
-
if (sourceTypes.has(
|
|
666
|
-
return
|
|
667
|
-
} else if (sourceTypes.has(
|
|
670
|
+
if (sourceTypes.has(JAVASCRIPT_TYPE) && sourceTypes.has(CSS_TYPE)) {
|
|
671
|
+
return JAVASCRIPT_AND_CSS_URL_TYPES;
|
|
672
|
+
} else if (sourceTypes.has(CSS_TYPE)) {
|
|
668
673
|
return CSS_URL_TYPES;
|
|
669
674
|
}
|
|
670
|
-
return
|
|
675
|
+
return JAVASCRIPT_TYPES;
|
|
671
676
|
}
|
|
672
677
|
|
|
673
678
|
return NO_TYPES;
|
|
674
679
|
}
|
|
675
680
|
|
|
676
681
|
if (sourceTypes.size > 0) {
|
|
677
|
-
if (sourceTypes.has(
|
|
678
|
-
return
|
|
679
|
-
} else if (sourceTypes.has(
|
|
682
|
+
if (sourceTypes.has(JAVASCRIPT_TYPE) && sourceTypes.has(CSS_TYPE)) {
|
|
683
|
+
return ASSET_AND_JAVASCRIPT_AND_CSS_URL_TYPES;
|
|
684
|
+
} else if (sourceTypes.has(CSS_TYPE)) {
|
|
680
685
|
return ASSET_AND_CSS_URL_TYPES;
|
|
681
686
|
}
|
|
682
|
-
return
|
|
687
|
+
return ASSET_AND_JAVASCRIPT_TYPES;
|
|
683
688
|
}
|
|
684
689
|
|
|
685
690
|
return ASSET_TYPES;
|
|
@@ -687,7 +692,7 @@ class AssetGenerator extends Generator {
|
|
|
687
692
|
|
|
688
693
|
/**
|
|
689
694
|
* @param {NormalModule} module the module
|
|
690
|
-
* @param {
|
|
695
|
+
* @param {SourceType=} type source type
|
|
691
696
|
* @returns {number} estimate size of the module
|
|
692
697
|
*/
|
|
693
698
|
getSize(module, type) {
|
|
@@ -9,16 +9,20 @@ const { RawSource } = require("webpack-sources");
|
|
|
9
9
|
const ConcatenationScope = require("../ConcatenationScope");
|
|
10
10
|
const Generator = require("../Generator");
|
|
11
11
|
const {
|
|
12
|
+
CSS_TYPE,
|
|
13
|
+
CSS_URL_TYPE,
|
|
12
14
|
CSS_URL_TYPES,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
JAVASCRIPT_AND_CSS_URL_TYPES,
|
|
16
|
+
JAVASCRIPT_TYPE,
|
|
17
|
+
JAVASCRIPT_TYPES,
|
|
15
18
|
NO_TYPES
|
|
16
|
-
} = require("../
|
|
19
|
+
} = require("../ModuleSourceTypeConstants");
|
|
17
20
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
18
21
|
|
|
19
22
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
20
23
|
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
|
21
24
|
/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
|
25
|
+
/** @typedef {import("../Module").SourceType} SourceType */
|
|
22
26
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
23
27
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
24
28
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
@@ -46,7 +50,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
46
50
|
const data = getData ? getData() : undefined;
|
|
47
51
|
|
|
48
52
|
switch (type) {
|
|
49
|
-
case
|
|
53
|
+
case JAVASCRIPT_TYPE: {
|
|
50
54
|
if (!originalSource) {
|
|
51
55
|
return new RawSource("");
|
|
52
56
|
}
|
|
@@ -65,13 +69,13 @@ class AssetSourceGenerator extends Generator {
|
|
|
65
69
|
} = ${JSON.stringify(encodedSource)};`;
|
|
66
70
|
} else {
|
|
67
71
|
runtimeRequirements.add(RuntimeGlobals.module);
|
|
68
|
-
sourceContent = `${
|
|
72
|
+
sourceContent = `${module.moduleArgument}.exports = ${JSON.stringify(
|
|
69
73
|
encodedSource
|
|
70
74
|
)};`;
|
|
71
75
|
}
|
|
72
76
|
return new RawSource(sourceContent);
|
|
73
77
|
}
|
|
74
|
-
case
|
|
78
|
+
case CSS_URL_TYPE: {
|
|
75
79
|
if (!originalSource) {
|
|
76
80
|
return null;
|
|
77
81
|
}
|
|
@@ -98,7 +102,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
98
102
|
*/
|
|
99
103
|
generateError(error, module, generateContext) {
|
|
100
104
|
switch (generateContext.type) {
|
|
101
|
-
case
|
|
105
|
+
case JAVASCRIPT_TYPE: {
|
|
102
106
|
return new RawSource(
|
|
103
107
|
`throw new Error(${JSON.stringify(error.message)});`
|
|
104
108
|
);
|
|
@@ -135,12 +139,12 @@ class AssetSourceGenerator extends Generator {
|
|
|
135
139
|
}
|
|
136
140
|
|
|
137
141
|
if (sourceTypes.size > 0) {
|
|
138
|
-
if (sourceTypes.has(
|
|
139
|
-
return
|
|
140
|
-
} else if (sourceTypes.has(
|
|
142
|
+
if (sourceTypes.has(JAVASCRIPT_TYPE) && sourceTypes.has(CSS_TYPE)) {
|
|
143
|
+
return JAVASCRIPT_AND_CSS_URL_TYPES;
|
|
144
|
+
} else if (sourceTypes.has(CSS_TYPE)) {
|
|
141
145
|
return CSS_URL_TYPES;
|
|
142
146
|
}
|
|
143
|
-
return
|
|
147
|
+
return JAVASCRIPT_TYPES;
|
|
144
148
|
}
|
|
145
149
|
|
|
146
150
|
return NO_TYPES;
|
|
@@ -148,7 +152,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
148
152
|
|
|
149
153
|
/**
|
|
150
154
|
* @param {NormalModule} module the module
|
|
151
|
-
* @param {
|
|
155
|
+
* @param {SourceType=} type source type
|
|
152
156
|
* @returns {number} estimate size of the module
|
|
153
157
|
*/
|
|
154
158
|
getSize(module, type) {
|
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
const { RawSource } = require("webpack-sources");
|
|
9
9
|
const Module = require("../Module");
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
JAVASCRIPT_TYPE,
|
|
12
|
+
JAVASCRIPT_TYPES
|
|
13
|
+
} = require("../ModuleSourceTypeConstants");
|
|
11
14
|
const { ASSET_MODULE_TYPE_RAW_DATA_URL } = require("../ModuleTypeConstants");
|
|
12
15
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
13
16
|
const makeSerializable = require("../util/makeSerializable");
|
|
@@ -47,7 +50,7 @@ class RawDataUrlModule extends Module {
|
|
|
47
50
|
* @returns {SourceTypes} types available (do not mutate)
|
|
48
51
|
*/
|
|
49
52
|
getSourceTypes() {
|
|
50
|
-
return
|
|
53
|
+
return JAVASCRIPT_TYPES;
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
/**
|
|
@@ -113,7 +116,7 @@ class RawDataUrlModule extends Module {
|
|
|
113
116
|
}
|
|
114
117
|
const sources = new Map();
|
|
115
118
|
sources.set(
|
|
116
|
-
|
|
119
|
+
JAVASCRIPT_TYPE,
|
|
117
120
|
new RawSource(`module.exports = ${JSON.stringify(this.url)};`)
|
|
118
121
|
);
|
|
119
122
|
const data = new Map();
|
package/lib/buildChunkGraph.js
CHANGED
|
@@ -352,10 +352,12 @@ const visitModules = (
|
|
|
352
352
|
/** @type {Map<ChunkGroupInfo, Set<DependenciesBlock>>} */
|
|
353
353
|
const blocksByChunkGroups = new Map();
|
|
354
354
|
|
|
355
|
-
/** @
|
|
355
|
+
/** @typedef {Map<string, ChunkGroupInfo>} NamedChunkGroup */
|
|
356
|
+
|
|
357
|
+
/** @type {NamedChunkGroup} */
|
|
356
358
|
const namedChunkGroups = new Map();
|
|
357
359
|
|
|
358
|
-
/** @type {
|
|
360
|
+
/** @type {NamedChunkGroup} */
|
|
359
361
|
const namedAsyncEntrypoints = new Map();
|
|
360
362
|
|
|
361
363
|
/** @type {Set<ChunkGroupInfo>} */
|
|
@@ -18,6 +18,7 @@ const {
|
|
|
18
18
|
} = require("../util/serialization");
|
|
19
19
|
|
|
20
20
|
/** @typedef {import("../../declarations/WebpackOptions").SnapshotOptions} SnapshotOptions */
|
|
21
|
+
/** @typedef {import("../Compilation").FileSystemDependencies} FileSystemDependencies */
|
|
21
22
|
/** @typedef {import("../Cache").Data} Data */
|
|
22
23
|
/** @typedef {import("../Cache").Etag} Etag */
|
|
23
24
|
/** @typedef {import("../Compiler")} Compiler */
|
|
@@ -51,7 +52,7 @@ class PackContainer {
|
|
|
51
52
|
resolveResults,
|
|
52
53
|
resolveBuildDependenciesSnapshot
|
|
53
54
|
) {
|
|
54
|
-
/** @type {Pack | (() => Pack)
|
|
55
|
+
/** @type {Pack | (() => Pack)} */
|
|
55
56
|
this.data = data;
|
|
56
57
|
/** @type {string} */
|
|
57
58
|
this.version = version;
|
|
@@ -395,7 +396,7 @@ class Pack {
|
|
|
395
396
|
return;
|
|
396
397
|
}
|
|
397
398
|
|
|
398
|
-
/** @type {PackContent[]
|
|
399
|
+
/** @type {PackContent[]} */
|
|
399
400
|
const mergedContent = [];
|
|
400
401
|
|
|
401
402
|
// 3. Remove old content entries
|
|
@@ -1109,7 +1110,7 @@ class PackFileCacheStrategy {
|
|
|
1109
1110
|
compression,
|
|
1110
1111
|
readonly
|
|
1111
1112
|
}) {
|
|
1112
|
-
/** @type {import("../serialization/Serializer")<PackContainer, null,
|
|
1113
|
+
/** @type {import("../serialization/Serializer")<PackContainer, null, EXPECTED_OBJECT>} */
|
|
1113
1114
|
this.fileSerializer = createFileSerializer(
|
|
1114
1115
|
fs,
|
|
1115
1116
|
/** @type {string | Hash} */
|
|
@@ -1140,7 +1141,7 @@ class PackFileCacheStrategy {
|
|
|
1140
1141
|
this.snapshot = snapshot;
|
|
1141
1142
|
/** @type {BuildDependencies} */
|
|
1142
1143
|
this.buildDependencies = new Set();
|
|
1143
|
-
/** @type {
|
|
1144
|
+
/** @type {FileSystemDependencies} */
|
|
1144
1145
|
this.newBuildDependencies = new LazySet();
|
|
1145
1146
|
/** @type {Snapshot | undefined} */
|
|
1146
1147
|
this.resolveBuildDependenciesSnapshot = undefined;
|
|
@@ -1364,7 +1365,7 @@ class PackFileCacheStrategy {
|
|
|
1364
1365
|
}
|
|
1365
1366
|
|
|
1366
1367
|
/**
|
|
1367
|
-
* @param {
|
|
1368
|
+
* @param {FileSystemDependencies | Iterable<string>} dependencies dependencies to store
|
|
1368
1369
|
*/
|
|
1369
1370
|
storeBuildDependencies(dependencies) {
|
|
1370
1371
|
if (this.readonly) return;
|
package/lib/cli.js
CHANGED
|
@@ -795,49 +795,8 @@ const init = (open, close, replace) =>
|
|
|
795
795
|
filterEmpty(`\u001B[${open}m`, `\u001B[${close}m`, replace);
|
|
796
796
|
|
|
797
797
|
/**
|
|
798
|
-
* @typedef {{
|
|
799
|
-
|
|
800
|
-
* bold: PrintFunction
|
|
801
|
-
* dim: PrintFunction
|
|
802
|
-
* italic: PrintFunction
|
|
803
|
-
* underline: PrintFunction
|
|
804
|
-
* inverse: PrintFunction
|
|
805
|
-
* hidden: PrintFunction
|
|
806
|
-
* strikethrough: PrintFunction
|
|
807
|
-
* black: PrintFunction
|
|
808
|
-
* red: PrintFunction
|
|
809
|
-
* green: PrintFunction
|
|
810
|
-
* yellow: PrintFunction
|
|
811
|
-
* blue: PrintFunction
|
|
812
|
-
* magenta: PrintFunction
|
|
813
|
-
* cyan: PrintFunction
|
|
814
|
-
* white: PrintFunction
|
|
815
|
-
* gray: PrintFunction
|
|
816
|
-
* bgBlack: PrintFunction
|
|
817
|
-
* bgRed: PrintFunction
|
|
818
|
-
* bgGreen: PrintFunction
|
|
819
|
-
* bgYellow: PrintFunction
|
|
820
|
-
* bgBlue: PrintFunction
|
|
821
|
-
* bgMagenta: PrintFunction
|
|
822
|
-
* bgCyan: PrintFunction
|
|
823
|
-
* bgWhite: PrintFunction
|
|
824
|
-
* blackBright: PrintFunction
|
|
825
|
-
* redBright: PrintFunction
|
|
826
|
-
* greenBright: PrintFunction
|
|
827
|
-
* yellowBright: PrintFunction
|
|
828
|
-
* blueBright: PrintFunction
|
|
829
|
-
* magentaBright: PrintFunction
|
|
830
|
-
* cyanBright: PrintFunction
|
|
831
|
-
* whiteBright: PrintFunction
|
|
832
|
-
* bgBlackBright: PrintFunction
|
|
833
|
-
* bgRedBright: PrintFunction
|
|
834
|
-
* bgGreenBright: PrintFunction
|
|
835
|
-
* bgYellowBright: PrintFunction
|
|
836
|
-
* bgBlueBright: PrintFunction
|
|
837
|
-
* bgMagentaBright: PrintFunction
|
|
838
|
-
* bgCyanBright: PrintFunction
|
|
839
|
-
* bgWhiteBright: PrintFunction
|
|
840
|
-
}} Colors */
|
|
798
|
+
* @typedef {{ reset: PrintFunction, bold: PrintFunction, dim: PrintFunction, italic: PrintFunction, underline: PrintFunction, inverse: PrintFunction, hidden: PrintFunction, strikethrough: PrintFunction, black: PrintFunction, red: PrintFunction, green: PrintFunction, yellow: PrintFunction, blue: PrintFunction, magenta: PrintFunction, cyan: PrintFunction, white: PrintFunction, gray: PrintFunction, bgBlack: PrintFunction, bgRed: PrintFunction, bgGreen: PrintFunction, bgYellow: PrintFunction, bgBlue: PrintFunction, bgMagenta: PrintFunction, bgCyan: PrintFunction, bgWhite: PrintFunction, blackBright: PrintFunction, redBright: PrintFunction, greenBright: PrintFunction, yellowBright: PrintFunction, blueBright: PrintFunction, magentaBright: PrintFunction, cyanBright: PrintFunction, whiteBright: PrintFunction, bgBlackBright: PrintFunction, bgRedBright: PrintFunction, bgGreenBright: PrintFunction, bgYellowBright: PrintFunction, bgBlueBright: PrintFunction, bgMagentaBright: PrintFunction, bgCyanBright: PrintFunction, bgWhiteBright: PrintFunction }} Colors
|
|
799
|
+
*/
|
|
841
800
|
|
|
842
801
|
/**
|
|
843
802
|
* @typedef {object} ColorsOptions
|
|
@@ -118,6 +118,25 @@ const resolve = (browsers) => {
|
|
|
118
118
|
kaios: [2, 5],
|
|
119
119
|
node: [6, 0]
|
|
120
120
|
}),
|
|
121
|
+
methodShorthand: rawChecker({
|
|
122
|
+
chrome: 47,
|
|
123
|
+
and_chr: 47,
|
|
124
|
+
edge: 12,
|
|
125
|
+
firefox: 34,
|
|
126
|
+
and_ff: 34,
|
|
127
|
+
// ie: Not supported,
|
|
128
|
+
opera: 34,
|
|
129
|
+
op_mob: 34,
|
|
130
|
+
safari: 9,
|
|
131
|
+
ios_saf: 9,
|
|
132
|
+
samsung: 5,
|
|
133
|
+
android: 47,
|
|
134
|
+
// baidu: Not tracked,
|
|
135
|
+
and_qq: [14, 9],
|
|
136
|
+
and_uc: [15, 5],
|
|
137
|
+
kaios: [2, 5],
|
|
138
|
+
node: [4, 9]
|
|
139
|
+
}),
|
|
121
140
|
arrowFunction: rawChecker({
|
|
122
141
|
chrome: 45,
|
|
123
142
|
and_chr: 45,
|
|
@@ -354,6 +373,11 @@ const resolve = (browsers) => {
|
|
|
354
373
|
rawChecker({
|
|
355
374
|
node: [14, 18]
|
|
356
375
|
}),
|
|
376
|
+
importMetaDirnameAndFilename:
|
|
377
|
+
nodeProperty &&
|
|
378
|
+
rawChecker({
|
|
379
|
+
node: [22, 16]
|
|
380
|
+
}),
|
|
357
381
|
require: nodeProperty
|
|
358
382
|
};
|
|
359
383
|
};
|