webpack 5.92.1 → 5.94.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 +8 -5
- package/bin/webpack.js +6 -7
- package/hot/log.js +1 -2
- package/hot/only-dev-server.js +1 -1
- package/hot/poll.js +1 -1
- package/hot/signal.js +1 -1
- package/lib/APIPlugin.js +4 -3
- package/lib/AbstractMethodError.js +10 -5
- package/lib/AutomaticPrefetchPlugin.js +1 -1
- package/lib/BannerPlugin.js +12 -6
- package/lib/Cache.js +8 -10
- package/lib/CacheFacade.js +3 -3
- package/lib/CaseSensitiveModulesWarning.js +5 -7
- package/lib/Chunk.js +14 -11
- package/lib/ChunkGraph.js +58 -36
- package/lib/ChunkGroup.js +2 -3
- package/lib/ChunkTemplate.js +43 -0
- package/lib/CleanPlugin.js +10 -11
- package/lib/CodeGenerationResults.js +6 -5
- package/lib/CommentCompilationWarning.js +0 -1
- package/lib/Compilation.js +223 -191
- package/lib/Compiler.js +81 -82
- package/lib/ConcatenationScope.js +3 -6
- package/lib/ConditionalInitFragment.js +6 -7
- package/lib/ConstPlugin.js +7 -15
- package/lib/ContextExclusionPlugin.js +3 -3
- package/lib/ContextModule.js +36 -21
- package/lib/ContextModuleFactory.js +89 -44
- package/lib/ContextReplacementPlugin.js +10 -9
- package/lib/DefinePlugin.js +76 -69
- package/lib/DelegatedModule.js +7 -3
- package/lib/DelegatedModuleFactoryPlugin.js +36 -22
- package/lib/DelegatedPlugin.js +4 -0
- package/lib/DependenciesBlock.js +0 -1
- package/lib/Dependency.js +10 -14
- package/lib/DllEntryPlugin.js +4 -2
- package/lib/DllModuleFactory.js +1 -0
- package/lib/DllPlugin.js +9 -7
- package/lib/DllReferencePlugin.js +30 -15
- package/lib/EntryPlugin.js +1 -3
- package/lib/EnvironmentPlugin.js +5 -2
- package/lib/ErrorHelpers.js +11 -12
- package/lib/EvalDevToolModulePlugin.js +10 -12
- package/lib/EvalSourceMapDevToolPlugin.js +15 -13
- package/lib/ExportsInfo.js +185 -120
- package/lib/ExternalModule.js +104 -64
- package/lib/ExternalModuleFactoryPlugin.js +23 -10
- package/lib/FileSystemInfo.js +791 -422
- package/lib/FlagAllModulesAsUsedPlugin.js +1 -1
- package/lib/FlagDependencyExportsPlugin.js +12 -11
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +2 -5
- package/lib/GraphHelpers.js +3 -2
- package/lib/HookWebpackError.js +8 -10
- package/lib/HotModuleReplacementPlugin.js +78 -64
- package/lib/IgnoreErrorModuleFactory.js +3 -3
- package/lib/IgnorePlugin.js +1 -3
- package/lib/IgnoreWarningsPlugin.js +6 -9
- package/lib/InitFragment.js +2 -3
- package/lib/LibManifestPlugin.js +4 -3
- package/lib/MainTemplate.js +72 -19
- package/lib/Module.js +25 -9
- package/lib/ModuleBuildError.js +4 -11
- package/lib/ModuleDependencyError.js +5 -5
- package/lib/ModuleDependencyWarning.js +5 -5
- package/lib/ModuleError.js +1 -5
- package/lib/ModuleFilenameHelpers.js +29 -46
- package/lib/ModuleGraph.js +7 -6
- package/lib/ModuleGraphConnection.js +6 -6
- package/lib/ModuleInfoHeaderPlugin.js +82 -30
- package/lib/ModuleParseError.js +8 -9
- package/lib/ModuleRestoreError.js +1 -1
- package/lib/ModuleStoreError.js +1 -1
- package/lib/ModuleTemplate.js +33 -1
- package/lib/ModuleTypeConstants.js +21 -22
- package/lib/ModuleWarning.js +1 -5
- package/lib/MultiCompiler.js +24 -26
- package/lib/MultiStats.js +73 -31
- package/lib/MultiWatching.js +1 -1
- package/lib/NormalModule.js +132 -70
- package/lib/NormalModuleFactory.js +53 -49
- package/lib/OptimizationStages.js +3 -3
- package/lib/ProgressPlugin.js +9 -9
- package/lib/ProvidePlugin.js +4 -4
- package/lib/RuntimeGlobals.js +71 -70
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +24 -12
- package/lib/RuntimeTemplate.js +40 -44
- package/lib/SizeFormatHelpers.js +2 -4
- package/lib/SourceMapDevToolPlugin.js +42 -34
- package/lib/Stats.js +5 -11
- package/lib/Template.js +18 -24
- package/lib/TemplatedPathPlugin.js +12 -10
- package/lib/UseStrictPlugin.js +8 -1
- package/lib/WarnDeprecatedOptionPlugin.js +0 -1
- package/lib/WatchIgnorePlugin.js +26 -9
- package/lib/Watching.js +10 -5
- package/lib/WebpackOptionsApply.js +89 -62
- package/lib/asset/AssetGenerator.js +107 -42
- package/lib/asset/AssetModulesPlugin.js +29 -23
- package/lib/asset/AssetSourceGenerator.js +2 -7
- package/lib/async-modules/AwaitDependenciesInitFragment.js +6 -7
- package/lib/buildChunkGraph.js +14 -19
- package/lib/cache/IdleFileCachePlugin.js +4 -4
- package/lib/cache/MemoryWithGcCachePlugin.js +5 -5
- package/lib/cache/PackFileCacheStrategy.js +51 -50
- package/lib/cache/ResolverCachePlugin.js +6 -6
- package/lib/cache/mergeEtags.js +16 -21
- package/lib/cli.js +148 -104
- package/lib/config/browserslistTargetHandler.js +16 -13
- package/lib/config/defaults.js +31 -28
- package/lib/config/normalization.js +335 -344
- package/lib/config/target.js +42 -52
- package/lib/container/ContainerEntryModule.js +2 -2
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/RemoteRuntimeModule.js +11 -8
- package/lib/container/options.js +18 -4
- package/lib/css/CssExportsGenerator.js +39 -40
- package/lib/css/CssGenerator.js +11 -14
- package/lib/css/CssLoadingRuntimeModule.js +10 -10
- package/lib/css/CssModulesPlugin.js +127 -47
- package/lib/css/CssParser.js +20 -18
- package/lib/css/walkCssTokens.js +80 -95
- package/lib/debug/ProfilingPlugin.js +19 -20
- package/lib/dependencies/AMDDefineDependency.js +1 -1
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +83 -47
- package/lib/dependencies/AMDRequireArrayDependency.js +9 -10
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +22 -16
- package/lib/dependencies/AMDRuntimeModules.js +2 -2
- package/lib/dependencies/CommonJsDependencyHelpers.js +6 -2
- package/lib/dependencies/CommonJsExportRequireDependency.js +37 -41
- package/lib/dependencies/CommonJsExportsDependency.js +0 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +19 -23
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +52 -61
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +6 -8
- package/lib/dependencies/ConstDependency.js +1 -1
- package/lib/dependencies/ContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +31 -34
- package/lib/dependencies/ContextElementDependency.js +2 -2
- package/lib/dependencies/CriticalDependencyWarning.js +1 -1
- package/lib/dependencies/CssExportDependency.js +72 -9
- package/lib/dependencies/CssImportDependency.js +0 -2
- package/lib/dependencies/CssLocalIdentifierDependency.js +68 -21
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/CssUrlDependency.js +4 -5
- package/lib/dependencies/DynamicExports.js +5 -5
- package/lib/dependencies/ExportsInfoDependency.js +1 -2
- package/lib/dependencies/HarmonyAcceptImportDependency.js +1 -1
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +4 -5
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +27 -16
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +107 -64
- package/lib/dependencies/HarmonyExports.js +2 -2
- package/lib/dependencies/HarmonyImportDependency.js +2 -4
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +19 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +41 -16
- package/lib/dependencies/ImportDependency.js +1 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +5 -5
- package/lib/dependencies/ImportMetaPlugin.js +11 -13
- package/lib/dependencies/ImportParserPlugin.js +39 -44
- package/lib/dependencies/JsonExportsDependency.js +22 -18
- package/lib/dependencies/LoaderPlugin.js +47 -36
- package/lib/dependencies/LocalModule.js +1 -1
- package/lib/dependencies/LocalModulesHelpers.js +4 -4
- package/lib/dependencies/ModuleDecoratorDependency.js +1 -1
- package/lib/dependencies/ProvidedDependency.js +1 -1
- package/lib/dependencies/PureExpressionDependency.js +6 -6
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLDependency.js +3 -3
- package/lib/dependencies/URLPlugin.js +66 -12
- package/lib/dependencies/WorkerPlugin.js +25 -24
- package/lib/dependencies/processExportInfo.js +3 -1
- package/lib/electron/ElectronTargetPlugin.js +1 -0
- package/lib/esm/ModuleChunkFormatPlugin.js +11 -12
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -3
- package/lib/formatLocation.js +1 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +4 -5
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +9 -12
- package/lib/hmr/LazyCompilationPlugin.js +27 -12
- package/lib/hmr/lazyCompilationBackend.js +64 -40
- package/lib/ids/ChunkModuleIdRangePlugin.js +1 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +2 -4
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/ids/HashedModuleIdsPlugin.js +5 -1
- package/lib/ids/IdHelpers.js +29 -39
- package/lib/ids/SyncModuleIdsPlugin.js +7 -2
- package/lib/index.js +1 -5
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +6 -4
- package/lib/javascript/BasicEvaluatedExpression.js +4 -19
- package/lib/javascript/ChunkHelpers.js +1 -1
- package/lib/javascript/CommonJsChunkFormatPlugin.js +10 -11
- package/lib/javascript/EnableChunkLoadingPlugin.js +7 -6
- package/lib/javascript/JavascriptGenerator.js +23 -7
- package/lib/javascript/JavascriptModulesPlugin.js +97 -70
- package/lib/javascript/JavascriptParser.js +179 -200
- package/lib/javascript/JavascriptParserHelpers.js +20 -21
- package/lib/javascript/StartupHelpers.js +41 -13
- package/lib/json/JsonGenerator.js +7 -13
- package/lib/json/JsonModulesPlugin.js +1 -4
- package/lib/json/JsonParser.js +5 -3
- package/lib/library/AmdLibraryPlugin.js +12 -16
- package/lib/library/AssignLibraryPlugin.js +9 -11
- package/lib/library/EnableLibraryPlugin.js +25 -15
- package/lib/library/ExportPropertyLibraryPlugin.js +8 -2
- package/lib/library/JsonpLibraryPlugin.js +2 -1
- package/lib/library/ModernModuleLibraryPlugin.js +144 -0
- package/lib/library/ModuleLibraryPlugin.js +2 -1
- package/lib/library/SystemLibraryPlugin.js +2 -1
- package/lib/library/UmdLibraryPlugin.js +66 -92
- package/lib/logging/Logger.js +32 -4
- package/lib/logging/createConsoleLogger.js +12 -13
- package/lib/logging/runtime.js +7 -8
- package/lib/logging/truncateArgs.js +5 -8
- package/lib/node/NodeWatchFileSystem.js +3 -18
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +1 -0
- package/lib/node/RequireChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/nodeConsole.js +22 -22
- package/lib/optimize/AggressiveMergingPlugin.js +2 -4
- package/lib/optimize/AggressiveSplittingPlugin.js +16 -19
- package/lib/optimize/ConcatenatedModule.js +144 -61
- package/lib/optimize/EnsureChunkConditionsPlugin.js +1 -1
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -3
- package/lib/optimize/InnerGraph.js +17 -17
- package/lib/optimize/InnerGraphPlugin.js +8 -7
- package/lib/optimize/LimitChunkCountPlugin.js +2 -3
- package/lib/optimize/MangleExportsPlugin.js +1 -0
- package/lib/optimize/MinMaxSizeWarning.js +1 -1
- package/lib/optimize/ModuleConcatenationPlugin.js +56 -78
- package/lib/optimize/RealContentHashPlugin.js +7 -10
- package/lib/optimize/RemoveParentModulesPlugin.js +3 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +6 -2
- package/lib/optimize/SplitChunksPlugin.js +34 -30
- package/lib/performance/SizeLimitsPlugin.js +2 -2
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +1 -0
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +1 -1
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +1 -1
- package/lib/rules/BasicEffectRulePlugin.js +3 -1
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +4 -1
- package/lib/rules/RuleSetCompiler.js +41 -22
- package/lib/rules/UseEffectRulePlugin.js +36 -32
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -1
- package/lib/runtime/AutoPublicPathRuntimeModule.js +8 -3
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +2 -2
- package/lib/runtime/DefinePropertyGettersRuntimeModule.js +1 -1
- package/lib/runtime/EnsureChunkRuntimeModule.js +10 -11
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +11 -17
- package/lib/runtime/LoadScriptRuntimeModule.js +17 -18
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +1 -3
- package/lib/schemes/DataUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +241 -126
- package/lib/serialization/BinaryMiddleware.js +44 -28
- package/lib/serialization/DateObjectSerializer.js +1 -0
- package/lib/serialization/ErrorObjectSerializer.js +2 -0
- package/lib/serialization/FileMiddleware.js +154 -106
- package/lib/serialization/MapObjectSerializer.js +2 -1
- package/lib/serialization/NullPrototypeObjectSerializer.js +3 -2
- package/lib/serialization/ObjectMiddleware.js +52 -56
- package/lib/serialization/PlainObjectSerializer.js +32 -6
- package/lib/serialization/RegExpObjectSerializer.js +1 -0
- package/lib/serialization/Serializer.js +4 -5
- package/lib/serialization/SerializerMiddleware.js +6 -6
- package/lib/serialization/SetObjectSerializer.js +2 -1
- package/lib/sharing/ConsumeSharedModule.js +19 -14
- package/lib/sharing/ConsumeSharedPlugin.js +116 -97
- package/lib/sharing/ConsumeSharedRuntimeModule.js +108 -141
- package/lib/sharing/ProvideForSharedDependency.js +0 -1
- package/lib/sharing/ProvideSharedPlugin.js +2 -2
- package/lib/sharing/resolveMatchedConfigs.js +2 -1
- package/lib/sharing/utils.js +15 -27
- package/lib/stats/DefaultStatsFactoryPlugin.js +424 -281
- package/lib/stats/DefaultStatsPresetPlugin.js +73 -18
- package/lib/stats/DefaultStatsPrinterPlugin.js +370 -101
- package/lib/stats/StatsFactory.js +127 -56
- package/lib/stats/StatsPrinter.js +75 -44
- package/lib/util/ArrayHelpers.js +8 -4
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +31 -12
- package/lib/util/IterableHelpers.js +3 -4
- package/lib/util/LazyBucketSortedSet.js +60 -44
- package/lib/util/LazySet.js +1 -0
- package/lib/util/MapHelpers.js +1 -3
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/Queue.js +1 -1
- package/lib/util/Semaphore.js +4 -7
- package/lib/util/SetHelpers.js +5 -5
- package/lib/util/SortableSet.js +4 -3
- package/lib/util/StackedCacheMap.js +4 -6
- package/lib/util/StackedMap.js +1 -3
- package/lib/util/StringXor.js +0 -5
- package/lib/util/TupleQueue.js +1 -1
- package/lib/util/TupleSet.js +15 -5
- package/lib/util/URLAbsoluteSpecifier.js +7 -7
- package/lib/util/WeakTupleMap.js +19 -21
- package/lib/util/binarySearchBounds.js +5 -12
- package/lib/util/chainedImports.js +1 -1
- package/lib/util/cleverMerge.js +21 -19
- package/lib/util/comparators.js +57 -52
- package/lib/util/compileBooleanMatcher.js +3 -6
- package/lib/util/conventions.js +10 -13
- package/lib/util/createHash.js +9 -6
- package/lib/util/deprecation.js +22 -12
- package/lib/util/deterministicGrouping.js +19 -26
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +31 -31
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +7 -7
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/identifier.js +81 -59
- package/lib/util/memoize.js +8 -10
- package/lib/util/mergeScope.js +6 -9
- package/lib/util/nonNumericOnlyHash.js +2 -2
- package/lib/util/numberHash.js +1 -6
- package/lib/util/objectToMap.js +0 -1
- package/lib/util/propertyAccess.js +2 -5
- package/lib/util/propertyName.js +1 -3
- package/lib/util/registerExternalSerializer.js +1 -1
- package/lib/util/runtime.js +103 -113
- package/lib/util/semver.js +29 -27
- package/lib/util/serialization.js +16 -1
- package/lib/util/smartGrouping.js +5 -5
- package/lib/util/source.js +1 -1
- package/lib/wasm/EnableWasmLoadingPlugin.js +5 -4
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -6
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +3 -3
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +20 -19
- package/lib/wasm-sync/WebAssemblyGenerator.js +14 -29
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-sync/WebAssemblyUtils.js +2 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +17 -16
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +17 -0
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetInlineGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- 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/types.d.ts +682 -347
package/lib/MultiStats.js
CHANGED
@@ -8,15 +8,25 @@
|
|
8
8
|
const identifierUtils = require("./util/identifier");
|
9
9
|
|
10
10
|
/** @typedef {import("../declarations/WebpackOptions").StatsOptions} StatsOptions */
|
11
|
+
/** @typedef {import("./Compilation").CreateStatsOptionsContext} CreateStatsOptionsContext */
|
12
|
+
/** @typedef {import("./Compilation").NormalizedStatsOptions} NormalizedStatsOptions */
|
11
13
|
/** @typedef {import("./Stats")} Stats */
|
12
14
|
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").KnownStatsCompilation} KnownStatsCompilation */
|
13
15
|
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsCompilation} StatsCompilation */
|
16
|
+
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsError} StatsError */
|
14
17
|
|
18
|
+
/**
|
19
|
+
* @param {string} str string
|
20
|
+
* @param {string} prefix pref
|
21
|
+
* @returns {string} indent
|
22
|
+
*/
|
15
23
|
const indent = (str, prefix) => {
|
16
|
-
const rem = str.replace(/\n([^\n])/g,
|
24
|
+
const rem = str.replace(/\n([^\n])/g, `\n${prefix}$1`);
|
17
25
|
return prefix + rem;
|
18
26
|
};
|
19
27
|
|
28
|
+
/** @typedef {{ version: boolean, hash: boolean, errorsCount: boolean, warningsCount: boolean, errors: boolean, warnings: boolean, children: NormalizedStatsOptions[] }} ChildOptions */
|
29
|
+
|
20
30
|
class MultiStats {
|
21
31
|
/**
|
22
32
|
* @param {Stats[]} stats the child stats
|
@@ -43,13 +53,30 @@ class MultiStats {
|
|
43
53
|
return this.stats.some(stat => stat.hasWarnings());
|
44
54
|
}
|
45
55
|
|
56
|
+
/**
|
57
|
+
* @param {string | boolean | StatsOptions | undefined} options stats options
|
58
|
+
* @param {CreateStatsOptionsContext} context context
|
59
|
+
* @returns {ChildOptions} context context
|
60
|
+
*/
|
46
61
|
_createChildOptions(options, context) {
|
47
|
-
|
48
|
-
options
|
49
|
-
|
50
|
-
|
51
|
-
|
62
|
+
const getCreateStatsOptions = () => {
|
63
|
+
if (!options) {
|
64
|
+
options = {};
|
65
|
+
}
|
66
|
+
|
67
|
+
const { children: childrenOptions = undefined, ...baseOptions } =
|
68
|
+
typeof options === "string"
|
69
|
+
? { preset: options }
|
70
|
+
: /** @type {StatsOptions} */ (options);
|
71
|
+
|
72
|
+
return { childrenOptions, baseOptions };
|
73
|
+
};
|
74
|
+
|
52
75
|
const children = this.stats.map((stat, idx) => {
|
76
|
+
if (typeof options === "boolean") {
|
77
|
+
return stat.compilation.createStatsOptions(options, context);
|
78
|
+
}
|
79
|
+
const { childrenOptions, baseOptions } = getCreateStatsOptions();
|
53
80
|
const childOptions = Array.isArray(childrenOptions)
|
54
81
|
? childrenOptions[idx]
|
55
82
|
: childrenOptions;
|
@@ -77,81 +104,96 @@ class MultiStats {
|
|
77
104
|
}
|
78
105
|
|
79
106
|
/**
|
80
|
-
* @param {
|
107
|
+
* @param {(string | boolean | StatsOptions)=} options stats options
|
81
108
|
* @returns {StatsCompilation} json output
|
82
109
|
*/
|
83
110
|
toJson(options) {
|
84
|
-
|
111
|
+
const childOptions = this._createChildOptions(options, {
|
112
|
+
forToString: false
|
113
|
+
});
|
85
114
|
/** @type {KnownStatsCompilation} */
|
86
115
|
const obj = {};
|
87
116
|
obj.children = this.stats.map((stat, idx) => {
|
88
|
-
const obj = stat.toJson(
|
117
|
+
const obj = stat.toJson(childOptions.children[idx]);
|
89
118
|
const compilationName = stat.compilation.name;
|
90
119
|
const name =
|
91
120
|
compilationName &&
|
92
121
|
identifierUtils.makePathsRelative(
|
93
|
-
|
122
|
+
stat.compilation.compiler.context,
|
94
123
|
compilationName,
|
95
124
|
stat.compilation.compiler.root
|
96
125
|
);
|
97
126
|
obj.name = name;
|
98
127
|
return obj;
|
99
128
|
});
|
100
|
-
if (
|
129
|
+
if (childOptions.version) {
|
101
130
|
obj.version = obj.children[0].version;
|
102
131
|
}
|
103
|
-
if (
|
132
|
+
if (childOptions.hash) {
|
104
133
|
obj.hash = obj.children.map(j => j.hash).join("");
|
105
134
|
}
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
135
|
+
/**
|
136
|
+
* @param {StatsCompilation} j stats error
|
137
|
+
* @param {StatsError} obj Stats error
|
138
|
+
* @returns {TODO} result
|
139
|
+
*/
|
140
|
+
const mapError = (j, obj) => ({
|
141
|
+
...obj,
|
142
|
+
compilerPath: obj.compilerPath ? `${j.name}.${obj.compilerPath}` : j.name
|
143
|
+
});
|
144
|
+
if (childOptions.errors) {
|
115
145
|
obj.errors = [];
|
116
146
|
for (const j of obj.children) {
|
117
|
-
|
147
|
+
const errors =
|
148
|
+
/** @type {NonNullable<KnownStatsCompilation["errors"]>} */
|
149
|
+
(j.errors);
|
150
|
+
for (const i of errors) {
|
118
151
|
obj.errors.push(mapError(j, i));
|
119
152
|
}
|
120
153
|
}
|
121
154
|
}
|
122
|
-
if (
|
155
|
+
if (childOptions.warnings) {
|
123
156
|
obj.warnings = [];
|
124
157
|
for (const j of obj.children) {
|
125
|
-
|
158
|
+
const warnings =
|
159
|
+
/** @type {NonNullable<KnownStatsCompilation["warnings"]>} */
|
160
|
+
(j.warnings);
|
161
|
+
for (const i of warnings) {
|
126
162
|
obj.warnings.push(mapError(j, i));
|
127
163
|
}
|
128
164
|
}
|
129
165
|
}
|
130
|
-
if (
|
166
|
+
if (childOptions.errorsCount) {
|
131
167
|
obj.errorsCount = 0;
|
132
168
|
for (const j of obj.children) {
|
133
|
-
obj.errorsCount += j.errorsCount;
|
169
|
+
obj.errorsCount += /** @type {number} */ (j.errorsCount);
|
134
170
|
}
|
135
171
|
}
|
136
|
-
if (
|
172
|
+
if (childOptions.warningsCount) {
|
137
173
|
obj.warningsCount = 0;
|
138
174
|
for (const j of obj.children) {
|
139
|
-
obj.warningsCount += j.warningsCount;
|
175
|
+
obj.warningsCount += /** @type {number} */ (j.warningsCount);
|
140
176
|
}
|
141
177
|
}
|
142
178
|
return obj;
|
143
179
|
}
|
144
180
|
|
181
|
+
/**
|
182
|
+
* @param {(string | boolean | StatsOptions)=} options stats options
|
183
|
+
* @returns {string} string output
|
184
|
+
*/
|
145
185
|
toString(options) {
|
146
|
-
|
186
|
+
const childOptions = this._createChildOptions(options, {
|
187
|
+
forToString: true
|
188
|
+
});
|
147
189
|
const results = this.stats.map((stat, idx) => {
|
148
|
-
const str = stat.toString(
|
190
|
+
const str = stat.toString(childOptions.children[idx]);
|
149
191
|
const compilationName = stat.compilation.name;
|
150
192
|
const name =
|
151
193
|
compilationName &&
|
152
194
|
identifierUtils
|
153
195
|
.makePathsRelative(
|
154
|
-
|
196
|
+
stat.compilation.compiler.context,
|
155
197
|
compilationName,
|
156
198
|
stat.compilation.compiler.root
|
157
199
|
)
|
package/lib/MultiWatching.js
CHANGED
package/lib/NormalModule.js
CHANGED
@@ -82,12 +82,27 @@ const memoize = require("./util/memoize");
|
|
82
82
|
/** @typedef {import("./util/Hash")} Hash */
|
83
83
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
84
84
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
85
|
+
/** @typedef {import("./util/createHash").Algorithm} Algorithm */
|
86
|
+
/**
|
87
|
+
* @template T
|
88
|
+
* @typedef {import("./util/deprecation").FakeHook<T>} FakeHook
|
89
|
+
*/
|
85
90
|
|
86
91
|
/** @typedef {{[k: string]: any}} ParserOptions */
|
87
92
|
/** @typedef {{[k: string]: any}} GeneratorOptions */
|
88
93
|
|
89
94
|
/** @typedef {UnsafeCacheData & { parser: undefined | Parser, parserOptions: undefined | ParserOptions, generator: undefined | Generator, generatorOptions: undefined | GeneratorOptions }} NormalModuleUnsafeCacheData */
|
90
95
|
|
96
|
+
/**
|
97
|
+
* @template T
|
98
|
+
* @typedef {import("../declarations/LoaderContext").LoaderContext<T>} LoaderContext
|
99
|
+
*/
|
100
|
+
|
101
|
+
/**
|
102
|
+
* @template T
|
103
|
+
* @typedef {import("../declarations/LoaderContext").NormalModuleLoaderContext<T>} NormalModuleLoaderContext
|
104
|
+
*/
|
105
|
+
|
91
106
|
/**
|
92
107
|
* @typedef {object} SourceMap
|
93
108
|
* @property {number} version
|
@@ -184,11 +199,14 @@ const asBuffer = input => {
|
|
184
199
|
};
|
185
200
|
|
186
201
|
class NonErrorEmittedError extends WebpackError {
|
202
|
+
/**
|
203
|
+
* @param {any} error value which is not an instance of Error
|
204
|
+
*/
|
187
205
|
constructor(error) {
|
188
206
|
super();
|
189
207
|
|
190
208
|
this.name = "NonErrorEmittedError";
|
191
|
-
this.message =
|
209
|
+
this.message = `(Emitted value instead of an instance of Error) ${error}`;
|
192
210
|
}
|
193
211
|
}
|
194
212
|
|
@@ -200,12 +218,12 @@ makeSerializable(
|
|
200
218
|
|
201
219
|
/**
|
202
220
|
* @typedef {object} NormalModuleCompilationHooks
|
203
|
-
* @property {SyncHook<[
|
204
|
-
* @property {SyncHook<[LoaderItem[], NormalModule,
|
221
|
+
* @property {SyncHook<[LoaderContext<any>, NormalModule]>} loader
|
222
|
+
* @property {SyncHook<[LoaderItem[], NormalModule, LoaderContext<any>]>} beforeLoaders
|
205
223
|
* @property {SyncHook<[NormalModule]>} beforeParse
|
206
224
|
* @property {SyncHook<[NormalModule]>} beforeSnapshot
|
207
|
-
* @property {HookMap<AsyncSeriesBailHook<[string, NormalModule], string | Buffer
|
208
|
-
* @property {HookMap<AsyncSeriesBailHook<[
|
225
|
+
* @property {HookMap<FakeHook<AsyncSeriesBailHook<[string, NormalModule], string | Buffer | null>>>} readResourceForScheme
|
226
|
+
* @property {HookMap<AsyncSeriesBailHook<[LoaderContext<any>], string | Buffer | null>>} readResource
|
209
227
|
* @property {AsyncSeriesBailHook<[NormalModule, NeedBuildContext], boolean>} needBuild
|
210
228
|
*/
|
211
229
|
|
@@ -251,20 +269,32 @@ class NormalModule extends Module {
|
|
251
269
|
beforeSnapshot: new SyncHook(["module"]),
|
252
270
|
// TODO webpack 6 deprecate
|
253
271
|
readResourceForScheme: new HookMap(scheme => {
|
254
|
-
const hook =
|
272
|
+
const hook =
|
273
|
+
/** @type {NormalModuleCompilationHooks} */
|
274
|
+
(hooks).readResource.for(scheme);
|
255
275
|
return createFakeHook(
|
256
|
-
/** @type {AsyncSeriesBailHook<[string, NormalModule], string | Buffer>} */ ({
|
276
|
+
/** @type {AsyncSeriesBailHook<[string, NormalModule], string | Buffer | null>} */ ({
|
257
277
|
tap: (options, fn) =>
|
258
278
|
hook.tap(options, loaderContext =>
|
259
|
-
fn(
|
279
|
+
fn(
|
280
|
+
loaderContext.resource,
|
281
|
+
/** @type {NormalModule} */ (loaderContext._module)
|
282
|
+
)
|
260
283
|
),
|
261
284
|
tapAsync: (options, fn) =>
|
262
285
|
hook.tapAsync(options, (loaderContext, callback) =>
|
263
|
-
fn(
|
286
|
+
fn(
|
287
|
+
loaderContext.resource,
|
288
|
+
/** @type {NormalModule} */ (loaderContext._module),
|
289
|
+
callback
|
290
|
+
)
|
264
291
|
),
|
265
292
|
tapPromise: (options, fn) =>
|
266
293
|
hook.tapPromise(options, loaderContext =>
|
267
|
-
fn(
|
294
|
+
fn(
|
295
|
+
loaderContext.resource,
|
296
|
+
/** @type {NormalModule} */ (loaderContext._module)
|
297
|
+
)
|
268
298
|
)
|
269
299
|
})
|
270
300
|
);
|
@@ -343,7 +373,7 @@ class NormalModule extends Module {
|
|
343
373
|
this._source = null;
|
344
374
|
/**
|
345
375
|
* @private
|
346
|
-
* @type {Map<string, number> | undefined}
|
376
|
+
* @type {Map<string | undefined, number> | undefined}
|
347
377
|
*/
|
348
378
|
this._sourceSizes = undefined;
|
349
379
|
/**
|
@@ -369,12 +399,10 @@ class NormalModule extends Module {
|
|
369
399
|
if (this.layer === null) {
|
370
400
|
if (this.type === JAVASCRIPT_MODULE_TYPE_AUTO) {
|
371
401
|
return this.request;
|
372
|
-
} else {
|
373
|
-
return `${this.type}|${this.request}`;
|
374
402
|
}
|
375
|
-
|
376
|
-
return `${this.type}|${this.request}|${this.layer}`;
|
403
|
+
return `${this.type}|${this.request}`;
|
377
404
|
}
|
405
|
+
return `${this.type}|${this.request}|${this.layer}`;
|
378
406
|
}
|
379
407
|
|
380
408
|
/**
|
@@ -382,7 +410,7 @@ class NormalModule extends Module {
|
|
382
410
|
* @returns {string} a user readable identifier of the module
|
383
411
|
*/
|
384
412
|
readableIdentifier(requestShortener) {
|
385
|
-
return requestShortener.shorten(this.userRequest);
|
413
|
+
return /** @type {string} */ (requestShortener.shorten(this.userRequest));
|
386
414
|
}
|
387
415
|
|
388
416
|
/**
|
@@ -556,30 +584,36 @@ class NormalModule extends Module {
|
|
556
584
|
/**
|
557
585
|
* @returns {ResolveContext} resolve context
|
558
586
|
*/
|
559
|
-
const getResolveContext = () => {
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
};
|
571
|
-
};
|
587
|
+
const getResolveContext = () => ({
|
588
|
+
fileDependencies: {
|
589
|
+
add: d => /** @type {TODO} */ (loaderContext).addDependency(d)
|
590
|
+
},
|
591
|
+
contextDependencies: {
|
592
|
+
add: d => /** @type {TODO} */ (loaderContext).addContextDependency(d)
|
593
|
+
},
|
594
|
+
missingDependencies: {
|
595
|
+
add: d => /** @type {TODO} */ (loaderContext).addMissingDependency(d)
|
596
|
+
}
|
597
|
+
});
|
572
598
|
const getAbsolutify = memoize(() =>
|
573
599
|
absolutify.bindCache(compilation.compiler.root)
|
574
600
|
);
|
575
601
|
const getAbsolutifyInContext = memoize(() =>
|
576
|
-
absolutify.bindContextCache(
|
602
|
+
absolutify.bindContextCache(
|
603
|
+
/** @type {string} */
|
604
|
+
(this.context),
|
605
|
+
compilation.compiler.root
|
606
|
+
)
|
577
607
|
);
|
578
608
|
const getContextify = memoize(() =>
|
579
609
|
contextify.bindCache(compilation.compiler.root)
|
580
610
|
);
|
581
611
|
const getContextifyInContext = memoize(() =>
|
582
|
-
contextify.bindContextCache(
|
612
|
+
contextify.bindContextCache(
|
613
|
+
/** @type {string} */
|
614
|
+
(this.context),
|
615
|
+
compilation.compiler.root
|
616
|
+
)
|
583
617
|
);
|
584
618
|
const utils = {
|
585
619
|
/**
|
@@ -587,28 +621,29 @@ class NormalModule extends Module {
|
|
587
621
|
* @param {string} request request
|
588
622
|
* @returns {string} result
|
589
623
|
*/
|
590
|
-
absolutify: (context, request) =>
|
591
|
-
|
624
|
+
absolutify: (context, request) =>
|
625
|
+
context === this.context
|
592
626
|
? getAbsolutifyInContext()(request)
|
593
|
-
: getAbsolutify()(context, request)
|
594
|
-
},
|
627
|
+
: getAbsolutify()(context, request),
|
595
628
|
/**
|
596
629
|
* @param {string} context context
|
597
630
|
* @param {string} request request
|
598
631
|
* @returns {string} result
|
599
632
|
*/
|
600
|
-
contextify: (context, request) =>
|
601
|
-
|
633
|
+
contextify: (context, request) =>
|
634
|
+
context === this.context
|
602
635
|
? getContextifyInContext()(request)
|
603
|
-
: getContextify()(context, request)
|
604
|
-
},
|
636
|
+
: getContextify()(context, request),
|
605
637
|
/**
|
606
638
|
* @param {(string | typeof import("./util/Hash"))=} type type
|
607
639
|
* @returns {Hash} hash
|
608
640
|
*/
|
609
|
-
createHash: type =>
|
610
|
-
|
611
|
-
|
641
|
+
createHash: type =>
|
642
|
+
createHash(
|
643
|
+
type ||
|
644
|
+
/** @type {Algorithm} */
|
645
|
+
(compilation.outputOptions.hashFunction)
|
646
|
+
)
|
612
647
|
};
|
613
648
|
/** @type {import("../declarations/LoaderContext").NormalModuleLoaderContext<T>} */
|
614
649
|
const loaderContext = {
|
@@ -622,8 +657,10 @@ class NormalModule extends Module {
|
|
622
657
|
if (options.startsWith("{") && options.endsWith("}")) {
|
623
658
|
try {
|
624
659
|
options = parseJson(options);
|
625
|
-
} catch (
|
626
|
-
throw new Error(
|
660
|
+
} catch (err) {
|
661
|
+
throw new Error(
|
662
|
+
`Cannot parse string options: ${/** @type {Error} */ (err).message}`
|
663
|
+
);
|
627
664
|
}
|
628
665
|
} else {
|
629
666
|
options = querystring.parse(options, "&", "=", {
|
@@ -738,17 +775,17 @@ class NormalModule extends Module {
|
|
738
775
|
utils,
|
739
776
|
rootContext: /** @type {string} */ (options.context),
|
740
777
|
webpack: true,
|
741
|
-
sourceMap:
|
778
|
+
sourceMap: Boolean(this.useSourceMap),
|
742
779
|
mode: options.mode || "production",
|
743
780
|
_module: this,
|
744
781
|
_compilation: compilation,
|
745
782
|
_compiler: compilation.compiler,
|
746
|
-
fs
|
783
|
+
fs
|
747
784
|
};
|
748
785
|
|
749
786
|
Object.assign(loaderContext, options.loader);
|
750
787
|
|
751
|
-
hooks.loader.call(loaderContext, this);
|
788
|
+
hooks.loader.call(/** @type {LoaderContext<any>} */ (loaderContext), this);
|
752
789
|
|
753
790
|
return loaderContext;
|
754
791
|
}
|
@@ -775,7 +812,7 @@ class NormalModule extends Module {
|
|
775
812
|
/**
|
776
813
|
* @param {string} context the compilation context
|
777
814
|
* @param {string | Buffer} content the content
|
778
|
-
* @param {(string | SourceMapSource)=} sourceMap an optional source map
|
815
|
+
* @param {(string | SourceMapSource | null)=} sourceMap an optional source map
|
779
816
|
* @param {object=} associatedObjectForCache object for caching
|
780
817
|
* @returns {Source} the created source
|
781
818
|
*/
|
@@ -832,7 +869,14 @@ class NormalModule extends Module {
|
|
832
869
|
hooks
|
833
870
|
);
|
834
871
|
|
835
|
-
|
872
|
+
/** @typedef {[string | Buffer, string | SourceMapSource, Record<string, any>]} Result */
|
873
|
+
|
874
|
+
/**
|
875
|
+
* @param {Error | null} err err
|
876
|
+
* @param {(Result | null)=} _result result
|
877
|
+
* @returns {void}
|
878
|
+
*/
|
879
|
+
const processResult = (err, _result) => {
|
836
880
|
if (err) {
|
837
881
|
if (!(err instanceof Error)) {
|
838
882
|
err = new NonErrorEmittedError(err);
|
@@ -848,6 +892,7 @@ class NormalModule extends Module {
|
|
848
892
|
return callback(error);
|
849
893
|
}
|
850
894
|
|
895
|
+
const result = /** @type {Result} */ (_result);
|
851
896
|
const source = result[0];
|
852
897
|
const sourceMap = result.length >= 1 ? result[1] : null;
|
853
898
|
const extraInfo = result.length >= 2 ? result[2] : null;
|
@@ -867,9 +912,14 @@ class NormalModule extends Module {
|
|
867
912
|
return callback(error);
|
868
913
|
}
|
869
914
|
|
915
|
+
const isBinaryModule =
|
916
|
+
this.generatorOptions && this.generatorOptions.binary !== undefined
|
917
|
+
? this.generatorOptions.binary
|
918
|
+
: this.binary;
|
919
|
+
|
870
920
|
this._source = this.createSource(
|
871
921
|
/** @type {string} */ (options.context),
|
872
|
-
|
922
|
+
isBinaryModule ? asBuffer(source) : asString(source),
|
873
923
|
sourceMap,
|
874
924
|
compilation.compiler.root
|
875
925
|
);
|
@@ -891,7 +941,11 @@ class NormalModule extends Module {
|
|
891
941
|
buildInfo.cacheable = true;
|
892
942
|
|
893
943
|
try {
|
894
|
-
hooks.beforeLoaders.call(
|
944
|
+
hooks.beforeLoaders.call(
|
945
|
+
this.loaders,
|
946
|
+
this,
|
947
|
+
/** @type {LoaderContext<any>} */ (loaderContext)
|
948
|
+
);
|
895
949
|
} catch (err) {
|
896
950
|
processResult(err);
|
897
951
|
return;
|
@@ -915,7 +969,13 @@ class NormalModule extends Module {
|
|
915
969
|
.callAsync(loaderContext, (err, result) => {
|
916
970
|
if (err) return callback(err);
|
917
971
|
if (typeof result !== "string" && !result) {
|
918
|
-
return callback(
|
972
|
+
return callback(
|
973
|
+
new UnhandledSchemeError(
|
974
|
+
/** @type {string} */
|
975
|
+
(scheme),
|
976
|
+
resource
|
977
|
+
)
|
978
|
+
);
|
919
979
|
}
|
920
980
|
return callback(null, result);
|
921
981
|
});
|
@@ -1032,7 +1092,10 @@ class NormalModule extends Module {
|
|
1032
1092
|
* @private
|
1033
1093
|
*/
|
1034
1094
|
_initBuildHash(compilation) {
|
1035
|
-
const hash = createHash(
|
1095
|
+
const hash = createHash(
|
1096
|
+
/** @type {Algorithm} */
|
1097
|
+
(compilation.outputOptions.hashFunction)
|
1098
|
+
);
|
1036
1099
|
if (this._source) {
|
1037
1100
|
hash.update("source");
|
1038
1101
|
this._source.updateHash(hash);
|
@@ -1123,7 +1186,7 @@ class NormalModule extends Module {
|
|
1123
1186
|
try {
|
1124
1187
|
hooks.beforeSnapshot.call(this);
|
1125
1188
|
} catch (err) {
|
1126
|
-
this.markModuleAsErrored(err);
|
1189
|
+
this.markModuleAsErrored(/** @type {WebpackError} */ (err));
|
1127
1190
|
return callback();
|
1128
1191
|
}
|
1129
1192
|
|
@@ -1135,7 +1198,7 @@ class NormalModule extends Module {
|
|
1135
1198
|
// add warning for all non-absolute paths in fileDependencies, etc
|
1136
1199
|
// This makes it easier to find problems with watching and/or caching
|
1137
1200
|
/** @type {undefined | Set<string>} */
|
1138
|
-
let nonAbsoluteDependencies
|
1201
|
+
let nonAbsoluteDependencies;
|
1139
1202
|
/**
|
1140
1203
|
* @param {LazySet<string>} deps deps
|
1141
1204
|
*/
|
@@ -1150,7 +1213,8 @@ class NormalModule extends Module {
|
|
1150
1213
|
const depWithoutGlob = dep.replace(/[\\/]?\*.*$/, "");
|
1151
1214
|
const absolute = join(
|
1152
1215
|
compilation.fileSystemInfo.fs,
|
1153
|
-
|
1216
|
+
/** @type {string} */
|
1217
|
+
(this.context),
|
1154
1218
|
depWithoutGlob
|
1155
1219
|
);
|
1156
1220
|
if (absolute !== dep && ABSOLUTE_PATH_REGEX.test(absolute)) {
|
@@ -1163,7 +1227,7 @@ class NormalModule extends Module {
|
|
1163
1227
|
: deps
|
1164
1228
|
).add(absolute);
|
1165
1229
|
}
|
1166
|
-
} catch (
|
1230
|
+
} catch (_err) {
|
1167
1231
|
// ignore
|
1168
1232
|
}
|
1169
1233
|
}
|
@@ -1213,7 +1277,7 @@ class NormalModule extends Module {
|
|
1213
1277
|
try {
|
1214
1278
|
hooks.beforeParse.call(this);
|
1215
1279
|
} catch (err) {
|
1216
|
-
this.markModuleAsErrored(err);
|
1280
|
+
this.markModuleAsErrored(/** @type {WebpackError} */ (err));
|
1217
1281
|
this._initBuildHash(compilation);
|
1218
1282
|
return callback();
|
1219
1283
|
}
|
@@ -1236,11 +1300,11 @@ class NormalModule extends Module {
|
|
1236
1300
|
source,
|
1237
1301
|
current: this,
|
1238
1302
|
module: this,
|
1239
|
-
compilation
|
1240
|
-
options
|
1303
|
+
compilation,
|
1304
|
+
options
|
1241
1305
|
});
|
1242
|
-
} catch (
|
1243
|
-
handleParseError(/** @type {Error} */ (
|
1306
|
+
} catch (parseErr) {
|
1307
|
+
handleParseError(/** @type {Error} */ (parseErr));
|
1244
1308
|
return;
|
1245
1309
|
}
|
1246
1310
|
handleParseResult();
|
@@ -1300,9 +1364,8 @@ class NormalModule extends Module {
|
|
1300
1364
|
// When caching is implemented here, make sure to not cache when
|
1301
1365
|
// at least one circular connection was in the loop above
|
1302
1366
|
return current;
|
1303
|
-
} else {
|
1304
|
-
return true;
|
1305
1367
|
}
|
1368
|
+
return true;
|
1306
1369
|
}
|
1307
1370
|
|
1308
1371
|
/**
|
@@ -1343,15 +1406,13 @@ class NormalModule extends Module {
|
|
1343
1406
|
}
|
1344
1407
|
|
1345
1408
|
/** @type {function(): Map<string, any>} */
|
1346
|
-
const getData = () =>
|
1347
|
-
return this._codeGeneratorData;
|
1348
|
-
};
|
1409
|
+
const getData = () => this._codeGeneratorData;
|
1349
1410
|
|
1350
1411
|
const sources = new Map();
|
1351
1412
|
for (const type of sourceTypes || chunkGraph.getModuleSourceTypes(this)) {
|
1352
1413
|
const source = this.error
|
1353
1414
|
? new RawSource(
|
1354
|
-
|
1415
|
+
`throw new Error(${JSON.stringify(this.error.message)});`
|
1355
1416
|
)
|
1356
1417
|
: /** @type {Generator} */ (this.generator).generate(this, {
|
1357
1418
|
dependencyTemplates,
|
@@ -1448,7 +1509,7 @@ class NormalModule extends Module {
|
|
1448
1509
|
)
|
1449
1510
|
);
|
1450
1511
|
}
|
1451
|
-
callback(null,
|
1512
|
+
callback(null, Boolean(needBuild));
|
1452
1513
|
});
|
1453
1514
|
});
|
1454
1515
|
}
|
@@ -1514,7 +1575,8 @@ class NormalModule extends Module {
|
|
1514
1575
|
*/
|
1515
1576
|
updateHash(hash, context) {
|
1516
1577
|
hash.update(/** @type {BuildInfo} */ (this.buildInfo).hash);
|
1517
|
-
|
1578
|
+
/** @type {Generator} */
|
1579
|
+
(this.generator).updateHash(hash, {
|
1518
1580
|
module: this,
|
1519
1581
|
...context
|
1520
1582
|
});
|