webpack 5.101.2 → 5.102.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 +21 -26
- package/lib/APIPlugin.js +30 -36
- package/lib/AsyncDependenciesBlock.js +1 -4
- package/lib/BannerPlugin.js +0 -1
- package/lib/Cache.js +7 -6
- package/lib/CacheFacade.js +0 -1
- package/lib/Chunk.js +49 -31
- package/lib/ChunkGraph.js +35 -25
- package/lib/ChunkGroup.js +8 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +3 -3
- package/lib/CodeGenerationResults.js +2 -1
- package/lib/CompatibilityPlugin.js +29 -12
- package/lib/Compilation.js +204 -185
- package/lib/Compiler.js +36 -35
- package/lib/ConcatenationScope.js +6 -1
- package/lib/ConditionalInitFragment.js +1 -1
- package/lib/ConstPlugin.js +18 -10
- package/lib/ContextExclusionPlugin.js +0 -1
- package/lib/ContextModule.js +22 -20
- package/lib/ContextModuleFactory.js +30 -11
- package/lib/ContextReplacementPlugin.js +38 -15
- package/lib/DefinePlugin.js +18 -8
- package/lib/DelegatedModule.js +7 -11
- package/lib/DependenciesBlock.js +0 -2
- package/lib/Dependency.js +9 -11
- package/lib/DependencyTemplates.js +1 -3
- package/lib/DllModule.js +1 -7
- package/lib/DllReferencePlugin.js +2 -4
- package/lib/DynamicEntryPlugin.js +0 -2
- package/lib/EntryOptionPlugin.js +0 -5
- package/lib/EnvironmentNotSupportAsyncWarning.js +0 -3
- package/lib/EvalDevToolModulePlugin.js +4 -3
- package/lib/EvalSourceMapDevToolPlugin.js +3 -4
- package/lib/ExportsInfo.js +50 -49
- package/lib/ExternalModule.js +84 -52
- package/lib/ExternalModuleFactoryPlugin.js +27 -7
- package/lib/ExternalsPlugin.js +24 -17
- package/lib/FileSystemInfo.js +96 -78
- package/lib/FlagDependencyUsagePlugin.js +3 -4
- package/lib/Generator.js +2 -13
- package/lib/GraphHelpers.js +0 -3
- package/lib/HookWebpackError.js +0 -2
- package/lib/HotModuleReplacementPlugin.js +22 -24
- package/lib/HotUpdateChunk.js +0 -3
- package/lib/IgnorePlugin.js +5 -2
- package/lib/InitFragment.js +41 -29
- package/lib/InvalidDependenciesModuleWarning.js +0 -1
- package/lib/LibManifestPlugin.js +4 -6
- package/lib/LoaderOptionsPlugin.js +1 -10
- package/lib/MainTemplate.js +8 -19
- package/lib/Module.js +32 -20
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleFilenameHelpers.js +41 -24
- package/lib/ModuleGraph.js +30 -16
- package/lib/ModuleInfoHeaderPlugin.js +0 -1
- package/lib/ModuleTemplate.js +0 -2
- package/lib/ModuleTypeConstants.js +11 -1
- package/lib/MultiCompiler.js +23 -15
- package/lib/MultiWatching.js +6 -10
- package/lib/NodeStuffPlugin.js +2 -10
- package/lib/NormalModule.js +145 -88
- package/lib/NormalModuleFactory.js +59 -40
- package/lib/OptionsApply.js +1 -1
- package/lib/Parser.js +1 -1
- package/lib/ProgressPlugin.js +6 -10
- package/lib/ProvidePlugin.js +5 -7
- package/lib/RawModule.js +1 -6
- package/lib/RecordIdsPlugin.js +10 -6
- package/lib/ResolverFactory.js +0 -2
- package/lib/RuntimeGlobals.js +5 -0
- package/lib/RuntimeModule.js +1 -3
- package/lib/RuntimePlugin.js +26 -22
- package/lib/RuntimeTemplate.js +12 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +6 -11
- package/lib/Stats.js +0 -1
- package/lib/Template.js +6 -11
- package/lib/TemplatedPathPlugin.js +2 -1
- package/lib/WatchIgnorePlugin.js +2 -3
- package/lib/Watching.js +15 -15
- package/lib/WebpackIsIncludedPlugin.js +0 -2
- package/lib/WebpackOptionsApply.js +74 -107
- package/lib/asset/AssetBytesGenerator.js +166 -0
- package/lib/asset/AssetBytesParser.js +37 -0
- package/lib/asset/AssetGenerator.js +20 -34
- package/lib/asset/AssetModulesPlugin.js +34 -16
- package/lib/asset/AssetParser.js +7 -3
- package/lib/asset/AssetSourceGenerator.js +1 -1
- package/lib/asset/RawDataUrlModule.js +3 -2
- package/lib/async-modules/AsyncModuleHelpers.js +6 -4
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -1
- package/lib/buildChunkGraph.js +0 -1
- package/lib/cache/MemoryCachePlugin.js +0 -2
- package/lib/cache/MemoryWithGcCachePlugin.js +0 -2
- package/lib/cache/PackFileCacheStrategy.js +14 -1
- package/lib/cache/ResolverCachePlugin.js +9 -15
- package/lib/config/defaults.js +155 -21
- package/lib/config/normalization.js +18 -3
- package/lib/container/ContainerEntryDependency.js +0 -1
- package/lib/container/ContainerEntryModule.js +3 -7
- package/lib/container/ContainerPlugin.js +1 -2
- package/lib/container/ContainerReferencePlugin.js +0 -1
- package/lib/container/FallbackDependency.js +2 -1
- package/lib/container/FallbackModule.js +6 -7
- package/lib/container/ModuleFederationPlugin.js +0 -1
- package/lib/container/RemoteModule.js +8 -8
- package/lib/container/RemoteRuntimeModule.js +2 -2
- package/lib/css/CssGenerator.js +3 -6
- package/lib/css/CssLoadingRuntimeModule.js +6 -9
- package/lib/css/CssModulesPlugin.js +11 -13
- package/lib/css/CssParser.js +3 -3
- package/lib/css/walkCssTokens.js +1 -1
- package/lib/debug/ProfilingPlugin.js +35 -8
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +12 -17
- package/lib/dependencies/AMDPlugin.js +2 -2
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/CachedConstDependency.js +0 -4
- package/lib/dependencies/CommonJsExportRequireDependency.js +20 -14
- package/lib/dependencies/CommonJsExportsDependency.js +2 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +20 -5
- package/lib/dependencies/CommonJsFullRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsImportsParserPlugin.js +16 -7
- package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +4 -4
- package/lib/dependencies/ConstDependency.js +2 -2
- package/lib/dependencies/ContextDependency.js +9 -4
- package/lib/dependencies/ContextDependencyHelpers.js +2 -2
- package/lib/dependencies/ContextDependencyTemplateAsId.js +9 -9
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +9 -9
- package/lib/dependencies/ContextElementDependency.js +22 -11
- package/lib/dependencies/CssIcssImportDependency.js +0 -2
- package/lib/dependencies/CssIcssSymbolDependency.js +2 -2
- package/lib/dependencies/CssImportDependency.js +0 -8
- package/lib/dependencies/CssLocalIdentifierDependency.js +3 -4
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssUrlDependency.js +0 -6
- package/lib/dependencies/ExportsInfoDependency.js +7 -9
- package/lib/dependencies/ExternalModuleDependency.js +0 -3
- package/lib/dependencies/ExternalModuleInitFragment.js +1 -1
- package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +0 -4
- package/lib/dependencies/HarmonyCompatibilityDependency.js +0 -1
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +0 -14
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +3 -3
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +4 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +29 -35
- package/lib/dependencies/HarmonyImportDependency.js +30 -14
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +38 -24
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
- package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
- package/lib/dependencies/ImportDependency.js +18 -6
- package/lib/dependencies/ImportEagerDependency.js +2 -3
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +8 -5
- package/lib/dependencies/ImportMetaContextPlugin.js +0 -1
- package/lib/dependencies/ImportMetaPlugin.js +8 -1
- package/lib/dependencies/ImportParserPlugin.js +294 -45
- package/lib/dependencies/ImportWeakDependency.js +2 -3
- package/lib/dependencies/JsonExportsDependency.js +0 -1
- package/lib/dependencies/LoaderDependency.js +0 -3
- package/lib/dependencies/LoaderImportDependency.js +0 -3
- package/lib/dependencies/LoaderPlugin.js +11 -5
- package/lib/dependencies/ModuleDecoratorDependency.js +2 -4
- package/lib/dependencies/ModuleDependency.js +3 -9
- package/lib/dependencies/NullDependency.js +2 -0
- package/lib/dependencies/ProvidedDependency.js +6 -8
- package/lib/dependencies/PureExpressionDependency.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +0 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -2
- package/lib/dependencies/RequireIncludeDependency.js +2 -2
- package/lib/dependencies/RequireResolveDependency.js +2 -2
- package/lib/dependencies/RuntimeRequirementsDependency.js +2 -3
- package/lib/dependencies/StaticExportsDependency.js +3 -5
- package/lib/dependencies/URLDependency.js +2 -7
- package/lib/dependencies/URLPlugin.js +1 -2
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +2 -2
- package/lib/dependencies/WebAssemblyImportDependency.js +2 -2
- package/lib/dependencies/WebpackIsIncludedDependency.js +2 -3
- package/lib/dependencies/WorkerDependency.js +2 -3
- package/lib/dependencies/WorkerPlugin.js +3 -9
- package/lib/dependencies/processExportInfo.js +2 -3
- package/lib/esm/ModuleChunkFormatPlugin.js +0 -3
- package/lib/esm/ModuleChunkLoadingPlugin.js +2 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +7 -7
- package/lib/hmr/LazyCompilationPlugin.js +6 -4
- package/lib/hmr/lazyCompilationBackend.js +13 -10
- package/lib/ids/DeterministicChunkIdsPlugin.js +0 -1
- package/lib/ids/NamedChunkIdsPlugin.js +1 -6
- package/lib/ids/NamedModuleIdsPlugin.js +1 -5
- package/lib/ids/NaturalChunkIdsPlugin.js +0 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +0 -1
- package/lib/ids/OccurrenceModuleIdsPlugin.js +0 -1
- package/lib/ids/SyncModuleIdsPlugin.js +4 -3
- package/lib/index.js +8 -7
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -1
- package/lib/javascript/BasicEvaluatedExpression.js +13 -6
- package/lib/javascript/ChunkFormatHelpers.js +1 -1
- package/lib/javascript/CommonJsChunkFormatPlugin.js +0 -1
- package/lib/javascript/JavascriptGenerator.js +2 -3
- package/lib/javascript/JavascriptModulesPlugin.js +44 -21
- package/lib/javascript/JavascriptParser.js +159 -93
- package/lib/javascript/JavascriptParserHelpers.js +2 -2
- package/lib/javascript/StartupHelpers.js +2 -4
- package/lib/json/JsonData.js +1 -1
- package/lib/json/JsonGenerator.js +4 -5
- package/lib/json/JsonModulesPlugin.js +0 -3
- package/lib/json/JsonParser.js +4 -2
- package/lib/library/AbstractLibraryPlugin.js +2 -2
- package/lib/library/AmdLibraryPlugin.js +0 -1
- package/lib/library/AssignLibraryPlugin.js +23 -12
- package/lib/library/EnableLibraryPlugin.js +7 -11
- package/lib/library/ExportPropertyLibraryPlugin.js +8 -20
- package/lib/library/JsonpLibraryPlugin.js +5 -2
- package/lib/library/ModuleLibraryPlugin.js +88 -43
- package/lib/library/SystemLibraryPlugin.js +0 -1
- package/lib/library/UmdLibraryPlugin.js +12 -18
- package/lib/logging/Logger.js +12 -10
- package/lib/logging/createConsoleLogger.js +15 -14
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/CommonJsChunkLoadingPlugin.js +2 -1
- package/lib/node/NodeWatchFileSystem.js +4 -4
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +2 -2
- package/lib/node/RequireChunkLoadingRuntimeModule.js +5 -2
- package/lib/node/nodeConsole.js +2 -2
- package/lib/optimize/AggressiveSplittingPlugin.js +2 -0
- package/lib/optimize/ConcatenatedModule.js +142 -100
- package/lib/optimize/InnerGraph.js +17 -11
- package/lib/optimize/InnerGraphPlugin.js +0 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +3 -4
- package/lib/optimize/RuntimeChunkPlugin.js +0 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -10
- package/lib/optimize/SplitChunksPlugin.js +46 -40
- package/lib/performance/SizeLimitsPlugin.js +2 -1
- package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +5 -7
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +0 -2
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +0 -1
- package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +2 -2
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +2 -2
- package/lib/rules/BasicMatcherRulePlugin.js +0 -2
- package/lib/rules/ObjectMatcherRulePlugin.js +0 -1
- package/lib/rules/RuleSetCompiler.js +8 -6
- package/lib/runtime/BaseUriRuntimeModule.js +2 -2
- package/lib/runtime/CompatRuntimeModule.js +0 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +8 -9
- package/lib/runtime/LoadScriptRuntimeModule.js +0 -2
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +1 -1
- package/lib/runtime/PublicPathRuntimeModule.js +2 -2
- package/lib/runtime/StartupEntrypointRuntimeModule.js +0 -1
- package/lib/runtime/SystemContextRuntimeModule.js +0 -2
- package/lib/runtime/ToBinaryRuntimeModule.js +64 -0
- package/lib/schemes/DataUriPlugin.js +2 -28
- package/lib/schemes/FileUriPlugin.js +5 -2
- package/lib/schemes/HttpUriPlugin.js +4 -2
- package/lib/schemes/VirtualUrlPlugin.js +11 -11
- package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
- package/lib/serialization/ObjectMiddleware.js +30 -19
- package/lib/serialization/SerializerMiddleware.js +1 -3
- package/lib/serialization/types.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +3 -5
- package/lib/sharing/ConsumeSharedPlugin.js +2 -4
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -6
- package/lib/sharing/ProvideSharedModule.js +3 -7
- package/lib/sharing/SharePlugin.js +0 -2
- package/lib/sharing/ShareRuntimeModule.js +4 -1
- package/lib/sharing/resolveMatchedConfigs.js +14 -6
- package/lib/sharing/utils.js +0 -6
- package/lib/stats/DefaultStatsFactoryPlugin.js +178 -94
- package/lib/stats/DefaultStatsPresetPlugin.js +15 -9
- package/lib/stats/DefaultStatsPrinterPlugin.js +77 -113
- package/lib/stats/StatsFactory.js +14 -11
- package/lib/url/URLParserPlugin.js +2 -4
- package/lib/util/ArrayHelpers.js +4 -4
- package/lib/util/AsyncQueue.js +1 -0
- package/lib/util/LazySet.js +2 -2
- package/lib/util/StackedCacheMap.js +0 -2
- package/lib/util/TupleSet.js +9 -4
- package/lib/util/URLAbsoluteSpecifier.js +0 -1
- package/lib/util/WeakTupleMap.js +1 -1
- package/lib/util/chainedImports.js +3 -1
- package/lib/util/cleverMerge.js +15 -18
- package/lib/util/comparators.js +2 -4
- package/lib/util/compileBooleanMatcher.js +11 -9
- package/lib/util/concatenate.js +1 -2
- package/lib/util/create-schema-validation.js +0 -1
- package/lib/util/dataURL.js +39 -0
- package/lib/util/deprecation.js +29 -31
- package/lib/util/deterministicGrouping.js +34 -30
- package/lib/util/extractSourceMap.js +319 -0
- package/lib/util/findGraphRoots.js +15 -5
- package/lib/util/fs.js +29 -8
- package/lib/util/semver.js +9 -8
- package/lib/util/smartGrouping.js +41 -26
- package/lib/util/traverseDestructuringAssignmentProperties.js +45 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +3 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +5 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -13
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +2 -9
- package/lib/wasm-async/AsyncWebAssemblyParser.js +2 -1
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +6 -4
- package/lib/wasm-sync/WebAssemblyGenerator.js +1 -3
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -4
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +2 -7
- package/lib/wasm-sync/WebAssemblyParser.js +1 -4
- package/lib/web/JsonpChunkLoadingPlugin.js +2 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +1 -1
- package/lib/web/JsonpTemplatePlugin.js +0 -1
- package/lib/webpack.js +21 -8
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +2 -1
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
- package/package.json +13 -13
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +77 -93
- package/schemas/plugins/BannerPlugin.check.js +1 -1
- package/schemas/plugins/BannerPlugin.json +4 -0
- package/schemas/plugins/IgnorePlugin.json +1 -1
- package/schemas/plugins/ProgressPlugin.json +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +5 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +1140 -505
- package/SECURITY.md +0 -9
|
@@ -10,6 +10,8 @@ const { join } = require("./util/fs");
|
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("./Compiler")} Compiler */
|
|
12
12
|
/** @typedef {import("./ContextModule").ContextModuleOptions} ContextModuleOptions */
|
|
13
|
+
/** @typedef {import("./ContextModuleFactory").BeforeContextResolveData} BeforeContextResolveData */
|
|
14
|
+
/** @typedef {import("./ContextModuleFactory").AfterContextResolveData} AfterContextResolveData */
|
|
13
15
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
|
14
16
|
|
|
15
17
|
/** @typedef {Record<string, string>} NewContentCreateContextMap */
|
|
@@ -19,7 +21,7 @@ const PLUGIN_NAME = "ContextReplacementPlugin";
|
|
|
19
21
|
class ContextReplacementPlugin {
|
|
20
22
|
/**
|
|
21
23
|
* @param {RegExp} resourceRegExp A regular expression that determines which files will be selected
|
|
22
|
-
* @param {(string | ((context:
|
|
24
|
+
* @param {(string | ((context: BeforeContextResolveData | AfterContextResolveData) => void) | RegExp | boolean)=} newContentResource A new resource to replace the match
|
|
23
25
|
* @param {(boolean | NewContentCreateContextMap | RegExp)=} newContentRecursive If true, all subdirectories are searched for matches
|
|
24
26
|
* @param {RegExp=} newContentRegExp A regular expression that determines which files will be selected
|
|
25
27
|
*/
|
|
@@ -122,7 +124,14 @@ class ContextReplacementPlugin {
|
|
|
122
124
|
});
|
|
123
125
|
cmf.hooks.afterResolve.tap(PLUGIN_NAME, (result) => {
|
|
124
126
|
if (!result) return;
|
|
125
|
-
|
|
127
|
+
const isMatchResourceRegExp = () => {
|
|
128
|
+
if (Array.isArray(result.resource)) {
|
|
129
|
+
return result.resource.some((item) => resourceRegExp.test(item));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return resourceRegExp.test(result.resource);
|
|
133
|
+
};
|
|
134
|
+
if (isMatchResourceRegExp()) {
|
|
126
135
|
if (newContentResource !== undefined) {
|
|
127
136
|
if (
|
|
128
137
|
newContentResource.startsWith("/") ||
|
|
@@ -130,10 +139,15 @@ class ContextReplacementPlugin {
|
|
|
130
139
|
) {
|
|
131
140
|
result.resource = newContentResource;
|
|
132
141
|
} else {
|
|
142
|
+
const rootPath =
|
|
143
|
+
typeof result.resource === "string"
|
|
144
|
+
? result.resource
|
|
145
|
+
: /** @type {string} */
|
|
146
|
+
(result.resource.find((item) => resourceRegExp.test(item)));
|
|
133
147
|
result.resource = join(
|
|
134
148
|
/** @type {InputFileSystem} */
|
|
135
149
|
(compiler.inputFileSystem),
|
|
136
|
-
|
|
150
|
+
rootPath,
|
|
137
151
|
newContentResource
|
|
138
152
|
);
|
|
139
153
|
}
|
|
@@ -153,18 +167,27 @@ class ContextReplacementPlugin {
|
|
|
153
167
|
if (typeof newContentCallback === "function") {
|
|
154
168
|
const origResource = result.resource;
|
|
155
169
|
newContentCallback(result);
|
|
156
|
-
if (
|
|
157
|
-
result.resource
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
170
|
+
if (result.resource !== origResource) {
|
|
171
|
+
const newResource = Array.isArray(result.resource)
|
|
172
|
+
? result.resource
|
|
173
|
+
: [result.resource];
|
|
174
|
+
|
|
175
|
+
for (let i = 0; i < newResource.length; i++) {
|
|
176
|
+
if (
|
|
177
|
+
!newResource[i].startsWith("/") &&
|
|
178
|
+
(newResource[i].length <= 1 || newResource[i][1] !== ":")
|
|
179
|
+
) {
|
|
180
|
+
// When the function changed it to an relative path
|
|
181
|
+
newResource[i] = join(
|
|
182
|
+
/** @type {InputFileSystem} */
|
|
183
|
+
(compiler.inputFileSystem),
|
|
184
|
+
origResource[i],
|
|
185
|
+
newResource[i]
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
result.resource = newResource;
|
|
168
191
|
}
|
|
169
192
|
} else {
|
|
170
193
|
for (const d of result.dependencies) {
|
package/lib/DefinePlugin.js
CHANGED
|
@@ -22,14 +22,14 @@ const {
|
|
|
22
22
|
const createHash = require("./util/createHash");
|
|
23
23
|
|
|
24
24
|
/** @typedef {import("estree").Expression} Expression */
|
|
25
|
-
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
|
26
25
|
/** @typedef {import("./Compiler")} Compiler */
|
|
27
26
|
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
|
27
|
+
/** @typedef {import("./Module").ValueCacheVersion} ValueCacheVersion */
|
|
28
28
|
/** @typedef {import("./Module").ValueCacheVersions} ValueCacheVersions */
|
|
29
29
|
/** @typedef {import("./NormalModule")} NormalModule */
|
|
30
30
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
|
31
31
|
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
|
32
|
-
/** @typedef {import("./javascript/JavascriptParser").
|
|
32
|
+
/** @typedef {import("./javascript/JavascriptParser").DestructuringAssignmentProperties} DestructuringAssignmentProperties */
|
|
33
33
|
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
|
|
34
34
|
/** @typedef {import("./logging/Logger").Logger} Logger */
|
|
35
35
|
|
|
@@ -45,7 +45,6 @@ const createHash = require("./util/createHash");
|
|
|
45
45
|
* @property {string| (() => string)=} version
|
|
46
46
|
*/
|
|
47
47
|
|
|
48
|
-
/** @typedef {string | Set<string>} ValueCacheVersion */
|
|
49
48
|
/** @typedef {(value: { module: NormalModule, key: string, readonly version: ValueCacheVersion }) => CodeValuePrimitive} GeneratorFn */
|
|
50
49
|
|
|
51
50
|
class RuntimeValue {
|
|
@@ -125,7 +124,7 @@ class RuntimeValue {
|
|
|
125
124
|
}
|
|
126
125
|
|
|
127
126
|
/**
|
|
128
|
-
* @param {
|
|
127
|
+
* @param {DestructuringAssignmentProperties | undefined} properties properties
|
|
129
128
|
* @returns {Set<string> | undefined} used keys
|
|
130
129
|
*/
|
|
131
130
|
function getObjKeys(properties) {
|
|
@@ -376,10 +375,7 @@ class DefinePlugin {
|
|
|
376
375
|
);
|
|
377
376
|
const { runtimeTemplate } = compilation;
|
|
378
377
|
|
|
379
|
-
const mainHash = createHash(
|
|
380
|
-
/** @type {HashFunction} */
|
|
381
|
-
(compilation.outputOptions.hashFunction)
|
|
382
|
-
);
|
|
378
|
+
const mainHash = createHash(compilation.outputOptions.hashFunction);
|
|
383
379
|
mainHash.update(
|
|
384
380
|
/** @type {string} */
|
|
385
381
|
(compilation.valueCacheVersions.get(VALUE_DEP_MAIN)) || ""
|
|
@@ -489,6 +485,13 @@ class DefinePlugin {
|
|
|
489
485
|
if (nested && !hooked.has(nested)) {
|
|
490
486
|
// only detect the same nested key once
|
|
491
487
|
hooked.add(nested);
|
|
488
|
+
parser.hooks.collectDestructuringAssignmentProperties.tap(
|
|
489
|
+
PLUGIN_NAME,
|
|
490
|
+
(expr) => {
|
|
491
|
+
const nameInfo = parser.getNameForExpression(expr);
|
|
492
|
+
if (nameInfo && nameInfo.name === nested) return true;
|
|
493
|
+
}
|
|
494
|
+
);
|
|
492
495
|
parser.hooks.expression.for(nested).tap(
|
|
493
496
|
{
|
|
494
497
|
name: PLUGIN_NAME,
|
|
@@ -687,6 +690,13 @@ class DefinePlugin {
|
|
|
687
690
|
PLUGIN_NAME,
|
|
688
691
|
withValueDependency(key, evaluateToString("object"))
|
|
689
692
|
);
|
|
693
|
+
parser.hooks.collectDestructuringAssignmentProperties.tap(
|
|
694
|
+
PLUGIN_NAME,
|
|
695
|
+
(expr) => {
|
|
696
|
+
const nameInfo = parser.getNameForExpression(expr);
|
|
697
|
+
if (nameInfo && nameInfo.name === key) return true;
|
|
698
|
+
}
|
|
699
|
+
);
|
|
690
700
|
parser.hooks.expression.for(key).tap(PLUGIN_NAME, (expr) => {
|
|
691
701
|
addValueDependency(key);
|
|
692
702
|
let strCode = stringifyObj(
|
package/lib/DelegatedModule.js
CHANGED
|
@@ -14,30 +14,26 @@ const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDepende
|
|
|
14
14
|
const StaticExportsDependency = require("./dependencies/StaticExportsDependency");
|
|
15
15
|
const makeSerializable = require("./util/makeSerializable");
|
|
16
16
|
|
|
17
|
-
/** @typedef {import("webpack-sources").Source} Source */
|
|
18
|
-
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
|
19
17
|
/** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */
|
|
20
|
-
/** @typedef {import("./
|
|
18
|
+
/** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
21
19
|
/** @typedef {import("./Compilation")} Compilation */
|
|
22
20
|
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
|
23
|
-
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
|
24
21
|
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
|
|
25
22
|
/** @typedef {import("./LibManifestPlugin").ManifestModuleData} ManifestModuleData */
|
|
23
|
+
/** @typedef {import("./Module").ModuleId} ModuleId */
|
|
26
24
|
/** @typedef {import("./Module").BuildCallback} BuildCallback */
|
|
27
25
|
/** @typedef {import("./Module").BuildMeta} BuildMeta */
|
|
28
26
|
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
|
|
29
27
|
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
|
30
28
|
/** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
|
|
29
|
+
/** @typedef {import("./Module").LibIdent} LibIdent */
|
|
31
30
|
/** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */
|
|
32
31
|
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
|
|
33
|
-
/** @typedef {import("./Module").SourceContext} SourceContext */
|
|
34
32
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
|
35
33
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
36
|
-
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
|
37
|
-
/** @typedef {import("./WebpackError")} WebpackError */
|
|
38
|
-
/** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
|
|
39
34
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
40
35
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
36
|
+
/** @typedef {import("./dependencies/StaticExportsDependency").Exports} Exports */
|
|
41
37
|
/** @typedef {import("./util/Hash")} Hash */
|
|
42
38
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
|
43
39
|
|
|
@@ -48,8 +44,8 @@ const makeSerializable = require("./util/makeSerializable");
|
|
|
48
44
|
/**
|
|
49
45
|
* @typedef {object} DelegatedModuleData
|
|
50
46
|
* @property {BuildMeta=} buildMeta build meta
|
|
51
|
-
* @property {
|
|
52
|
-
* @property {
|
|
47
|
+
* @property {Exports=} exports exports
|
|
48
|
+
* @property {ModuleId} id module id
|
|
53
49
|
*/
|
|
54
50
|
|
|
55
51
|
const RUNTIME_REQUIREMENTS = new Set([
|
|
@@ -89,7 +85,7 @@ class DelegatedModule extends Module {
|
|
|
89
85
|
|
|
90
86
|
/**
|
|
91
87
|
* @param {LibIdentOptions} options options
|
|
92
|
-
* @returns {
|
|
88
|
+
* @returns {LibIdent | null} an identifier for library inclusion
|
|
93
89
|
*/
|
|
94
90
|
libIdent(options) {
|
|
95
91
|
return typeof this.originalRequest === "string"
|
package/lib/DependenciesBlock.js
CHANGED
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
const makeSerializable = require("./util/makeSerializable");
|
|
9
9
|
|
|
10
10
|
/** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */
|
|
11
|
-
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
|
12
|
-
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
|
13
11
|
/** @typedef {import("./Dependency")} Dependency */
|
|
14
12
|
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
|
15
13
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
package/lib/Dependency.js
CHANGED
|
@@ -7,10 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
const memoize = require("./util/memoize");
|
|
9
9
|
|
|
10
|
-
/** @typedef {import("webpack-sources").Source} Source */
|
|
11
10
|
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
|
12
11
|
/** @typedef {import("./DependenciesBlock")} DependenciesBlock */
|
|
13
|
-
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
|
14
12
|
/** @typedef {import("./Module")} Module */
|
|
15
13
|
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
|
16
14
|
/** @typedef {import("./ModuleGraphConnection")} ModuleGraphConnection */
|
|
@@ -62,10 +60,12 @@ const memoize = require("./util/memoize");
|
|
|
62
60
|
* @property {boolean=} hidden export is not visible, because another export blends over it
|
|
63
61
|
*/
|
|
64
62
|
|
|
63
|
+
/** @typedef {Set<string>} ExportsSpecExcludeExports */
|
|
64
|
+
|
|
65
65
|
/**
|
|
66
66
|
* @typedef {object} ExportsSpec
|
|
67
67
|
* @property {(string | ExportSpec)[] | true | null} exports exported names, true for unknown exports or null for no exports
|
|
68
|
-
* @property {
|
|
68
|
+
* @property {ExportsSpecExcludeExports=} excludeExports when exports = true, list of unaffected exports
|
|
69
69
|
* @property {(Set<string> | null)=} hideExports list of maybe prior exposed, but now hidden exports
|
|
70
70
|
* @property {ModuleGraphConnection=} from when reexported: from which module
|
|
71
71
|
* @property {number=} priority when reexported: with which priority
|
|
@@ -80,6 +80,9 @@ const memoize = require("./util/memoize");
|
|
|
80
80
|
* @property {boolean=} canMangle when false, referenced export can not be mangled, defaults to true
|
|
81
81
|
*/
|
|
82
82
|
|
|
83
|
+
/** @typedef {string[][]} RawReferencedExports */
|
|
84
|
+
/** @typedef {(string[] | ReferencedExport)[]} ReferencedExports */
|
|
85
|
+
|
|
83
86
|
/** @typedef {(moduleGraphConnection: ModuleGraphConnection, runtime: RuntimeSpec) => ConnectionState} GetConditionFn */
|
|
84
87
|
|
|
85
88
|
const TRANSITIVE = Symbol("transitive");
|
|
@@ -105,9 +108,6 @@ class Dependency {
|
|
|
105
108
|
this.weak = false;
|
|
106
109
|
// TODO check if this can be moved into ModuleDependency
|
|
107
110
|
/** @type {boolean | undefined} */
|
|
108
|
-
this.defer = false;
|
|
109
|
-
// TODO check if this can be moved into ModuleDependency
|
|
110
|
-
/** @type {boolean | undefined} */
|
|
111
111
|
this.optional = false;
|
|
112
112
|
this._locSL = 0;
|
|
113
113
|
this._locSC = 0;
|
|
@@ -230,7 +230,7 @@ class Dependency {
|
|
|
230
230
|
* Returns list of exports referenced by this dependency
|
|
231
231
|
* @param {ModuleGraph} moduleGraph module graph
|
|
232
232
|
* @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
|
233
|
-
* @returns {
|
|
233
|
+
* @returns {ReferencedExports} referenced exports
|
|
234
234
|
*/
|
|
235
235
|
getReferencedExports(moduleGraph, runtime) {
|
|
236
236
|
return Dependency.EXPORTS_OBJECT_REFERENCED;
|
|
@@ -315,7 +315,6 @@ class Dependency {
|
|
|
315
315
|
write(this._locEC);
|
|
316
316
|
write(this._locI);
|
|
317
317
|
write(this._locN);
|
|
318
|
-
write(this.defer);
|
|
319
318
|
}
|
|
320
319
|
|
|
321
320
|
/**
|
|
@@ -330,13 +329,12 @@ class Dependency {
|
|
|
330
329
|
this._locEC = read();
|
|
331
330
|
this._locI = read();
|
|
332
331
|
this._locN = read();
|
|
333
|
-
this.defer = read();
|
|
334
332
|
}
|
|
335
333
|
}
|
|
336
334
|
|
|
337
|
-
/** @type {
|
|
335
|
+
/** @type {RawReferencedExports} */
|
|
338
336
|
Dependency.NO_EXPORTS_REFERENCED = [];
|
|
339
|
-
/** @type {
|
|
337
|
+
/** @type {RawReferencedExports} */
|
|
340
338
|
Dependency.EXPORTS_OBJECT_REFERENCED = [[]];
|
|
341
339
|
|
|
342
340
|
// TODO remove in webpack 6
|
|
@@ -8,12 +8,10 @@
|
|
|
8
8
|
const { DEFAULTS } = require("./config/defaults");
|
|
9
9
|
const createHash = require("./util/createHash");
|
|
10
10
|
|
|
11
|
-
/** @typedef {import("./
|
|
11
|
+
/** @typedef {import("./Compilation").DependencyConstructor} DependencyConstructor */
|
|
12
12
|
/** @typedef {import("./DependencyTemplate")} DependencyTemplate */
|
|
13
13
|
/** @typedef {typeof import("./util/Hash")} Hash */
|
|
14
14
|
|
|
15
|
-
/** @typedef {new (...args: EXPECTED_ANY[]) => Dependency} DependencyConstructor */
|
|
16
|
-
|
|
17
15
|
class DependencyTemplates {
|
|
18
16
|
/**
|
|
19
17
|
* @param {string | Hash} hashFunction the hash function to use
|
package/lib/DllModule.js
CHANGED
|
@@ -12,24 +12,18 @@ const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
|
|
|
12
12
|
const RuntimeGlobals = require("./RuntimeGlobals");
|
|
13
13
|
const makeSerializable = require("./util/makeSerializable");
|
|
14
14
|
|
|
15
|
-
/** @typedef {import("
|
|
16
|
-
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
|
17
|
-
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
|
15
|
+
/** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
18
16
|
/** @typedef {import("./Compilation")} Compilation */
|
|
19
17
|
/** @typedef {import("./Dependency")} Dependency */
|
|
20
18
|
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
|
21
|
-
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
|
22
19
|
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
|
|
23
20
|
/** @typedef {import("./Module").BuildCallback} BuildCallback */
|
|
24
21
|
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
|
|
25
22
|
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
|
26
23
|
/** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */
|
|
27
24
|
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
|
|
28
|
-
/** @typedef {import("./Module").SourceContext} SourceContext */
|
|
29
25
|
/** @typedef {import("./RequestShortener")} RequestShortener */
|
|
30
26
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
31
|
-
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
|
32
|
-
/** @typedef {import("./WebpackError")} WebpackError */
|
|
33
27
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
34
28
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
35
29
|
/** @typedef {import("./util/Hash")} Hash */
|
|
@@ -84,7 +84,7 @@ class DllReferencePlugin {
|
|
|
84
84
|
// Store the error in the params so that it can
|
|
85
85
|
// be added as a compilation error later on.
|
|
86
86
|
const manifestPath = makePathsRelative(
|
|
87
|
-
|
|
87
|
+
compiler.context,
|
|
88
88
|
manifest,
|
|
89
89
|
compiler.root
|
|
90
90
|
);
|
|
@@ -142,9 +142,7 @@ class DllReferencePlugin {
|
|
|
142
142
|
source,
|
|
143
143
|
type: this.options.type,
|
|
144
144
|
scope: this.options.scope,
|
|
145
|
-
context:
|
|
146
|
-
/** @type {string} */
|
|
147
|
-
(this.options.context || compiler.options.context),
|
|
145
|
+
context: this.options.context || compiler.context,
|
|
148
146
|
content:
|
|
149
147
|
/** @type {DllReferencePluginOptionsContent} */
|
|
150
148
|
(resolvedContent),
|
|
@@ -11,8 +11,6 @@ const EntryDependency = require("./dependencies/EntryDependency");
|
|
|
11
11
|
|
|
12
12
|
/** @typedef {import("../declarations/WebpackOptions").EntryDescriptionNormalized} EntryDescriptionNormalized */
|
|
13
13
|
/** @typedef {import("../declarations/WebpackOptions").EntryDynamicNormalized} EntryDynamic */
|
|
14
|
-
/** @typedef {import("../declarations/WebpackOptions").EntryItem} EntryItem */
|
|
15
|
-
/** @typedef {import("../declarations/WebpackOptions").EntryStaticNormalized} EntryStatic */
|
|
16
14
|
/** @typedef {import("./Compiler")} Compiler */
|
|
17
15
|
|
|
18
16
|
const PLUGIN_NAME = "DynamicEntryPlugin";
|
package/lib/EntryOptionPlugin.js
CHANGED
|
@@ -76,11 +76,6 @@ class EntryOptionPlugin {
|
|
|
76
76
|
wasmLoading: desc.wasmLoading,
|
|
77
77
|
library: desc.library
|
|
78
78
|
};
|
|
79
|
-
if (desc.layer !== undefined && !compiler.options.experiments.layers) {
|
|
80
|
-
throw new Error(
|
|
81
|
-
"'entryOptions.layer' is only allowed when 'experiments.layers' is enabled"
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
79
|
if (desc.chunkLoading) {
|
|
85
80
|
const EnableChunkLoadingPlugin = require("./javascript/EnableChunkLoadingPlugin");
|
|
86
81
|
|
|
@@ -9,10 +9,7 @@ const WebpackError = require("./WebpackError");
|
|
|
9
9
|
const makeSerializable = require("./util/makeSerializable");
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("./Module")} Module */
|
|
12
|
-
/** @typedef {import("./Compilation")} Compilation */
|
|
13
12
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
|
14
|
-
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
15
|
-
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
16
13
|
/** @typedef {"asyncWebAssembly" | "topLevelAwait" | "external promise" | "external script" | "external import" | "external module"} Feature */
|
|
17
14
|
|
|
18
15
|
class EnvironmentNotSupportAsyncWarning extends WebpackError {
|
|
@@ -12,7 +12,8 @@ const RuntimeGlobals = require("./RuntimeGlobals");
|
|
|
12
12
|
const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin");
|
|
13
13
|
|
|
14
14
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
15
|
-
/** @typedef {import("../declarations/WebpackOptions").
|
|
15
|
+
/** @typedef {import("../declarations/WebpackOptions").DevtoolNamespace} DevtoolNamespace */
|
|
16
|
+
/** @typedef {import("../declarations/WebpackOptions").DevtoolModuleFilenameTemplate} DevtoolModuleFilenameTemplate */
|
|
16
17
|
/** @typedef {import("./Compiler")} Compiler */
|
|
17
18
|
|
|
18
19
|
/** @type {WeakMap<Source, Source>} */
|
|
@@ -30,9 +31,9 @@ const devtoolWarning = new RawSource(`/*
|
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* @typedef {object} EvalDevToolModulePluginOptions
|
|
33
|
-
* @property {
|
|
34
|
+
* @property {DevtoolNamespace=} namespace namespace
|
|
34
35
|
* @property {string=} sourceUrlComment source url comment
|
|
35
|
-
* @property {
|
|
36
|
+
* @property {DevtoolModuleFilenameTemplate=} moduleFilenameTemplate module filename template
|
|
36
37
|
*/
|
|
37
38
|
|
|
38
39
|
const PLUGIN_NAME = "EvalDevToolModulePlugin";
|
|
@@ -17,7 +17,6 @@ const { makePathsAbsolute } = require("./util/identifier");
|
|
|
17
17
|
|
|
18
18
|
/** @typedef {import("webpack-sources").RawSourceMap} RawSourceMap */
|
|
19
19
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
20
|
-
/** @typedef {import("../declarations/WebpackOptions").DevTool} DevToolOptions */
|
|
21
20
|
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
|
|
22
21
|
/** @typedef {import("./ChunkGraph").ModuleId} ModuleId */
|
|
23
22
|
/** @typedef {import("./Compiler")} Compiler */
|
|
@@ -39,9 +38,9 @@ const PLUGIN_NAME = "EvalSourceMapDevToolPlugin";
|
|
|
39
38
|
|
|
40
39
|
class EvalSourceMapDevToolPlugin {
|
|
41
40
|
/**
|
|
42
|
-
* @param {SourceMapDevToolPluginOptions | string} inputOptions Options object
|
|
41
|
+
* @param {SourceMapDevToolPluginOptions | string=} inputOptions Options object
|
|
43
42
|
*/
|
|
44
|
-
constructor(inputOptions) {
|
|
43
|
+
constructor(inputOptions = {}) {
|
|
45
44
|
/** @type {SourceMapDevToolPluginOptions} */
|
|
46
45
|
let options;
|
|
47
46
|
if (typeof inputOptions === "string") {
|
|
@@ -134,7 +133,7 @@ class EvalSourceMapDevToolPlugin {
|
|
|
134
133
|
|
|
135
134
|
// Clone (flat) the sourcemap to ensure that the mutations below do not persist.
|
|
136
135
|
sourceMap = { ...sourceMap };
|
|
137
|
-
const context =
|
|
136
|
+
const context = compiler.context;
|
|
138
137
|
const root = compiler.root;
|
|
139
138
|
const modules = sourceMap.sources.map((source) => {
|
|
140
139
|
if (!source.startsWith("webpack://")) return source;
|