webpack 5.106.2 → 5.107.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/lib/APIPlugin.js +1 -1
- package/lib/BannerPlugin.js +3 -4
- package/lib/Cache.js +3 -6
- package/lib/Chunk.js +21 -25
- package/lib/ChunkGroup.js +57 -15
- package/lib/CompatibilityPlugin.js +8 -7
- package/lib/Compilation.js +67 -37
- package/lib/Compiler.js +4 -13
- package/lib/ContextModule.js +2 -2
- package/lib/DefinePlugin.js +2 -2
- package/lib/Dependency.js +22 -1
- package/lib/DependencyTemplate.js +2 -1
- package/lib/EnvironmentPlugin.js +1 -1
- package/lib/EvalSourceMapDevToolPlugin.js +8 -10
- package/lib/ExportsInfo.js +30 -34
- package/lib/ExternalModule.js +91 -26
- package/lib/ExternalModuleFactoryPlugin.js +7 -1
- package/lib/FileSystemInfo.js +187 -72
- package/lib/Generator.js +3 -3
- package/lib/HotModuleReplacementPlugin.js +26 -8
- package/lib/IgnorePlugin.js +2 -1
- package/lib/Module.js +20 -19
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleNotFoundError.js +3 -84
- package/lib/ModuleSourceTypeConstants.js +51 -19
- package/lib/ModuleTypeConstants.js +12 -3
- package/lib/MultiCompiler.js +2 -2
- package/lib/NodeStuffPlugin.js +1 -1
- package/lib/NormalModule.js +119 -77
- package/lib/NormalModuleFactory.js +47 -27
- package/lib/Parser.js +1 -1
- package/lib/ProgressPlugin.js +129 -56
- package/lib/RuntimeGlobals.js +5 -5
- package/lib/RuntimeModule.js +9 -7
- package/lib/RuntimePlugin.js +12 -1
- package/lib/SourceMapDevToolPlugin.js +250 -49
- package/lib/Template.js +1 -1
- package/lib/TemplatedPathPlugin.js +22 -4
- package/lib/WarnCaseSensitiveModulesPlugin.js +70 -2
- package/lib/WarnDeprecatedOptionPlugin.js +1 -1
- package/lib/WarnNoModeSetPlugin.js +16 -1
- package/lib/Watching.js +2 -3
- package/lib/WebpackError.js +3 -77
- package/lib/WebpackIsIncludedPlugin.js +1 -1
- package/lib/WebpackOptionsApply.js +13 -1
- package/lib/asset/AssetBytesGenerator.js +12 -8
- package/lib/asset/AssetGenerator.js +36 -22
- package/lib/asset/AssetModulesPlugin.js +6 -8
- package/lib/asset/AssetSourceGenerator.js +12 -8
- package/lib/buildChunkGraph.js +4 -6
- package/lib/cache/PackFileCacheStrategy.js +4 -4
- package/lib/cli.js +3 -1
- package/lib/config/defaults.js +197 -10
- package/lib/config/normalization.js +3 -1
- package/lib/css/CssGenerator.js +320 -105
- package/lib/css/CssInjectStyleRuntimeModule.js +44 -42
- package/lib/css/CssLoadingRuntimeModule.js +22 -4
- package/lib/{CssModule.js → css/CssModule.js} +15 -15
- package/lib/css/CssModulesPlugin.js +168 -88
- package/lib/css/CssParser.js +566 -269
- package/lib/css/walkCssTokens.js +148 -2
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -1
- package/lib/dependencies/CommonJsDependencyHelpers.js +63 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +54 -10
- package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -1
- package/lib/dependencies/CommonJsFullRequireDependency.js +32 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +112 -4
- package/lib/dependencies/CommonJsRequireDependency.js +67 -4
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +1 -1
- package/lib/dependencies/CreateRequireParserPlugin.js +1 -1
- package/lib/dependencies/CriticalDependencyWarning.js +1 -1
- package/lib/dependencies/CssIcssExportDependency.js +332 -67
- package/lib/dependencies/CssIcssImportDependency.js +49 -7
- package/lib/dependencies/CssIcssSymbolDependency.js +11 -3
- package/lib/dependencies/CssImportDependency.js +8 -0
- package/lib/dependencies/CssUrlDependency.js +28 -2
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +22 -2
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +8 -7
- package/lib/dependencies/HarmonyExportExpressionDependency.js +22 -14
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +110 -3
- package/lib/dependencies/HarmonyImportDependency.js +10 -2
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +22 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +1 -1
- package/lib/{HarmonyLinkingError.js → dependencies/HarmonyLinkingError.js} +5 -3
- package/lib/dependencies/HtmlInlineScriptDependency.js +133 -0
- package/lib/dependencies/HtmlInlineStyleDependency.js +101 -0
- package/lib/dependencies/HtmlScriptSrcDependency.js +557 -0
- package/lib/dependencies/HtmlSourceDependency.js +128 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/ImportParserPlugin.js +2 -2
- package/lib/dependencies/ImportPhase.js +1 -1
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +1 -1
- package/lib/{RequireJsStuffPlugin.js → dependencies/RequireJsStuffPlugin.js} +7 -7
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/WebAssemblyImportDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +2 -2
- package/lib/{DelegatedModule.js → dll/DelegatedModule.js} +31 -31
- package/lib/{DelegatedModuleFactoryPlugin.js → dll/DelegatedModuleFactoryPlugin.js} +4 -4
- package/lib/{DelegatedPlugin.js → dll/DelegatedPlugin.js} +2 -2
- package/lib/{DllEntryPlugin.js → dll/DllEntryPlugin.js} +4 -4
- package/lib/{DllModule.js → dll/DllModule.js} +24 -24
- package/lib/{DllModuleFactory.js → dll/DllModuleFactory.js} +4 -4
- package/lib/{DllPlugin.js → dll/DllPlugin.js} +6 -5
- package/lib/{DllReferencePlugin.js → dll/DllReferencePlugin.js} +14 -14
- package/lib/{LibManifestPlugin.js → dll/LibManifestPlugin.js} +9 -9
- package/lib/{AsyncDependencyToInitialChunkError.js → errors/AsyncDependencyToInitialChunkError.js} +2 -2
- package/lib/errors/BuildCycleError.js +1 -1
- package/lib/{ChunkRenderError.js → errors/ChunkRenderError.js} +1 -1
- package/lib/{CodeGenerationError.js → errors/CodeGenerationError.js} +1 -1
- package/lib/{CommentCompilationWarning.js → errors/CommentCompilationWarning.js} +3 -3
- package/lib/{ConcurrentCompilationError.js → errors/ConcurrentCompilationError.js} +4 -2
- package/lib/{EnvironmentNotSupportAsyncWarning.js → errors/EnvironmentNotSupportAsyncWarning.js} +4 -4
- package/lib/{HookWebpackError.js → errors/HookWebpackError.js} +5 -5
- package/lib/{IgnoreErrorModuleFactory.js → errors/IgnoreErrorModuleFactory.js} +4 -4
- package/lib/{InvalidDependenciesModuleWarning.js → errors/InvalidDependenciesModuleWarning.js} +3 -3
- package/lib/errors/JSONParseError.js +114 -0
- package/lib/{ModuleBuildError.js → errors/ModuleBuildError.js} +5 -5
- package/lib/{ModuleDependencyError.js → errors/ModuleDependencyError.js} +2 -2
- package/lib/{ModuleDependencyWarning.js → errors/ModuleDependencyWarning.js} +4 -4
- package/lib/{ModuleError.js → errors/ModuleError.js} +5 -5
- package/lib/{ModuleHashingError.js → errors/ModuleHashingError.js} +1 -1
- package/lib/errors/ModuleNotFoundError.js +91 -0
- package/lib/{ModuleParseError.js → errors/ModuleParseError.js} +8 -6
- package/lib/{ModuleRestoreError.js → errors/ModuleRestoreError.js} +1 -1
- package/lib/{ModuleStoreError.js → errors/ModuleStoreError.js} +1 -1
- package/lib/{ModuleWarning.js → errors/ModuleWarning.js} +5 -5
- package/lib/{NodeStuffInWebError.js → errors/NodeStuffInWebError.js} +4 -4
- package/lib/errors/NonErrorEmittedError.js +28 -0
- package/lib/{UnhandledSchemeError.js → errors/UnhandledSchemeError.js} +2 -2
- package/lib/{UnsupportedFeatureWarning.js → errors/UnsupportedFeatureWarning.js} +3 -3
- package/lib/errors/WebpackError.js +84 -0
- package/lib/html/HtmlGenerator.js +379 -0
- package/lib/html/HtmlModulesPlugin.js +429 -0
- package/lib/html/HtmlParser.js +1489 -0
- package/lib/html/walkHtmlTokens.js +3249 -0
- package/lib/ids/IdHelpers.js +2 -1
- package/lib/index.js +36 -15
- package/lib/javascript/JavascriptModulesPlugin.js +91 -10
- package/lib/javascript/JavascriptParser.js +197 -16
- package/lib/javascript/JavascriptParserHelpers.js +1 -1
- package/lib/json/JsonParser.js +7 -16
- package/lib/library/AbstractLibraryPlugin.js +1 -1
- package/lib/library/EnableLibraryPlugin.js +1 -1
- package/lib/{FalseIIFEUmdWarning.js → library/FalseIIFEUmdWarning.js} +1 -1
- package/lib/library/ModuleLibraryPlugin.js +74 -0
- package/lib/node/NodeEnvironmentPlugin.js +4 -2
- package/lib/node/nodeConsole.js +113 -64
- package/lib/optimize/ConcatenatedModule.js +51 -6
- package/lib/optimize/InnerGraph.js +1 -1
- package/lib/optimize/InnerGraphPlugin.js +11 -1
- package/lib/optimize/MinMaxSizeWarning.js +4 -4
- package/lib/optimize/ModuleConcatenationPlugin.js +15 -7
- package/lib/optimize/RealContentHashPlugin.js +89 -26
- package/lib/optimize/SideEffectsFlagPlugin.js +112 -5
- package/lib/optimize/SplitChunksPlugin.js +5 -5
- package/lib/performance/AssetsOverSizeLimitWarning.js +2 -2
- package/lib/performance/EntrypointsOverSizeLimitWarning.js +2 -2
- package/lib/performance/NoAsyncChunksWarning.js +5 -3
- package/lib/performance/SizeLimitsPlugin.js +1 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +4 -1
- package/lib/rules/UseEffectRulePlugin.js +4 -3
- package/lib/runtime/AutoPublicPathRuntimeModule.js +3 -3
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -5
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +119 -13
- package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +35 -0
- package/lib/schemes/DataUriPlugin.js +13 -1
- package/lib/schemes/VirtualUrlPlugin.js +1 -1
- package/lib/serialization/SerializerMiddleware.js +2 -2
- package/lib/sharing/ConsumeSharedPlugin.js +4 -10
- package/lib/sharing/ConsumeSharedRuntimeModule.js +8 -4
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +5 -5
- package/lib/sharing/resolveMatchedConfigs.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +2 -2
- package/lib/stats/DefaultStatsPresetPlugin.js +1 -1
- package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
- package/lib/stats/StatsFactory.js +1 -1
- package/lib/typescript/TypeScriptPlugin.js +210 -0
- package/lib/url/URLParserPlugin.js +2 -2
- package/lib/util/AsyncQueue.js +2 -2
- package/lib/util/Hash.js +2 -2
- package/lib/util/LocConverter.js +53 -0
- package/lib/util/SortableSet.js +1 -1
- package/lib/util/cleverMerge.js +2 -2
- package/lib/util/comparators.js +3 -3
- package/lib/util/concatenate.js +3 -3
- package/lib/util/conventions.js +42 -1
- package/lib/util/createMappings.js +118 -0
- package/lib/{formatLocation.js → util/formatLocation.js} +2 -2
- package/lib/{SizeFormatHelpers.js → util/formatSize.js} +3 -1
- package/lib/util/fs.js +8 -8
- package/lib/util/hash/md4.js +1 -1
- package/lib/util/hash/xxhash64.js +1 -1
- package/lib/util/identifier.js +48 -0
- package/lib/util/internalSerializables.js +35 -19
- package/lib/util/magicComment.js +10 -7
- package/lib/util/parseJson.js +2 -73
- package/lib/util/source.js +21 -0
- package/lib/util/topologicalSort.js +69 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -4
- package/lib/wasm-async/AsyncWebAssemblyParser.js +1 -1
- package/lib/wasm-sync/UnsupportedWebAssemblyFeatureError.js +5 -3
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +1 -1
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +5 -3
- package/lib/webpack.js +3 -1
- package/package.json +24 -22
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +129 -12
- package/schemas/plugins/{DllPlugin.check.d.ts → HtmlGeneratorOptions.check.d.ts} +1 -1
- package/schemas/plugins/HtmlGeneratorOptions.check.js +6 -0
- package/schemas/plugins/HtmlGeneratorOptions.json +3 -0
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.json +22 -0
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
- package/schemas/plugins/{DllReferencePlugin.check.d.ts → css/CssAutoOrModuleParserOptions.check.d.ts} +1 -1
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.json +3 -0
- package/schemas/plugins/dll/DllPlugin.check.d.ts +7 -0
- package/schemas/plugins/dll/DllReferencePlugin.check.d.ts +7 -0
- package/types.d.ts +1153 -233
- package/lib/CaseSensitiveModulesWarning.js +0 -80
- package/lib/GraphHelpers.js +0 -49
- package/lib/NoModeWarning.js +0 -23
- package/lib/css/CssMergeStyleSheetsRuntimeModule.js +0 -57
- /package/lib/{AbstractMethodError.js → errors/AbstractMethodError.js} +0 -0
- /package/schemas/plugins/{DllPlugin.check.js → dll/DllPlugin.check.js} +0 -0
- /package/schemas/plugins/{DllPlugin.json → dll/DllPlugin.json} +0 -0
- /package/schemas/plugins/{DllReferencePlugin.check.js → dll/DllReferencePlugin.check.js} +0 -0
- /package/schemas/plugins/{DllReferencePlugin.json → dll/DllReferencePlugin.json} +0 -0
package/lib/WebpackError.js
CHANGED
|
@@ -5,80 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/** @typedef {import("./Chunk")} Chunk */
|
|
12
|
-
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
|
13
|
-
/** @typedef {import("./Module")} Module */
|
|
14
|
-
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
15
|
-
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
16
|
-
|
|
17
|
-
class WebpackError extends Error {
|
|
18
|
-
/**
|
|
19
|
-
* Creates an instance of WebpackError.
|
|
20
|
-
* @param {string=} message error message
|
|
21
|
-
* @param {{ cause?: unknown }} options error options
|
|
22
|
-
*/
|
|
23
|
-
constructor(message, options = {}) {
|
|
24
|
-
super(message, options);
|
|
25
|
-
|
|
26
|
-
/** @type {string=} */
|
|
27
|
-
this.details = undefined;
|
|
28
|
-
/** @type {(Module | null)=} */
|
|
29
|
-
this.module = undefined;
|
|
30
|
-
/** @type {DependencyLocation=} */
|
|
31
|
-
this.loc = undefined;
|
|
32
|
-
/** @type {boolean=} */
|
|
33
|
-
this.hideStack = undefined;
|
|
34
|
-
/** @type {Chunk=} */
|
|
35
|
-
this.chunk = undefined;
|
|
36
|
-
/** @type {string=} */
|
|
37
|
-
this.file = undefined;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Returns inspect message.
|
|
42
|
-
* @returns {string} inspect message
|
|
43
|
-
*/
|
|
44
|
-
[inspect]() {
|
|
45
|
-
return (
|
|
46
|
-
this.stack +
|
|
47
|
-
(this.details ? `\n${this.details}` : "") +
|
|
48
|
-
(this.cause ? `\n${this.cause}` : "")
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Serializes this instance into the provided serializer context.
|
|
54
|
-
* @param {ObjectSerializerContext} context context
|
|
55
|
-
*/
|
|
56
|
-
serialize({ write }) {
|
|
57
|
-
write(this.name);
|
|
58
|
-
write(this.message);
|
|
59
|
-
write(this.stack);
|
|
60
|
-
write(this.cause);
|
|
61
|
-
write(this.details);
|
|
62
|
-
write(this.loc);
|
|
63
|
-
write(this.hideStack);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Restores this instance from the provided deserializer context.
|
|
68
|
-
* @param {ObjectDeserializerContext} context context
|
|
69
|
-
*/
|
|
70
|
-
deserialize({ read }) {
|
|
71
|
-
this.name = read();
|
|
72
|
-
this.message = read();
|
|
73
|
-
this.stack = read();
|
|
74
|
-
this.cause = read();
|
|
75
|
-
this.details = read();
|
|
76
|
-
this.loc = read();
|
|
77
|
-
this.hideStack = read();
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
makeSerializable(WebpackError, "webpack/lib/WebpackError");
|
|
82
|
-
|
|
83
|
-
/** @type {typeof WebpackError} */
|
|
84
|
-
module.exports = WebpackError;
|
|
8
|
+
// TODO remove in webpack 6
|
|
9
|
+
// Some old plugins use `require("webpack/lib/WebpackError")`, in webpack@6 developer should migrate to `compiler.webpack.WebpackError`
|
|
10
|
+
module.exports = require("./errors/WebpackError");
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const IgnoreErrorModuleFactory = require("./IgnoreErrorModuleFactory");
|
|
9
8
|
const {
|
|
10
9
|
JAVASCRIPT_MODULE_TYPE_AUTO,
|
|
11
10
|
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
|
12
11
|
JAVASCRIPT_MODULE_TYPE_ESM
|
|
13
12
|
} = require("./ModuleTypeConstants");
|
|
14
13
|
const WebpackIsIncludedDependency = require("./dependencies/WebpackIsIncludedDependency");
|
|
14
|
+
const IgnoreErrorModuleFactory = require("./errors/IgnoreErrorModuleFactory");
|
|
15
15
|
const {
|
|
16
16
|
toConstantDependency
|
|
17
17
|
} = require("./javascript/JavascriptParserHelpers");
|
|
@@ -425,6 +425,18 @@ class WebpackOptionsApply extends OptionsApply {
|
|
|
425
425
|
new CssModulesPlugin().apply(compiler);
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
+
if (options.experiments.html) {
|
|
429
|
+
const HtmlModulesPlugin = require("./html/HtmlModulesPlugin");
|
|
430
|
+
|
|
431
|
+
new HtmlModulesPlugin().apply(compiler);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
if (options.experiments.typescript) {
|
|
435
|
+
const TypeScriptPlugin = require("./typescript/TypeScriptPlugin");
|
|
436
|
+
|
|
437
|
+
new TypeScriptPlugin().apply(compiler);
|
|
438
|
+
}
|
|
439
|
+
|
|
428
440
|
if (options.experiments.lazyCompilation) {
|
|
429
441
|
const LazyCompilationPlugin = require("./hmr/LazyCompilationPlugin");
|
|
430
442
|
|
|
@@ -517,7 +529,7 @@ class WebpackOptionsApply extends OptionsApply {
|
|
|
517
529
|
}).apply(compiler);
|
|
518
530
|
if (options.amd !== false) {
|
|
519
531
|
const AMDPlugin = require("./dependencies/AMDPlugin");
|
|
520
|
-
const RequireJsStuffPlugin = require("./RequireJsStuffPlugin");
|
|
532
|
+
const RequireJsStuffPlugin = require("./dependencies/RequireJsStuffPlugin");
|
|
521
533
|
|
|
522
534
|
new AMDPlugin(options.amd || {}).apply(compiler);
|
|
523
535
|
new RequireJsStuffPlugin().apply(compiler);
|
|
@@ -9,10 +9,11 @@ const { RawSource } = require("webpack-sources");
|
|
|
9
9
|
const ConcatenationScope = require("../ConcatenationScope");
|
|
10
10
|
const Generator = require("../Generator");
|
|
11
11
|
const {
|
|
12
|
+
ASSET_URL_TYPE,
|
|
13
|
+
ASSET_URL_TYPES,
|
|
12
14
|
CSS_TYPE,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
JAVASCRIPT_AND_CSS_URL_TYPES,
|
|
15
|
+
HTML_TYPE,
|
|
16
|
+
JAVASCRIPT_AND_ASSET_URL_TYPES,
|
|
16
17
|
JAVASCRIPT_TYPE,
|
|
17
18
|
JAVASCRIPT_TYPES,
|
|
18
19
|
NO_TYPES
|
|
@@ -79,7 +80,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
79
80
|
}
|
|
80
81
|
return new RawSource(sourceContent);
|
|
81
82
|
}
|
|
82
|
-
case
|
|
83
|
+
case ASSET_URL_TYPE: {
|
|
83
84
|
if (!originalSource) {
|
|
84
85
|
return null;
|
|
85
86
|
}
|
|
@@ -146,10 +147,13 @@ class AssetSourceGenerator extends Generator {
|
|
|
146
147
|
}
|
|
147
148
|
|
|
148
149
|
if (sourceTypes.size > 0) {
|
|
149
|
-
if (
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
150
|
+
if (
|
|
151
|
+
sourceTypes.has(JAVASCRIPT_TYPE) &&
|
|
152
|
+
(sourceTypes.has(CSS_TYPE) || sourceTypes.has(HTML_TYPE))
|
|
153
|
+
) {
|
|
154
|
+
return JAVASCRIPT_AND_ASSET_URL_TYPES;
|
|
155
|
+
} else if (sourceTypes.has(CSS_TYPE) || sourceTypes.has(HTML_TYPE)) {
|
|
156
|
+
return ASSET_URL_TYPES;
|
|
153
157
|
}
|
|
154
158
|
return JAVASCRIPT_TYPES;
|
|
155
159
|
}
|
|
@@ -10,14 +10,15 @@ const { RawSource } = require("webpack-sources");
|
|
|
10
10
|
const ConcatenationScope = require("../ConcatenationScope");
|
|
11
11
|
const Generator = require("../Generator");
|
|
12
12
|
const {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
ASSET_AND_ASSET_URL_TYPES,
|
|
14
|
+
ASSET_AND_JAVASCRIPT_AND_ASSET_URL_TYPES,
|
|
15
15
|
ASSET_AND_JAVASCRIPT_TYPES,
|
|
16
16
|
ASSET_TYPES,
|
|
17
|
+
ASSET_URL_TYPE,
|
|
18
|
+
ASSET_URL_TYPES,
|
|
17
19
|
CSS_TYPE,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
JAVASCRIPT_AND_CSS_URL_TYPES,
|
|
20
|
+
HTML_TYPE,
|
|
21
|
+
JAVASCRIPT_AND_ASSET_URL_TYPES,
|
|
21
22
|
JAVASCRIPT_TYPE,
|
|
22
23
|
JAVASCRIPT_TYPES,
|
|
23
24
|
NO_TYPES
|
|
@@ -29,6 +30,7 @@ const createHash = require("../util/createHash");
|
|
|
29
30
|
const { makePathsRelative } = require("../util/identifier");
|
|
30
31
|
const memoize = require("../util/memoize");
|
|
31
32
|
const nonNumericOnlyHash = require("../util/nonNumericOnlyHash");
|
|
33
|
+
const { updateHashFromSource } = require("../util/source");
|
|
32
34
|
|
|
33
35
|
const getMimeTypes = memoize(() => require("../util/mimeTypes"));
|
|
34
36
|
|
|
@@ -259,7 +261,7 @@ class AssetGenerator extends Generator {
|
|
|
259
261
|
const source = module.originalSource();
|
|
260
262
|
|
|
261
263
|
if (source) {
|
|
262
|
-
hash
|
|
264
|
+
updateHashFromSource(hash, source);
|
|
263
265
|
}
|
|
264
266
|
|
|
265
267
|
if (module.error) {
|
|
@@ -371,7 +373,7 @@ class AssetGenerator extends Generator {
|
|
|
371
373
|
assetPath = JSON.stringify(path + filename);
|
|
372
374
|
} else if (
|
|
373
375
|
generatorOptions.publicPath !== undefined &&
|
|
374
|
-
type ===
|
|
376
|
+
type === ASSET_URL_TYPE
|
|
375
377
|
) {
|
|
376
378
|
const { path, info } = runtimeTemplate.compilation.getAssetPathWithInfo(
|
|
377
379
|
generatorOptions.publicPath,
|
|
@@ -392,13 +394,19 @@ class AssetGenerator extends Generator {
|
|
|
392
394
|
{ expr: RuntimeGlobals.publicPath },
|
|
393
395
|
filename
|
|
394
396
|
);
|
|
395
|
-
} else if (type ===
|
|
397
|
+
} else if (type === ASSET_URL_TYPE) {
|
|
396
398
|
const compilation = runtimeTemplate.compilation;
|
|
397
399
|
const path =
|
|
398
400
|
compilation.outputOptions.publicPath === "auto"
|
|
399
401
|
? CssUrlDependency.PUBLIC_PATH_AUTO
|
|
400
402
|
: compilation.getAssetPath(compilation.outputOptions.publicPath, {
|
|
401
|
-
hash:
|
|
403
|
+
hash:
|
|
404
|
+
compilation.hash ||
|
|
405
|
+
`${CssUrlDependency.PUBLIC_PATH_FULL_HASH}0__`,
|
|
406
|
+
hashWithLength: (length) =>
|
|
407
|
+
compilation.hash
|
|
408
|
+
? compilation.hash.slice(0, length)
|
|
409
|
+
: `${CssUrlDependency.PUBLIC_PATH_FULL_HASH}${length}__`
|
|
402
410
|
});
|
|
403
411
|
|
|
404
412
|
assetPath = path + filename;
|
|
@@ -552,7 +560,7 @@ class AssetGenerator extends Generator {
|
|
|
552
560
|
/** @type {string} */
|
|
553
561
|
let content;
|
|
554
562
|
|
|
555
|
-
const needContent = type === JAVASCRIPT_TYPE || type ===
|
|
563
|
+
const needContent = type === JAVASCRIPT_TYPE || type === ASSET_URL_TYPE;
|
|
556
564
|
const data = getData ? getData() : undefined;
|
|
557
565
|
|
|
558
566
|
if (
|
|
@@ -567,7 +575,7 @@ class AssetGenerator extends Generator {
|
|
|
567
575
|
: encodedSource;
|
|
568
576
|
|
|
569
577
|
if (data) {
|
|
570
|
-
data.set("url", {
|
|
578
|
+
data.set("url", { ...data.get("url"), [type]: content });
|
|
571
579
|
}
|
|
572
580
|
} else {
|
|
573
581
|
const [fullContentHash, contentHash] = AssetGenerator.getFullContentHash(
|
|
@@ -605,8 +613,8 @@ class AssetGenerator extends Generator {
|
|
|
605
613
|
contentHash
|
|
606
614
|
);
|
|
607
615
|
|
|
608
|
-
if (data && (type === JAVASCRIPT_TYPE || type ===
|
|
609
|
-
data.set("url", {
|
|
616
|
+
if (data && (type === JAVASCRIPT_TYPE || type === ASSET_URL_TYPE)) {
|
|
617
|
+
data.set("url", { ...data.get("url"), [type]: assetPath });
|
|
610
618
|
}
|
|
611
619
|
|
|
612
620
|
if (data) {
|
|
@@ -649,7 +657,7 @@ class AssetGenerator extends Generator {
|
|
|
649
657
|
runtimeRequirements.add(RuntimeGlobals.module);
|
|
650
658
|
|
|
651
659
|
return new RawSource(`${module.moduleArgument}.exports = ${content};`);
|
|
652
|
-
} else if (type ===
|
|
660
|
+
} else if (type === ASSET_URL_TYPE) {
|
|
653
661
|
return null;
|
|
654
662
|
}
|
|
655
663
|
|
|
@@ -698,10 +706,13 @@ class AssetGenerator extends Generator {
|
|
|
698
706
|
|
|
699
707
|
if ((module.buildInfo && module.buildInfo.dataUrl) || this.emit === false) {
|
|
700
708
|
if (sourceTypes.size > 0) {
|
|
701
|
-
if (
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
709
|
+
if (
|
|
710
|
+
sourceTypes.has(JAVASCRIPT_TYPE) &&
|
|
711
|
+
(sourceTypes.has(CSS_TYPE) || sourceTypes.has(HTML_TYPE))
|
|
712
|
+
) {
|
|
713
|
+
return JAVASCRIPT_AND_ASSET_URL_TYPES;
|
|
714
|
+
} else if (sourceTypes.has(CSS_TYPE) || sourceTypes.has(HTML_TYPE)) {
|
|
715
|
+
return ASSET_URL_TYPES;
|
|
705
716
|
}
|
|
706
717
|
return JAVASCRIPT_TYPES;
|
|
707
718
|
}
|
|
@@ -710,10 +721,13 @@ class AssetGenerator extends Generator {
|
|
|
710
721
|
}
|
|
711
722
|
|
|
712
723
|
if (sourceTypes.size > 0) {
|
|
713
|
-
if (
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
724
|
+
if (
|
|
725
|
+
sourceTypes.has(JAVASCRIPT_TYPE) &&
|
|
726
|
+
(sourceTypes.has(CSS_TYPE) || sourceTypes.has(HTML_TYPE))
|
|
727
|
+
) {
|
|
728
|
+
return ASSET_AND_JAVASCRIPT_AND_ASSET_URL_TYPES;
|
|
729
|
+
} else if (sourceTypes.has(CSS_TYPE) || sourceTypes.has(HTML_TYPE)) {
|
|
730
|
+
return ASSET_AND_ASSET_URL_TYPES;
|
|
717
731
|
}
|
|
718
732
|
return ASSET_AND_JAVASCRIPT_TYPES;
|
|
719
733
|
}
|
|
@@ -20,13 +20,12 @@ const memoize = require("../util/memoize");
|
|
|
20
20
|
/** @typedef {import("../../declarations/WebpackOptions").AssetGeneratorDataUrl} AssetGeneratorDataUrl */
|
|
21
21
|
/** @typedef {import("../../declarations/WebpackOptions").AssetModuleOutputPath} AssetModuleOutputPath */
|
|
22
22
|
/** @typedef {import("../../declarations/WebpackOptions").RawPublicPath} RawPublicPath */
|
|
23
|
-
/** @typedef {import("../../declarations/WebpackOptions").
|
|
23
|
+
/** @typedef {import("../../declarations/WebpackOptions").AssetModuleFilename} AssetModuleFilename */
|
|
24
24
|
/** @typedef {import("../Compilation").AssetInfo} AssetInfo */
|
|
25
25
|
/** @typedef {import("../Compiler")} Compiler */
|
|
26
26
|
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
27
27
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
|
28
28
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
29
|
-
/** @typedef {import("../NormalModule").NormalModuleCreateData} NormalModuleCreateData */
|
|
30
29
|
|
|
31
30
|
/**
|
|
32
31
|
* Returns definition.
|
|
@@ -34,7 +33,9 @@ const memoize = require("../util/memoize");
|
|
|
34
33
|
* @returns {Schema} definition
|
|
35
34
|
*/
|
|
36
35
|
const getSchema = (name) => {
|
|
37
|
-
const { definitions } =
|
|
36
|
+
const { definitions } =
|
|
37
|
+
/** @type {EXPECTED_ANY} */
|
|
38
|
+
(require("../../schemas/WebpackOptions.json"));
|
|
38
39
|
|
|
39
40
|
return {
|
|
40
41
|
definitions,
|
|
@@ -96,10 +97,7 @@ class AssetModulesPlugin {
|
|
|
96
97
|
.for(type)
|
|
97
98
|
.tap(PLUGIN_NAME, (createData, _resolveData) => {
|
|
98
99
|
// TODO create the module via new AssetModule with its own properties
|
|
99
|
-
const module = new NormalModule(
|
|
100
|
-
/** @type {NormalModuleCreateData} */
|
|
101
|
-
(createData)
|
|
102
|
-
);
|
|
100
|
+
const module = new NormalModule(createData);
|
|
103
101
|
if (this.options.sideEffectFree) {
|
|
104
102
|
module.factoryMeta = { sideEffectFree: true };
|
|
105
103
|
}
|
|
@@ -225,7 +223,7 @@ class AssetModulesPlugin {
|
|
|
225
223
|
}
|
|
226
224
|
}
|
|
227
225
|
|
|
228
|
-
/** @type {undefined |
|
|
226
|
+
/** @type {undefined | AssetModuleFilename} */
|
|
229
227
|
let filename;
|
|
230
228
|
/** @type {undefined | RawPublicPath} */
|
|
231
229
|
let publicPath;
|
|
@@ -9,10 +9,11 @@ const { RawSource } = require("webpack-sources");
|
|
|
9
9
|
const ConcatenationScope = require("../ConcatenationScope");
|
|
10
10
|
const Generator = require("../Generator");
|
|
11
11
|
const {
|
|
12
|
+
ASSET_URL_TYPE,
|
|
13
|
+
ASSET_URL_TYPES,
|
|
12
14
|
CSS_TYPE,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
JAVASCRIPT_AND_CSS_URL_TYPES,
|
|
15
|
+
HTML_TYPE,
|
|
16
|
+
JAVASCRIPT_AND_ASSET_URL_TYPES,
|
|
16
17
|
JAVASCRIPT_TYPE,
|
|
17
18
|
JAVASCRIPT_TYPES,
|
|
18
19
|
NO_TYPES
|
|
@@ -78,7 +79,7 @@ class AssetSourceGenerator extends Generator {
|
|
|
78
79
|
}
|
|
79
80
|
return new RawSource(sourceContent);
|
|
80
81
|
}
|
|
81
|
-
case
|
|
82
|
+
case ASSET_URL_TYPE: {
|
|
82
83
|
if (!originalSource) {
|
|
83
84
|
return null;
|
|
84
85
|
}
|
|
@@ -145,10 +146,13 @@ class AssetSourceGenerator extends Generator {
|
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
if (sourceTypes.size > 0) {
|
|
148
|
-
if (
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
if (
|
|
150
|
+
sourceTypes.has(JAVASCRIPT_TYPE) &&
|
|
151
|
+
(sourceTypes.has(CSS_TYPE) || sourceTypes.has(HTML_TYPE))
|
|
152
|
+
) {
|
|
153
|
+
return JAVASCRIPT_AND_ASSET_URL_TYPES;
|
|
154
|
+
} else if (sourceTypes.has(CSS_TYPE) || sourceTypes.has(HTML_TYPE)) {
|
|
155
|
+
return ASSET_URL_TYPES;
|
|
152
156
|
}
|
|
153
157
|
return JAVASCRIPT_TYPES;
|
|
154
158
|
}
|
package/lib/buildChunkGraph.js
CHANGED
|
@@ -5,9 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const AsyncDependencyToInitialChunkError = require("./AsyncDependencyToInitialChunkError");
|
|
9
|
-
const { connectChunkGroupParentAndChild } = require("./GraphHelpers");
|
|
10
8
|
const ModuleGraphConnection = require("./ModuleGraphConnection");
|
|
9
|
+
const AsyncDependencyToInitialChunkError = require("./errors/AsyncDependencyToInitialChunkError");
|
|
11
10
|
const { getEntryRuntime, mergeRuntime } = require("./util/runtime");
|
|
12
11
|
|
|
13
12
|
/** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
|
|
@@ -1311,10 +1310,9 @@ const connectChunkGroups = (
|
|
|
1311
1310
|
chunkGraph.connectBlockAndChunkGroup(block, chunkGroup);
|
|
1312
1311
|
|
|
1313
1312
|
// 4. Connect chunk with parent
|
|
1314
|
-
|
|
1315
|
-
originChunkGroupInfo.chunkGroup
|
|
1316
|
-
|
|
1317
|
-
);
|
|
1313
|
+
if (originChunkGroupInfo.chunkGroup.addChild(chunkGroup)) {
|
|
1314
|
+
chunkGroup.addParent(originChunkGroupInfo.chunkGroup);
|
|
1315
|
+
}
|
|
1318
1316
|
}
|
|
1319
1317
|
}
|
|
1320
1318
|
};
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
const FileSystemInfo = require("../FileSystemInfo");
|
|
9
9
|
const ProgressPlugin = require("../ProgressPlugin");
|
|
10
|
-
const { formatSize } = require("../SizeFormatHelpers");
|
|
11
10
|
const SerializerMiddleware = require("../serialization/SerializerMiddleware");
|
|
12
11
|
const LazySet = require("../util/LazySet");
|
|
12
|
+
const formatSize = require("../util/formatSize");
|
|
13
13
|
const makeSerializable = require("../util/makeSerializable");
|
|
14
14
|
const memoize = require("../util/memoize");
|
|
15
15
|
const {
|
|
@@ -105,7 +105,7 @@ const MIN_CONTENT_SIZE = 1024 * 1024; // 1 MB
|
|
|
105
105
|
const CONTENT_COUNT_TO_MERGE = 10;
|
|
106
106
|
const MIN_ITEMS_IN_FRESH_PACK = 100;
|
|
107
107
|
const MAX_ITEMS_IN_FRESH_PACK = 50000;
|
|
108
|
-
const MAX_TIME_IN_FRESH_PACK =
|
|
108
|
+
const MAX_TIME_IN_FRESH_PACK = 60 * 1000; // 1 min
|
|
109
109
|
|
|
110
110
|
class PackItemInfo {
|
|
111
111
|
/**
|
|
@@ -799,7 +799,7 @@ class PackContentItems {
|
|
|
799
799
|
if (read()) {
|
|
800
800
|
this.map = read();
|
|
801
801
|
} else if (profile) {
|
|
802
|
-
/** @type {
|
|
802
|
+
/** @type {Content} */
|
|
803
803
|
const map = new Map();
|
|
804
804
|
let key = read();
|
|
805
805
|
while (key !== null) {
|
|
@@ -825,7 +825,7 @@ class PackContentItems {
|
|
|
825
825
|
}
|
|
826
826
|
this.map = map;
|
|
827
827
|
} else {
|
|
828
|
-
/** @type {
|
|
828
|
+
/** @type {Content} */
|
|
829
829
|
const map = new Map();
|
|
830
830
|
let key = read();
|
|
831
831
|
while (key !== null) {
|
package/lib/cli.js
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
|
|
8
8
|
const path = require("path");
|
|
9
9
|
const tty = require("tty");
|
|
10
|
-
const webpackSchema =
|
|
10
|
+
const webpackSchema =
|
|
11
|
+
/** @type {EXPECTED_ANY} */
|
|
12
|
+
(require("../schemas/WebpackOptions.json"));
|
|
11
13
|
|
|
12
14
|
/** @typedef {import("json-schema").JSONSchema4} JSONSchema4 */
|
|
13
15
|
/** @typedef {import("json-schema").JSONSchema6} JSONSchema6 */
|