webpack 5.99.8 → 5.100.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 +0 -3
- package/bin/webpack.js +8 -2
- package/hot/log.js +15 -15
- package/hot/poll.js +1 -0
- package/lib/APIPlugin.js +3 -3
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -0
- package/lib/BannerPlugin.js +1 -1
- package/lib/CacheFacade.js +2 -1
- package/lib/CaseSensitiveModulesWarning.js +4 -4
- package/lib/Chunk.js +6 -6
- package/lib/ChunkGraph.js +37 -32
- package/lib/ChunkGroup.js +17 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +94 -17
- package/lib/CodeGenerationResults.js +1 -1
- package/lib/CompatibilityPlugin.js +5 -2
- package/lib/Compilation.js +77 -71
- package/lib/Compiler.js +46 -16
- package/lib/ConcatenationScope.js +15 -6
- package/lib/ConstPlugin.js +65 -45
- package/lib/ContextModule.js +16 -12
- package/lib/ContextModuleFactory.js +4 -3
- package/lib/ContextReplacementPlugin.js +4 -2
- package/lib/CssModule.js +2 -3
- package/lib/DefinePlugin.js +111 -3
- package/lib/DelegatedModuleFactoryPlugin.js +18 -18
- package/lib/Dependency.js +16 -12
- package/lib/DependencyTemplate.js +1 -0
- package/lib/DllEntryPlugin.js +3 -1
- package/lib/DllPlugin.js +4 -3
- package/lib/DllReferencePlugin.js +2 -2
- package/lib/DynamicEntryPlugin.js +1 -1
- package/lib/EntryOptionPlugin.js +5 -0
- package/lib/ErrorHelpers.js +4 -4
- package/lib/EvalDevToolModulePlugin.js +3 -3
- package/lib/EvalSourceMapDevToolPlugin.js +7 -7
- package/lib/ExportsInfo.js +48 -39
- package/lib/ExternalModule.js +15 -11
- package/lib/ExternalModuleFactoryPlugin.js +5 -2
- package/lib/FileSystemInfo.js +51 -38
- package/lib/FlagDependencyExportsPlugin.js +14 -7
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +14 -1
- package/lib/HookWebpackError.js +1 -0
- package/lib/HotModuleReplacementPlugin.js +77 -50
- package/lib/IgnorePlugin.js +1 -1
- package/lib/InvalidDependenciesModuleWarning.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +0 -1
- package/lib/LibManifestPlugin.js +4 -2
- package/lib/LoaderOptionsPlugin.js +6 -4
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +21 -6
- package/lib/ModuleFactory.js +1 -0
- package/lib/ModuleGraph.js +24 -2
- package/lib/ModuleGraphConnection.js +5 -5
- package/lib/ModuleInfoHeaderPlugin.js +2 -1
- package/lib/ModuleParseError.js +1 -0
- package/lib/ModuleSourceTypesConstants.js +12 -12
- package/lib/ModuleTemplate.js +1 -1
- package/lib/ModuleTypeConstants.js +21 -21
- package/lib/MultiCompiler.js +6 -6
- package/lib/NormalModule.js +61 -56
- package/lib/NormalModuleFactory.js +52 -37
- package/lib/NormalModuleReplacementPlugin.js +1 -1
- package/lib/NullFactory.js +1 -0
- package/lib/OptimizationStages.js +1 -1
- package/lib/Parser.js +1 -0
- package/lib/ProgressPlugin.js +12 -5
- package/lib/ProvidePlugin.js +5 -1
- package/lib/RecordIdsPlugin.js +3 -3
- package/lib/RuntimeGlobals.js +175 -155
- package/lib/RuntimeModule.js +1 -0
- package/lib/RuntimePlugin.js +34 -8
- package/lib/RuntimeTemplate.js +111 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +15 -25
- package/lib/SourceMapDevToolPlugin.js +19 -17
- package/lib/Template.js +2 -2
- package/lib/TemplatedPathPlugin.js +1 -1
- package/lib/WarnDeprecatedOptionPlugin.js +7 -8
- package/lib/WatchIgnorePlugin.js +4 -3
- package/lib/WebpackIsIncludedPlugin.js +2 -1
- package/lib/WebpackOptionsApply.js +115 -27
- package/lib/asset/AssetGenerator.js +26 -21
- package/lib/asset/AssetModulesPlugin.js +19 -17
- package/lib/asset/AssetSourceGenerator.js +11 -9
- package/lib/asset/RawDataUrlModule.js +4 -2
- package/lib/async-modules/AwaitDependenciesInitFragment.js +1 -1
- package/lib/buildChunkGraph.js +6 -3
- package/lib/cache/AddBuildDependenciesPlugin.js +5 -6
- package/lib/cache/IdleFileCachePlugin.js +7 -4
- package/lib/cache/MemoryCachePlugin.js +1 -0
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +26 -20
- package/lib/cache/ResolverCachePlugin.js +16 -8
- package/lib/cli.js +15 -10
- package/lib/config/browserslistTargetHandler.js +3 -3
- package/lib/config/defaults.js +25 -17
- package/lib/config/normalization.js +2 -1
- package/lib/config/target.js +6 -5
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackModule.js +2 -1
- package/lib/container/HoistContainerReferencesPlugin.js +1 -1
- package/lib/container/ModuleFederationPlugin.js +2 -2
- package/lib/container/RemoteModule.js +1 -1
- package/lib/css/CssGenerator.js +9 -6
- package/lib/css/CssModulesPlugin.js +44 -31
- package/lib/css/CssParser.js +6 -4
- package/lib/css/walkCssTokens.js +33 -37
- package/lib/debug/ProfilingPlugin.js +6 -6
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -8
- package/lib/dependencies/AMDPlugin.js +12 -8
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +28 -26
- package/lib/dependencies/CachedConstDependency.js +1 -5
- package/lib/dependencies/CommonJsExportRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsExportsParserPlugin.js +22 -25
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +100 -114
- package/lib/dependencies/CommonJsPlugin.js +15 -16
- package/lib/dependencies/ContextDependencyHelpers.js +2 -1
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +1 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/CssUrlDependency.js +1 -1
- package/lib/dependencies/DynamicExports.js +9 -9
- package/lib/dependencies/ExportsInfoDependency.js +1 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +122 -101
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +95 -19
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +11 -5
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +238 -162
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +20 -9
- package/lib/dependencies/HarmonyModulesPlugin.js +23 -12
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
- package/lib/dependencies/ImportMetaPlugin.js +2 -2
- package/lib/dependencies/ImportParserPlugin.js +40 -9
- package/lib/dependencies/ImportPlugin.js +3 -1
- package/lib/dependencies/LoaderPlugin.js +1 -0
- package/lib/dependencies/ModuleDependency.js +1 -1
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +3 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +3 -0
- package/lib/dependencies/RequireEnsurePlugin.js +6 -6
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +33 -34
- package/lib/dependencies/RequireIncludePlugin.js +1 -0
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLContextDependency.js +65 -0
- package/lib/dependencies/URLDependency.js +1 -1
- package/lib/dependencies/URLPlugin.js +17 -157
- package/lib/dependencies/WorkerPlugin.js +23 -10
- package/lib/dependencies/processExportInfo.js +2 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +269 -185
- package/lib/esm/ModuleChunkLoadingPlugin.js +39 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +73 -6
- package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
- package/lib/hmr/LazyCompilationPlugin.js +4 -2
- package/lib/hmr/lazyCompilationBackend.js +4 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +6 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +30 -35
- package/lib/ids/DeterministicModuleIdsPlugin.js +4 -3
- package/lib/ids/HashedModuleIdsPlugin.js +5 -4
- package/lib/ids/IdHelpers.js +21 -17
- package/lib/ids/NamedChunkIdsPlugin.js +5 -5
- package/lib/ids/NamedModuleIdsPlugin.js +4 -4
- package/lib/ids/NaturalChunkIdsPlugin.js +2 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +3 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +1 -1
- package/lib/index.js +13 -3
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +113 -119
- package/lib/javascript/BasicEvaluatedExpression.js +2 -1
- package/lib/javascript/ChunkHelpers.js +1 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +121 -136
- package/lib/javascript/EnableChunkLoadingPlugin.js +6 -3
- package/lib/javascript/JavascriptGenerator.js +14 -2
- package/lib/javascript/JavascriptModulesPlugin.js +68 -27
- package/lib/javascript/JavascriptParser.js +136 -81
- package/lib/javascript/JavascriptParserHelpers.js +41 -41
- package/lib/javascript/StartupHelpers.js +17 -17
- package/lib/json/JsonGenerator.js +4 -2
- package/lib/json/JsonModulesPlugin.js +2 -2
- package/lib/json/JsonParser.js +1 -1
- package/lib/library/AbstractLibraryPlugin.js +6 -2
- package/lib/library/AssignLibraryPlugin.js +21 -6
- package/lib/library/EnableLibraryPlugin.js +23 -3
- package/lib/library/ModuleLibraryPlugin.js +4 -1
- package/lib/library/UmdLibraryPlugin.js +15 -6
- package/lib/logging/createConsoleLogger.js +3 -3
- package/lib/logging/runtime.js +9 -9
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/RequireChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/nodeConsole.js +4 -2
- package/lib/optimize/AggressiveMergingPlugin.js +45 -46
- package/lib/optimize/AggressiveSplittingPlugin.js +13 -12
- package/lib/optimize/ConcatenatedModule.js +227 -57
- package/lib/optimize/EnsureChunkConditionsPlugin.js +58 -58
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -1
- package/lib/optimize/InnerGraph.js +115 -112
- package/lib/optimize/InnerGraphPlugin.js +2 -2
- package/lib/optimize/LimitChunkCountPlugin.js +4 -2
- package/lib/optimize/MangleExportsPlugin.js +4 -3
- package/lib/optimize/MergeDuplicateChunksPlugin.js +80 -81
- package/lib/optimize/MinChunkSizePlugin.js +6 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +31 -22
- package/lib/optimize/RealContentHashPlugin.js +26 -20
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
- package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
- package/lib/optimize/SideEffectsFlagPlugin.js +6 -3
- package/lib/optimize/SplitChunksPlugin.js +16 -13
- package/lib/rules/BasicEffectRulePlugin.js +4 -2
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +3 -1
- package/lib/rules/RuleSetCompiler.js +7 -4
- package/lib/rules/UseEffectRulePlugin.js +3 -1
- package/lib/runtime/AsyncModuleRuntimeModule.js +64 -9
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +214 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +2 -1
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -7
- package/lib/schemes/DataUriPlugin.js +3 -1
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +27 -19
- package/lib/schemes/VirtualUrlPlugin.js +222 -0
- package/lib/serialization/AggregateErrorSerializer.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +5 -4
- package/lib/serialization/FileMiddleware.js +7 -4
- package/lib/serialization/ObjectMiddleware.js +14 -8
- package/lib/serialization/Serializer.js +5 -3
- package/lib/serialization/SerializerMiddleware.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +1 -1
- package/lib/sharing/ConsumeSharedPlugin.js +3 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +2 -2
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +6 -3
- package/lib/sharing/SharePlugin.js +2 -1
- package/lib/sharing/ShareRuntimeModule.js +3 -5
- package/lib/sharing/utils.js +34 -34
- package/lib/stats/DefaultStatsFactoryPlugin.js +49 -46
- package/lib/stats/DefaultStatsPresetPlugin.js +4 -2
- package/lib/stats/DefaultStatsPrinterPlugin.js +28 -22
- package/lib/stats/StatsFactory.js +4 -2
- package/lib/stats/StatsPrinter.js +3 -2
- package/lib/url/URLParserPlugin.js +266 -0
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/Hash.js +2 -0
- package/lib/util/IterableHelpers.js +1 -1
- package/lib/util/LazyBucketSortedSet.js +2 -1
- package/lib/util/LazySet.js +11 -6
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/SetHelpers.js +3 -3
- package/lib/util/SortableSet.js +2 -2
- package/lib/util/StackedCacheMap.js +3 -1
- package/lib/util/StackedMap.js +2 -2
- package/lib/util/StringXor.js +1 -0
- package/lib/util/TupleSet.js +1 -0
- package/lib/util/URLAbsoluteSpecifier.js +1 -1
- package/lib/util/cleverMerge.js +12 -8
- package/lib/util/comparators.js +154 -127
- package/lib/util/compileBooleanMatcher.js +8 -3
- package/lib/util/concatenate.js +8 -7
- package/lib/util/conventions.js +72 -73
- package/lib/util/create-schema-validation.js +2 -1
- package/lib/util/createHash.js +10 -4
- package/lib/util/deprecation.js +69 -66
- package/lib/util/deterministicGrouping.js +4 -2
- package/lib/util/extractUrlAndGlobal.js +1 -1
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +30 -23
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +4 -2
- package/lib/util/identifier.js +13 -12
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/magicComment.js +5 -5
- package/lib/util/processAsyncTree.js +1 -1
- package/lib/util/propertyAccess.js +1 -1
- package/lib/util/propertyName.js +1 -1
- package/lib/util/registerExternalSerializer.js +1 -2
- package/lib/util/removeBOM.js +1 -1
- package/lib/util/runtime.js +29 -21
- package/lib/util/semver.js +1 -1
- package/lib/util/serialization.js +3 -0
- package/lib/util/source.js +3 -2
- package/lib/validateSchema.js +1 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +6 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +46 -49
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +2 -3
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +3 -2
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +3 -0
- package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -22
- package/lib/webpack.js +4 -5
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -24
- package/lib/webworker/WebWorkerTemplatePlugin.js +1 -0
- package/package.json +121 -114
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +17 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
- package/types.d.ts +1261 -366
|
@@ -10,6 +10,12 @@ const { RawSource } = require("webpack-sources");
|
|
|
10
10
|
const ChunkGraph = require("./ChunkGraph");
|
|
11
11
|
const Compilation = require("./Compilation");
|
|
12
12
|
const HotUpdateChunk = require("./HotUpdateChunk");
|
|
13
|
+
const {
|
|
14
|
+
JAVASCRIPT_MODULE_TYPE_AUTO,
|
|
15
|
+
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
|
16
|
+
JAVASCRIPT_MODULE_TYPE_ESM,
|
|
17
|
+
WEBPACK_MODULE_TYPE_RUNTIME
|
|
18
|
+
} = require("./ModuleTypeConstants");
|
|
13
19
|
const NormalModule = require("./NormalModule");
|
|
14
20
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
|
15
21
|
const WebpackError = require("./WebpackError");
|
|
@@ -27,21 +33,14 @@ const { find, isSubset } = require("./util/SetHelpers");
|
|
|
27
33
|
const TupleSet = require("./util/TupleSet");
|
|
28
34
|
const { compareModulesById } = require("./util/comparators");
|
|
29
35
|
const {
|
|
36
|
+
forEachRuntime,
|
|
30
37
|
getRuntimeKey,
|
|
38
|
+
intersectRuntime,
|
|
31
39
|
keyToRuntime,
|
|
32
|
-
forEachRuntime,
|
|
33
40
|
mergeRuntimeOwned,
|
|
34
|
-
subtractRuntime
|
|
35
|
-
intersectRuntime
|
|
41
|
+
subtractRuntime
|
|
36
42
|
} = require("./util/runtime");
|
|
37
43
|
|
|
38
|
-
const {
|
|
39
|
-
JAVASCRIPT_MODULE_TYPE_AUTO,
|
|
40
|
-
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
|
|
41
|
-
JAVASCRIPT_MODULE_TYPE_ESM,
|
|
42
|
-
WEBPACK_MODULE_TYPE_RUNTIME
|
|
43
|
-
} = require("./ModuleTypeConstants");
|
|
44
|
-
|
|
45
44
|
/** @typedef {import("estree").CallExpression} CallExpression */
|
|
46
45
|
/** @typedef {import("estree").Expression} Expression */
|
|
47
46
|
/** @typedef {import("estree").SpreadElement} SpreadElement */
|
|
@@ -66,6 +65,13 @@ const {
|
|
|
66
65
|
* @property {SyncBailHook<[CallExpression, string[]], void>} hotAcceptWithoutCallback
|
|
67
66
|
*/
|
|
68
67
|
|
|
68
|
+
/** @typedef {number} HotIndex */
|
|
69
|
+
/** @typedef {Record<string, string>} FullHashChunkModuleHashes */
|
|
70
|
+
/** @typedef {Record<string, string>} ChunkModuleHashes */
|
|
71
|
+
/** @typedef {Record<ChunkId, string>} ChunkHashes */
|
|
72
|
+
/** @typedef {Record<ChunkId, string>} ChunkRuntime */
|
|
73
|
+
/** @typedef {Record<ChunkId, ModuleId[]>} ChunkModuleIds */
|
|
74
|
+
|
|
69
75
|
/** @typedef {{ updatedChunkIds: Set<ChunkId>, removedChunkIds: Set<ChunkId>, removedModules: Set<Module>, filename: string, assetInfo: AssetInfo }} HotUpdateMainContentByRuntimeItem */
|
|
70
76
|
/** @typedef {Map<string, HotUpdateMainContentByRuntimeItem>} HotUpdateMainContentByRuntime */
|
|
71
77
|
|
|
@@ -103,8 +109,9 @@ class HotModuleReplacementPlugin {
|
|
|
103
109
|
*/
|
|
104
110
|
apply(compiler) {
|
|
105
111
|
const { _backCompat: backCompat } = compiler;
|
|
106
|
-
if (compiler.options.output.strictModuleErrorHandling === undefined)
|
|
112
|
+
if (compiler.options.output.strictModuleErrorHandling === undefined) {
|
|
107
113
|
compiler.options.output.strictModuleErrorHandling = true;
|
|
114
|
+
}
|
|
108
115
|
const runtimeRequirements = [RuntimeGlobals.module];
|
|
109
116
|
|
|
110
117
|
/**
|
|
@@ -344,10 +351,11 @@ class HotModuleReplacementPlugin {
|
|
|
344
351
|
);
|
|
345
352
|
// #endregion
|
|
346
353
|
|
|
354
|
+
/** @type {HotIndex} */
|
|
347
355
|
let hotIndex = 0;
|
|
348
|
-
/** @type {
|
|
356
|
+
/** @type {FullHashChunkModuleHashes} */
|
|
349
357
|
const fullHashChunkModuleHashes = {};
|
|
350
|
-
/** @type {
|
|
358
|
+
/** @type {ChunkModuleHashes} */
|
|
351
359
|
const chunkModuleHashes = {};
|
|
352
360
|
|
|
353
361
|
compilation.hooks.record.tap(PLUGIN_NAME, (compilation, records) => {
|
|
@@ -361,19 +369,20 @@ class HotModuleReplacementPlugin {
|
|
|
361
369
|
records.chunkRuntime = {};
|
|
362
370
|
for (const chunk of compilation.chunks) {
|
|
363
371
|
const chunkId = /** @type {ChunkId} */ (chunk.id);
|
|
364
|
-
records.chunkHashes[chunkId] = chunk.hash;
|
|
372
|
+
records.chunkHashes[chunkId] = /** @type {string} */ (chunk.hash);
|
|
365
373
|
records.chunkRuntime[chunkId] = getRuntimeKey(chunk.runtime);
|
|
366
374
|
}
|
|
367
375
|
records.chunkModuleIds = {};
|
|
368
376
|
for (const chunk of compilation.chunks) {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
)
|
|
375
|
-
|
|
376
|
-
)
|
|
377
|
+
const chunkId = /** @type {ChunkId} */ (chunk.id);
|
|
378
|
+
|
|
379
|
+
records.chunkModuleIds[chunkId] = Array.from(
|
|
380
|
+
chunkGraph.getOrderedChunkModulesIterable(
|
|
381
|
+
chunk,
|
|
382
|
+
compareModulesById(chunkGraph)
|
|
383
|
+
),
|
|
384
|
+
m => /** @type {ModuleId} */ (chunkGraph.getModuleId(m))
|
|
385
|
+
);
|
|
377
386
|
}
|
|
378
387
|
});
|
|
379
388
|
/** @type {TupleSet<Module, Chunk>} */
|
|
@@ -418,10 +427,14 @@ class HotModuleReplacementPlugin {
|
|
|
418
427
|
const hash = getModuleHash(module);
|
|
419
428
|
if (
|
|
420
429
|
fullHashModulesInThisChunk.has(
|
|
421
|
-
/** @type {RuntimeModule} */
|
|
430
|
+
/** @type {RuntimeModule} */
|
|
431
|
+
(module)
|
|
422
432
|
)
|
|
423
433
|
) {
|
|
424
|
-
if (
|
|
434
|
+
if (
|
|
435
|
+
/** @type {FullHashChunkModuleHashes} */
|
|
436
|
+
(records.fullHashChunkModuleHashes)[key] !== hash
|
|
437
|
+
) {
|
|
425
438
|
updatedModules.add(module, chunk);
|
|
426
439
|
}
|
|
427
440
|
fullHashChunkModuleHashes[key] = hash;
|
|
@@ -504,8 +517,11 @@ class HotModuleReplacementPlugin {
|
|
|
504
517
|
/** @type {HotUpdateMainContentByRuntime} */
|
|
505
518
|
const hotUpdateMainContentByRuntime = new Map();
|
|
506
519
|
let allOldRuntime;
|
|
507
|
-
|
|
508
|
-
|
|
520
|
+
const chunkRuntime =
|
|
521
|
+
/** @type {ChunkRuntime} */
|
|
522
|
+
(records.chunkRuntime);
|
|
523
|
+
for (const key of Object.keys(chunkRuntime)) {
|
|
524
|
+
const runtime = keyToRuntime(chunkRuntime[key]);
|
|
509
525
|
allOldRuntime = mergeRuntimeOwned(allOldRuntime, runtime);
|
|
510
526
|
}
|
|
511
527
|
forEachRuntime(allOldRuntime, runtime => {
|
|
@@ -532,7 +548,7 @@ class HotModuleReplacementPlugin {
|
|
|
532
548
|
if (hotUpdateMainContentByRuntime.size === 0) return;
|
|
533
549
|
|
|
534
550
|
// Create a list of all active modules to verify which modules are removed completely
|
|
535
|
-
/** @type {Map<number|string, Module>} */
|
|
551
|
+
/** @type {Map<number | string, Module>} */
|
|
536
552
|
const allModules = new Map();
|
|
537
553
|
for (const module of compilation.modules) {
|
|
538
554
|
const id =
|
|
@@ -546,7 +562,10 @@ class HotModuleReplacementPlugin {
|
|
|
546
562
|
const completelyRemovedModules = new Set();
|
|
547
563
|
|
|
548
564
|
for (const key of Object.keys(records.chunkHashes)) {
|
|
549
|
-
const oldRuntime = keyToRuntime(
|
|
565
|
+
const oldRuntime = keyToRuntime(
|
|
566
|
+
/** @type {ChunkRuntime} */
|
|
567
|
+
(records.chunkRuntime)[key]
|
|
568
|
+
);
|
|
550
569
|
/** @type {Module[]} */
|
|
551
570
|
const remainingModules = [];
|
|
552
571
|
// Check which modules are removed
|
|
@@ -581,21 +600,21 @@ class HotModuleReplacementPlugin {
|
|
|
581
600
|
newModules = chunkGraph
|
|
582
601
|
.getChunkModules(currentChunk)
|
|
583
602
|
.filter(module => updatedModules.has(module, currentChunk));
|
|
584
|
-
newRuntimeModules =
|
|
585
|
-
chunkGraph.getChunkRuntimeModulesIterable(currentChunk)
|
|
586
|
-
|
|
603
|
+
newRuntimeModules = [
|
|
604
|
+
...chunkGraph.getChunkRuntimeModulesIterable(currentChunk)
|
|
605
|
+
].filter(module => updatedModules.has(module, currentChunk));
|
|
587
606
|
const fullHashModules =
|
|
588
607
|
chunkGraph.getChunkFullHashModulesIterable(currentChunk);
|
|
589
608
|
newFullHashModules =
|
|
590
609
|
fullHashModules &&
|
|
591
|
-
|
|
610
|
+
[...fullHashModules].filter(module =>
|
|
592
611
|
updatedModules.has(module, currentChunk)
|
|
593
612
|
);
|
|
594
613
|
const dependentHashModules =
|
|
595
614
|
chunkGraph.getChunkDependentHashModulesIterable(currentChunk);
|
|
596
615
|
newDependentHashModules =
|
|
597
616
|
dependentHashModules &&
|
|
598
|
-
|
|
617
|
+
[...dependentHashModules].filter(module =>
|
|
599
618
|
updatedModules.has(module, currentChunk)
|
|
600
619
|
);
|
|
601
620
|
removedFromRuntime = subtractRuntime(oldRuntime, newRuntime);
|
|
@@ -658,8 +677,9 @@ class HotModuleReplacementPlugin {
|
|
|
658
677
|
} else if (
|
|
659
678
|
moduleRuntime !== undefined &&
|
|
660
679
|
moduleRuntime.has(/** @type {string} */ (runtime))
|
|
661
|
-
)
|
|
680
|
+
) {
|
|
662
681
|
return;
|
|
682
|
+
}
|
|
663
683
|
}
|
|
664
684
|
const item =
|
|
665
685
|
/** @type {HotUpdateMainContentByRuntimeItem} */ (
|
|
@@ -677,15 +697,17 @@ class HotModuleReplacementPlugin {
|
|
|
677
697
|
(newRuntimeModules && newRuntimeModules.length > 0)
|
|
678
698
|
) {
|
|
679
699
|
const hotUpdateChunk = new HotUpdateChunk();
|
|
680
|
-
if (backCompat)
|
|
700
|
+
if (backCompat) {
|
|
681
701
|
ChunkGraph.setChunkGraphForChunk(hotUpdateChunk, chunkGraph);
|
|
702
|
+
}
|
|
682
703
|
hotUpdateChunk.id = chunkId;
|
|
683
704
|
hotUpdateChunk.runtime = currentChunk
|
|
684
705
|
? currentChunk.runtime
|
|
685
706
|
: newRuntime;
|
|
686
707
|
if (currentChunk) {
|
|
687
|
-
for (const group of currentChunk.groupsIterable)
|
|
708
|
+
for (const group of currentChunk.groupsIterable) {
|
|
688
709
|
hotUpdateChunk.addGroup(group);
|
|
710
|
+
}
|
|
689
711
|
}
|
|
690
712
|
chunkGraph.attachModules(hotUpdateChunk, newModules || []);
|
|
691
713
|
chunkGraph.attachRuntimeModules(
|
|
@@ -706,8 +728,8 @@ class HotModuleReplacementPlugin {
|
|
|
706
728
|
}
|
|
707
729
|
const renderManifest = compilation.getRenderManifest({
|
|
708
730
|
chunk: hotUpdateChunk,
|
|
709
|
-
hash: records.hash,
|
|
710
|
-
fullHash: records.hash,
|
|
731
|
+
hash: /** @type {string} */ (records.hash),
|
|
732
|
+
fullHash: /** @type {string} */ (records.hash),
|
|
711
733
|
outputOptions: compilation.outputOptions,
|
|
712
734
|
moduleTemplates: compilation.moduleTemplates,
|
|
713
735
|
dependencyTemplates: compilation.dependencyTemplates,
|
|
@@ -753,9 +775,7 @@ class HotModuleReplacementPlugin {
|
|
|
753
775
|
});
|
|
754
776
|
}
|
|
755
777
|
}
|
|
756
|
-
const completelyRemovedModulesArray =
|
|
757
|
-
completelyRemovedModules
|
|
758
|
-
);
|
|
778
|
+
const completelyRemovedModulesArray = [...completelyRemovedModules];
|
|
759
779
|
const hotUpdateMainContentByFilename = new Map();
|
|
760
780
|
for (const {
|
|
761
781
|
removedChunkIds,
|
|
@@ -777,12 +797,15 @@ The configured output.hotUpdateMainFilename doesn't lead to unique filenames per
|
|
|
777
797
|
This might lead to incorrect runtime behavior of the applied update.
|
|
778
798
|
To fix this, make sure to include [runtime] in the output.hotUpdateMainFilename option, or use the default config.`)
|
|
779
799
|
);
|
|
780
|
-
for (const chunkId of removedChunkIds)
|
|
800
|
+
for (const chunkId of removedChunkIds) {
|
|
781
801
|
old.removedChunkIds.add(chunkId);
|
|
782
|
-
|
|
802
|
+
}
|
|
803
|
+
for (const chunkId of removedModules) {
|
|
783
804
|
old.removedModules.add(chunkId);
|
|
784
|
-
|
|
805
|
+
}
|
|
806
|
+
for (const chunkId of updatedChunkIds) {
|
|
785
807
|
old.updatedChunkIds.add(chunkId);
|
|
808
|
+
}
|
|
786
809
|
continue;
|
|
787
810
|
}
|
|
788
811
|
hotUpdateMainContentByFilename.set(filename, {
|
|
@@ -797,21 +820,25 @@ To fix this, make sure to include [runtime] in the output.hotUpdateMainFilename
|
|
|
797
820
|
{ removedChunkIds, removedModules, updatedChunkIds, assetInfo }
|
|
798
821
|
] of hotUpdateMainContentByFilename) {
|
|
799
822
|
const hotUpdateMainJson = {
|
|
800
|
-
c:
|
|
801
|
-
r:
|
|
823
|
+
c: [...updatedChunkIds],
|
|
824
|
+
r: [...removedChunkIds],
|
|
802
825
|
m:
|
|
803
826
|
removedModules.size === 0
|
|
804
827
|
? completelyRemovedModulesArray
|
|
805
|
-
:
|
|
806
|
-
|
|
828
|
+
: [
|
|
829
|
+
...completelyRemovedModulesArray,
|
|
830
|
+
...Array.from(
|
|
807
831
|
removedModules,
|
|
808
832
|
m =>
|
|
809
833
|
/** @type {ModuleId} */ (chunkGraph.getModuleId(m))
|
|
810
834
|
)
|
|
811
|
-
|
|
835
|
+
]
|
|
812
836
|
};
|
|
813
837
|
|
|
814
|
-
const source = new RawSource(
|
|
838
|
+
const source = new RawSource(
|
|
839
|
+
(filename.endsWith(".json") ? "" : "export default ") +
|
|
840
|
+
JSON.stringify(hotUpdateMainJson)
|
|
841
|
+
);
|
|
815
842
|
compilation.emitAsset(filename, source, {
|
|
816
843
|
hotModuleReplacement: true,
|
|
817
844
|
...assetInfo
|
package/lib/IgnorePlugin.js
CHANGED
|
@@ -14,7 +14,7 @@ const createSchemaValidation = require("./util/create-schema-validation");
|
|
|
14
14
|
/** @typedef {import("./NormalModuleFactory").ResolveData} ResolveData */
|
|
15
15
|
|
|
16
16
|
const validate = createSchemaValidation(
|
|
17
|
-
require("../schemas/plugins/IgnorePlugin.check
|
|
17
|
+
require("../schemas/plugins/IgnorePlugin.check"),
|
|
18
18
|
() => require("../schemas/plugins/IgnorePlugin.json"),
|
|
19
19
|
{
|
|
20
20
|
name: "Ignore Plugin",
|
|
@@ -17,7 +17,7 @@ class InvalidDependenciesModuleWarning extends WebpackError {
|
|
|
17
17
|
* @param {Iterable<string>} deps invalid dependencies
|
|
18
18
|
*/
|
|
19
19
|
constructor(module, deps) {
|
|
20
|
-
const orderedDeps = deps ?
|
|
20
|
+
const orderedDeps = deps ? [...deps].sort() : [];
|
|
21
21
|
const depsList = orderedDeps.map(dep => ` * ${JSON.stringify(dep)}`);
|
|
22
22
|
super(`Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
|
|
23
23
|
Invalid dependencies may lead to broken watching and caching.
|
|
@@ -38,7 +38,6 @@ class JavascriptMetaInfoPlugin {
|
|
|
38
38
|
/** @type {BuildInfo} */
|
|
39
39
|
(parser.state.module.buildInfo);
|
|
40
40
|
buildInfo.moduleConcatenationBailout = "eval()";
|
|
41
|
-
buildInfo.usingEval = true;
|
|
42
41
|
const currentSymbol = InnerGraph.getTopLevelSymbol(parser.state);
|
|
43
42
|
if (currentSymbol) {
|
|
44
43
|
InnerGraph.addUsage(parser.state, null, currentSymbol);
|
package/lib/LibManifestPlugin.js
CHANGED
|
@@ -56,7 +56,7 @@ class LibManifestPlugin {
|
|
|
56
56
|
// store used paths to detect issue and output an error. #18200
|
|
57
57
|
const usedPaths = new Set();
|
|
58
58
|
asyncLib.each(
|
|
59
|
-
|
|
59
|
+
[...compilation.chunks],
|
|
60
60
|
(chunk, callback) => {
|
|
61
61
|
if (!chunk.canBeInitial()) {
|
|
62
62
|
callback();
|
|
@@ -94,7 +94,8 @@ class LibManifestPlugin {
|
|
|
94
94
|
const ident = module.libIdent({
|
|
95
95
|
context:
|
|
96
96
|
this.options.context ||
|
|
97
|
-
/** @type {string} */
|
|
97
|
+
/** @type {string} */
|
|
98
|
+
(compiler.options.context),
|
|
98
99
|
associatedObjectForCache: compiler.root
|
|
99
100
|
});
|
|
100
101
|
if (ident) {
|
|
@@ -140,4 +141,5 @@ class LibManifestPlugin {
|
|
|
140
141
|
);
|
|
141
142
|
}
|
|
142
143
|
}
|
|
144
|
+
|
|
143
145
|
module.exports = LibManifestPlugin;
|
|
@@ -20,7 +20,7 @@ const createSchemaValidation = require("./util/create-schema-validation");
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
const validate = createSchemaValidation(
|
|
23
|
-
require("../schemas/plugins/LoaderOptionsPlugin.check
|
|
23
|
+
require("../schemas/plugins/LoaderOptionsPlugin.check"),
|
|
24
24
|
() => require("../schemas/plugins/LoaderOptionsPlugin.json"),
|
|
25
25
|
{
|
|
26
26
|
name: "Loader Options Plugin",
|
|
@@ -39,13 +39,15 @@ class LoaderOptionsPlugin {
|
|
|
39
39
|
// If no options are set then generate empty options object
|
|
40
40
|
if (typeof options !== "object") options = {};
|
|
41
41
|
if (!options.test) {
|
|
42
|
-
/** @type {
|
|
42
|
+
/** @type {Partial<RegExp>} */
|
|
43
43
|
const defaultTrueMockRegExp = {
|
|
44
44
|
test: () => true
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
/** @type {RegExp} */
|
|
48
|
-
options.test =
|
|
48
|
+
options.test =
|
|
49
|
+
/** @type {RegExp} */
|
|
50
|
+
(defaultTrueMockRegExp);
|
|
49
51
|
}
|
|
50
52
|
this.options = options;
|
|
51
53
|
}
|
|
@@ -75,7 +77,7 @@ class LoaderOptionsPlugin {
|
|
|
75
77
|
continue;
|
|
76
78
|
}
|
|
77
79
|
|
|
78
|
-
/** @type {
|
|
80
|
+
/** @type {LoaderContext<EXPECTED_ANY> & Record<string, EXPECTED_ANY>} */
|
|
79
81
|
(context)[key] = options[key];
|
|
80
82
|
}
|
|
81
83
|
}
|
package/lib/MainTemplate.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const { SyncWaterfallHook } = require("tapable");
|
|
9
8
|
const util = require("util");
|
|
9
|
+
const { SyncWaterfallHook } = require("tapable");
|
|
10
10
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
|
11
11
|
const memoize = require("./util/memoize");
|
|
12
12
|
|
|
@@ -371,7 +371,7 @@ Object.defineProperty(MainTemplate.prototype, "outputOptions", {
|
|
|
371
371
|
* @this {MainTemplate}
|
|
372
372
|
* @returns {OutputOptions} output options
|
|
373
373
|
*/
|
|
374
|
-
function () {
|
|
374
|
+
function outputOptions() {
|
|
375
375
|
return this._outputOptions;
|
|
376
376
|
},
|
|
377
377
|
"MainTemplate.outputOptions is deprecated (use Compilation.outputOptions instead)",
|
package/lib/Module.js
CHANGED
|
@@ -40,12 +40,14 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
40
40
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
41
41
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
|
42
42
|
/** @typedef {import("./WebpackError")} WebpackError */
|
|
43
|
+
/** @typedef {import("./json/JsonData")} JsonData */
|
|
43
44
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
44
45
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
45
46
|
/** @typedef {import("./util/Hash")} Hash */
|
|
46
47
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
|
47
48
|
/** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
|
|
48
49
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
|
50
|
+
/** @typedef {"namespace" | "default-only" | "default-with-named" | "dynamic"} ExportsType */
|
|
49
51
|
|
|
50
52
|
/**
|
|
51
53
|
* @template T
|
|
@@ -115,6 +117,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
115
117
|
* @property {boolean=} sideEffectFree
|
|
116
118
|
* @property {Record<string, string>=} exportsFinalName
|
|
117
119
|
* @property {boolean=} isCSSModule
|
|
120
|
+
* @property {Record<string, string>=} jsIncompatibleExports
|
|
118
121
|
*/
|
|
119
122
|
|
|
120
123
|
/**
|
|
@@ -133,13 +136,18 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
133
136
|
* @property {LazySet<string>=} buildDependencies using in NormalModule
|
|
134
137
|
* @property {ValueCacheVersions=} valueDependencies using in NormalModule
|
|
135
138
|
* @property {Record<string, Source>=} assets using in NormalModule
|
|
139
|
+
* @property {Map<string, AssetInfo | undefined>=} assetsInfo using in NormalModule
|
|
136
140
|
* @property {string=} hash using in NormalModule
|
|
137
141
|
* @property {(Snapshot | null)=} snapshot using in ContextModule
|
|
138
142
|
* @property {string=} fullContentHash for assets modules
|
|
139
143
|
* @property {string=} filename for assets modules
|
|
140
|
-
* @property {Map<string, AssetInfo | undefined>=} assetsInfo for assets modules
|
|
141
144
|
* @property {boolean=} dataUrl for assets modules
|
|
145
|
+
* @property {AssetInfo=} assetInfo for assets modules
|
|
146
|
+
* @property {boolean=} javascriptModule for external modules
|
|
147
|
+
* @property {boolean=} active for lazy compilation modules
|
|
142
148
|
* @property {CssData=} cssData for css modules
|
|
149
|
+
* @property {JsonData=} jsonData for json modules
|
|
150
|
+
* @property {Set<string>=} topLevelDeclarations top level declaration names
|
|
143
151
|
*/
|
|
144
152
|
|
|
145
153
|
/** @typedef {Map<string, string | Set<string>>} ValueCacheVersions */
|
|
@@ -526,7 +534,7 @@ class Module extends DependenciesBlock {
|
|
|
526
534
|
/**
|
|
527
535
|
* @param {ModuleGraph} moduleGraph the module graph
|
|
528
536
|
* @param {boolean | undefined} strict the importing module is strict
|
|
529
|
-
* @returns {
|
|
537
|
+
* @returns {ExportsType} export type
|
|
530
538
|
* "namespace": Exports is already a namespace object. namespace = exports.
|
|
531
539
|
* "dynamic": Check at runtime if __esModule is set. When set: namespace = { ...exports, default: exports }. When not set: namespace = { default: exports }.
|
|
532
540
|
* "default-only": Provide a namespace object with only default export. namespace = { default: exports }
|
|
@@ -742,8 +750,9 @@ class Module extends DependenciesBlock {
|
|
|
742
750
|
// 1. If module is in one of the chunks of the group we can continue checking the next items
|
|
743
751
|
// because it's accessible.
|
|
744
752
|
for (const chunk of cg.chunks) {
|
|
745
|
-
if (chunk !== ignoreChunk && chunkGraph.isModuleInChunk(this, chunk))
|
|
753
|
+
if (chunk !== ignoreChunk && chunkGraph.isModuleInChunk(this, chunk)) {
|
|
746
754
|
continue queueFor;
|
|
755
|
+
}
|
|
747
756
|
}
|
|
748
757
|
// 2. If the chunk group is initial, we can break here because it's not accessible.
|
|
749
758
|
if (chunkGroup.isInitial()) return false;
|
|
@@ -771,8 +780,9 @@ class Module extends DependenciesBlock {
|
|
|
771
780
|
/** @type {Module} */ (fromModule)
|
|
772
781
|
)) {
|
|
773
782
|
// return true if module this is not reachable from originChunk when ignoring chunk
|
|
774
|
-
if (!this.isAccessibleInChunk(chunkGraph, originChunk, chunk))
|
|
783
|
+
if (!this.isAccessibleInChunk(chunkGraph, originChunk, chunk)) {
|
|
775
784
|
return true;
|
|
785
|
+
}
|
|
776
786
|
}
|
|
777
787
|
}
|
|
778
788
|
return false;
|
|
@@ -861,6 +871,7 @@ class Module extends DependenciesBlock {
|
|
|
861
871
|
*/
|
|
862
872
|
identifier() {
|
|
863
873
|
const AbstractMethodError = require("./AbstractMethodError");
|
|
874
|
+
|
|
864
875
|
throw new AbstractMethodError();
|
|
865
876
|
}
|
|
866
877
|
|
|
@@ -872,6 +883,7 @@ class Module extends DependenciesBlock {
|
|
|
872
883
|
*/
|
|
873
884
|
readableIdentifier(requestShortener) {
|
|
874
885
|
const AbstractMethodError = require("./AbstractMethodError");
|
|
886
|
+
|
|
875
887
|
throw new AbstractMethodError();
|
|
876
888
|
}
|
|
877
889
|
|
|
@@ -887,6 +899,7 @@ class Module extends DependenciesBlock {
|
|
|
887
899
|
*/
|
|
888
900
|
build(options, compilation, resolver, fs, callback) {
|
|
889
901
|
const AbstractMethodError = require("./AbstractMethodError");
|
|
902
|
+
|
|
890
903
|
throw new AbstractMethodError();
|
|
891
904
|
}
|
|
892
905
|
|
|
@@ -913,6 +926,7 @@ class Module extends DependenciesBlock {
|
|
|
913
926
|
source(dependencyTemplates, runtimeTemplate, type = "javascript") {
|
|
914
927
|
if (this.codeGeneration === Module.prototype.codeGeneration) {
|
|
915
928
|
const AbstractMethodError = require("./AbstractMethodError");
|
|
929
|
+
|
|
916
930
|
throw new AbstractMethodError();
|
|
917
931
|
}
|
|
918
932
|
const chunkGraph = ChunkGraph.getChunkGraphForModule(
|
|
@@ -946,6 +960,7 @@ class Module extends DependenciesBlock {
|
|
|
946
960
|
*/
|
|
947
961
|
size(type) {
|
|
948
962
|
const AbstractMethodError = require("./AbstractMethodError");
|
|
963
|
+
|
|
949
964
|
throw new AbstractMethodError();
|
|
950
965
|
}
|
|
951
966
|
|
|
@@ -1179,7 +1194,7 @@ Object.defineProperty(Module.prototype, "errors", {
|
|
|
1179
1194
|
* @this {Module}
|
|
1180
1195
|
* @returns {WebpackError[]} errors
|
|
1181
1196
|
*/
|
|
1182
|
-
function () {
|
|
1197
|
+
function errors() {
|
|
1183
1198
|
if (this._errors === undefined) {
|
|
1184
1199
|
this._errors = [];
|
|
1185
1200
|
}
|
|
@@ -1201,7 +1216,7 @@ Object.defineProperty(Module.prototype, "warnings", {
|
|
|
1201
1216
|
* @this {Module}
|
|
1202
1217
|
* @returns {WebpackError[]} warnings
|
|
1203
1218
|
*/
|
|
1204
|
-
function () {
|
|
1219
|
+
function warnings() {
|
|
1205
1220
|
if (this._warnings === undefined) {
|
|
1206
1221
|
this._warnings = [];
|
|
1207
1222
|
}
|
package/lib/ModuleFactory.js
CHANGED
package/lib/ModuleGraph.js
CHANGED
|
@@ -441,8 +441,9 @@ class ModuleGraph {
|
|
|
441
441
|
/** @type {Dependency} */ (connection.dependency),
|
|
442
442
|
connection
|
|
443
443
|
);
|
|
444
|
-
if (connection.dependency === dependency)
|
|
444
|
+
if (connection.dependency === dependency) {
|
|
445
445
|
foundConnection = connection;
|
|
446
|
+
}
|
|
446
447
|
}
|
|
447
448
|
mgm._unassignedConnections.length = 0;
|
|
448
449
|
if (foundConnection !== undefined) {
|
|
@@ -752,6 +753,26 @@ class ModuleGraph {
|
|
|
752
753
|
return mgm.async;
|
|
753
754
|
}
|
|
754
755
|
|
|
756
|
+
/**
|
|
757
|
+
* @param {Module} module the module
|
|
758
|
+
* @returns {boolean} true, if the module is used as a deferred module at least once
|
|
759
|
+
*/
|
|
760
|
+
isDeferred(module) {
|
|
761
|
+
if (this.isAsync(module)) return false;
|
|
762
|
+
const connections = this.getIncomingConnections(module);
|
|
763
|
+
for (const connection of connections) {
|
|
764
|
+
if (
|
|
765
|
+
!connection.dependency ||
|
|
766
|
+
connection.dependency instanceof
|
|
767
|
+
require("./dependencies/CommonJsSelfReferenceDependency")
|
|
768
|
+
) {
|
|
769
|
+
continue;
|
|
770
|
+
}
|
|
771
|
+
if (connection.dependency.defer) return true;
|
|
772
|
+
}
|
|
773
|
+
return false;
|
|
774
|
+
}
|
|
775
|
+
|
|
755
776
|
/**
|
|
756
777
|
* @param {Module} module the module
|
|
757
778
|
* @returns {void}
|
|
@@ -860,12 +881,13 @@ class ModuleGraph {
|
|
|
860
881
|
*/
|
|
861
882
|
module => {
|
|
862
883
|
const moduleGraph = moduleGraphForModuleMap.get(module);
|
|
863
|
-
if (!moduleGraph)
|
|
884
|
+
if (!moduleGraph) {
|
|
864
885
|
throw new Error(
|
|
865
886
|
`${
|
|
866
887
|
deprecateMessage
|
|
867
888
|
}There was no ModuleGraph assigned to the Module for backward-compat (Use the new API)`
|
|
868
889
|
);
|
|
890
|
+
}
|
|
869
891
|
return moduleGraph;
|
|
870
892
|
},
|
|
871
893
|
`${deprecateMessage}: Use new ModuleGraph API`,
|
|
@@ -132,7 +132,7 @@ class ModuleGraphConnection {
|
|
|
132
132
|
|
|
133
133
|
get explanation() {
|
|
134
134
|
if (this.explanations === undefined) return "";
|
|
135
|
-
return
|
|
135
|
+
return [...this.explanations].join(" ");
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/**
|
|
@@ -190,10 +190,10 @@ class ModuleGraphConnection {
|
|
|
190
190
|
/** @typedef {typeof CIRCULAR_CONNECTION} CIRCULAR_CONNECTION */
|
|
191
191
|
|
|
192
192
|
module.exports = ModuleGraphConnection;
|
|
193
|
-
module.exports.addConnectionStates = addConnectionStates;
|
|
194
|
-
module.exports.TRANSITIVE_ONLY = /** @type {typeof TRANSITIVE_ONLY} */ (
|
|
195
|
-
TRANSITIVE_ONLY
|
|
196
|
-
);
|
|
197
193
|
module.exports.CIRCULAR_CONNECTION = /** @type {typeof CIRCULAR_CONNECTION} */ (
|
|
198
194
|
CIRCULAR_CONNECTION
|
|
199
195
|
);
|
|
196
|
+
module.exports.TRANSITIVE_ONLY = /** @type {typeof TRANSITIVE_ONLY} */ (
|
|
197
|
+
TRANSITIVE_ONLY
|
|
198
|
+
);
|
|
199
|
+
module.exports.addConnectionStates = addConnectionStates;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
-
const { ConcatSource, RawSource
|
|
8
|
+
const { CachedSource, ConcatSource, RawSource } = require("webpack-sources");
|
|
9
9
|
const { UsageState } = require("./ExportsInfo");
|
|
10
10
|
const Template = require("./Template");
|
|
11
11
|
const CssModulesPlugin = require("./css/CssModulesPlugin");
|
|
@@ -310,4 +310,5 @@ class ModuleInfoHeaderPlugin {
|
|
|
310
310
|
return new RawSource(headerStr);
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
+
|
|
313
314
|
module.exports = ModuleInfoHeaderPlugin;
|
package/lib/ModuleParseError.js
CHANGED
|
@@ -102,22 +102,22 @@ const CONSUME_SHARED_TYPES = new Set(["consume-shared"]);
|
|
|
102
102
|
*/
|
|
103
103
|
const SHARED_INIT_TYPES = new Set(["share-init"]);
|
|
104
104
|
|
|
105
|
-
module.exports.NO_TYPES = NO_TYPES;
|
|
106
|
-
module.exports.JS_TYPE = JS_TYPE;
|
|
107
|
-
module.exports.JS_TYPES = JS_TYPES;
|
|
108
|
-
module.exports.JS_AND_CSS_TYPES = JS_AND_CSS_TYPES;
|
|
109
|
-
module.exports.JS_AND_CSS_URL_TYPES = JS_AND_CSS_URL_TYPES;
|
|
110
|
-
module.exports.JS_AND_CSS_EXPORT_TYPES = JS_AND_CSS_EXPORT_TYPES;
|
|
111
|
-
module.exports.ASSET_TYPES = ASSET_TYPES;
|
|
112
|
-
module.exports.ASSET_AND_JS_TYPES = ASSET_AND_JS_TYPES;
|
|
113
105
|
module.exports.ASSET_AND_CSS_URL_TYPES = ASSET_AND_CSS_URL_TYPES;
|
|
114
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;
|
|
115
111
|
module.exports.CSS_TYPE = CSS_TYPE;
|
|
116
112
|
module.exports.CSS_TYPES = CSS_TYPES;
|
|
117
113
|
module.exports.CSS_URL_TYPES = CSS_URL_TYPES;
|
|
118
|
-
module.exports.
|
|
119
|
-
module.exports.
|
|
120
|
-
module.exports.
|
|
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;
|
|
121
120
|
module.exports.REMOTE_AND_SHARE_INIT_TYPES = REMOTE_AND_SHARE_INIT_TYPES;
|
|
122
|
-
module.exports.
|
|
121
|
+
module.exports.RUNTIME_TYPES = RUNTIME_TYPES;
|
|
123
122
|
module.exports.SHARED_INIT_TYPES = SHARED_INIT_TYPES;
|
|
123
|
+
module.exports.WEBASSEMBLY_TYPES = WEBASSEMBLY_TYPES;
|