webpack 5.101.3 → 5.102.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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 +37 -27
- package/lib/ChunkGroup.js +8 -10
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +3 -3
- package/lib/CodeGenerationResults.js +3 -2
- package/lib/CompatibilityPlugin.js +29 -12
- package/lib/Compilation.js +209 -196
- package/lib/Compiler.js +36 -35
- package/lib/ConcatenationScope.js +6 -1
- package/lib/ConditionalInitFragment.js +1 -1
- package/lib/ConstPlugin.js +6 -5
- package/lib/ContextExclusionPlugin.js +0 -1
- package/lib/ContextModule.js +25 -21
- package/lib/ContextModuleFactory.js +30 -11
- package/lib/ContextReplacementPlugin.js +38 -15
- package/lib/DefinePlugin.js +5 -9
- package/lib/DelegatedModule.js +7 -11
- package/lib/DependenciesBlock.js +0 -2
- package/lib/Dependency.js +9 -11
- package/lib/DependencyTemplates.js +2 -4
- 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 +105 -90
- 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 +42 -25
- 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 +146 -89
- package/lib/NormalModuleFactory.js +132 -42
- 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 +22 -12
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +2 -2
- package/lib/SourceMapDevToolPlugin.js +11 -18
- 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 +167 -0
- package/lib/asset/AssetBytesParser.js +37 -0
- package/lib/asset/AssetGenerator.js +22 -37
- 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/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/cache/getLazyHashedEtag.js +1 -1
- package/lib/config/browserslistTargetHandler.js +77 -76
- package/lib/config/defaults.js +162 -23
- package/lib/config/normalization.js +18 -3
- package/lib/config/target.js +1 -1
- 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 +13 -19
- package/lib/css/CssParser.js +3 -3
- package/lib/css/walkCssTokens.js +2 -2
- 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 +4 -7
- 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 +33 -14
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +20 -23
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +0 -4
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -31
- package/lib/dependencies/HarmonyModulesPlugin.js +3 -3
- package/lib/dependencies/ImportContextDependency.js +13 -0
- 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 +3 -2
- package/lib/dependencies/ImportParserPlugin.js +288 -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 +4 -12
- 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/HashedModuleIdsPlugin.js +5 -7
- package/lib/ids/IdHelpers.js +1 -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 +46 -24
- package/lib/javascript/JavascriptParser.js +120 -55
- 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 +15 -6
- 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/RealContentHashPlugin.js +5 -3
- 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/FileMiddleware.js +1 -1
- package/lib/serialization/NullPrototypeObjectSerializer.js +5 -3
- package/lib/serialization/ObjectMiddleware.js +31 -20
- 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 +179 -95
- 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/Hash.js +35 -5
- 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 +1 -2
- package/lib/util/createHash.js +85 -15
- 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/hash/BatchedHash.js +47 -8
- package/lib/util/hash/wasm-hash.js +53 -13
- 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 -10
- 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 -13
- 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 +21 -21
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +93 -96
- 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/ids/HashedModuleIdsPlugin.check.d.ts +7 -0
- package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +6 -0
- package/schemas/plugins/{HashedModuleIdsPlugin.json → ids/HashedModuleIdsPlugin.json} +15 -2
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +3 -3
- package/types.d.ts +1699 -706
- package/SECURITY.md +0 -9
- package/schemas/plugins/HashedModuleIdsPlugin.check.d.ts +0 -7
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +0 -6
|
@@ -11,7 +11,6 @@ const Template = require("../Template");
|
|
|
11
11
|
const HelperRuntimeModule = require("./HelperRuntimeModule");
|
|
12
12
|
|
|
13
13
|
/** @typedef {import("../Chunk")} Chunk */
|
|
14
|
-
/** @typedef {import("../Compiler")} Compiler */
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* @typedef {object} LoadScriptCompilationHooks
|
|
@@ -74,7 +73,6 @@ class LoadScriptRuntimeModule extends HelperRuntimeModule {
|
|
|
74
73
|
"script = document.createElement('script');",
|
|
75
74
|
scriptType ? `script.type = ${JSON.stringify(scriptType)};` : "",
|
|
76
75
|
charset ? "script.charset = 'utf-8';" : "",
|
|
77
|
-
`script.timeout = ${/** @type {number} */ (loadTimeout) / 1000};`,
|
|
78
76
|
`if (${RuntimeGlobals.scriptNonce}) {`,
|
|
79
77
|
Template.indent(
|
|
80
78
|
`script.setAttribute("nonce", ${RuntimeGlobals.scriptNonce});`
|
|
@@ -174,7 +174,7 @@ class MakeDeferredNamespaceObjectRuntimeModule extends HelperRuntimeModule {
|
|
|
174
174
|
])},`,
|
|
175
175
|
`ownKeys: ${runtimeTemplate.basicFunction("", [
|
|
176
176
|
init,
|
|
177
|
-
`var keys = Reflect.ownKeys(ns).filter(${runtimeTemplate.expressionFunction('x !== "then"', "x")}).concat([Symbol.toStringTag]);`,
|
|
177
|
+
`var keys = Reflect.ownKeys(ns).filter(${runtimeTemplate.expressionFunction('x !== "then" && x !== Symbol.toStringTag', "x")}).concat([Symbol.toStringTag]);`,
|
|
178
178
|
"return keys;"
|
|
179
179
|
])},`,
|
|
180
180
|
`getOwnPropertyDescriptor: ${runtimeTemplate.basicFunction("_, name", [
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
8
8
|
const RuntimeModule = require("../RuntimeModule");
|
|
9
9
|
|
|
10
|
-
/** @typedef {import("../../declarations/WebpackOptions").
|
|
10
|
+
/** @typedef {import("../../declarations/WebpackOptions").PublicPath} PublicPath */
|
|
11
11
|
/** @typedef {import("../Compilation")} Compilation */
|
|
12
12
|
|
|
13
13
|
class PublicPathRuntimeModule extends RuntimeModule {
|
|
14
14
|
/**
|
|
15
|
-
* @param {
|
|
15
|
+
* @param {PublicPath} publicPath public path
|
|
16
16
|
*/
|
|
17
17
|
constructor(publicPath) {
|
|
18
18
|
super("publicPath", RuntimeModule.STAGE_BASIC);
|
|
@@ -8,7 +8,6 @@ const RuntimeGlobals = require("../RuntimeGlobals");
|
|
|
8
8
|
const RuntimeModule = require("../RuntimeModule");
|
|
9
9
|
|
|
10
10
|
/** @typedef {import("../Compilation")} Compilation */
|
|
11
|
-
/** @typedef {import("../MainTemplate")} MainTemplate */
|
|
12
11
|
|
|
13
12
|
class StartupEntrypointRuntimeModule extends RuntimeModule {
|
|
14
13
|
/**
|
|
@@ -7,8 +7,6 @@
|
|
|
7
7
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
8
8
|
const RuntimeModule = require("../RuntimeModule");
|
|
9
9
|
|
|
10
|
-
/** @typedef {import("../Compilation")} Compilation */
|
|
11
|
-
|
|
12
10
|
class SystemContextRuntimeModule extends RuntimeModule {
|
|
13
11
|
constructor() {
|
|
14
12
|
super("__system_context__");
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Alexander Akait @alexander-akait
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
9
|
+
const RuntimeModule = require("../RuntimeModule");
|
|
10
|
+
const Template = require("../Template");
|
|
11
|
+
|
|
12
|
+
/** @typedef {import("../Compilation")} Compilation */
|
|
13
|
+
|
|
14
|
+
class ToBinaryRuntimeModule extends RuntimeModule {
|
|
15
|
+
constructor() {
|
|
16
|
+
super("to binary");
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @returns {string | null} runtime code
|
|
21
|
+
*/
|
|
22
|
+
generate() {
|
|
23
|
+
const compilation = /** @type {Compilation} */ (this.compilation);
|
|
24
|
+
const fn = RuntimeGlobals.toBinary;
|
|
25
|
+
const { runtimeTemplate } = compilation;
|
|
26
|
+
|
|
27
|
+
// Inspired by esbuild
|
|
28
|
+
|
|
29
|
+
const isNodePlatform = compilation.compiler.platform.node;
|
|
30
|
+
const isWebPlatform = compilation.compiler.platform.web;
|
|
31
|
+
const isNeutralPlatform = runtimeTemplate.isNeutralPlatform();
|
|
32
|
+
|
|
33
|
+
return Template.asString([
|
|
34
|
+
"// define to binary helper",
|
|
35
|
+
`${fn} = ${isNeutralPlatform ? "typeof Buffer !== 'undefined' ? " : ""}${
|
|
36
|
+
isNodePlatform || isNeutralPlatform
|
|
37
|
+
? `${runtimeTemplate.returningFunction("new Uint8Array(Buffer.from(base64, 'base64'))", "base64")}`
|
|
38
|
+
: ""
|
|
39
|
+
} ${isNeutralPlatform ? ": " : ""}${
|
|
40
|
+
isWebPlatform || isNeutralPlatform
|
|
41
|
+
? `(${runtimeTemplate.basicFunction("", [
|
|
42
|
+
"var table = new Uint8Array(128);",
|
|
43
|
+
"for (var i = 0; i < 64; i++) table[i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i * 4 - 205] = i;",
|
|
44
|
+
`return ${runtimeTemplate.basicFunction("base64", [
|
|
45
|
+
"var n = base64.length, bytes = new Uint8Array((n - (base64[n - 1] == '=') - (base64[n - 2] == '=')) * 3 / 4 | 0);",
|
|
46
|
+
"for (var i = 0, j = 0; i < n;) {",
|
|
47
|
+
Template.indent([
|
|
48
|
+
"var c0 = table[base64.charCodeAt(i++)], c1 = table[base64.charCodeAt(i++)];",
|
|
49
|
+
"var c2 = table[base64.charCodeAt(i++)], c3 = table[base64.charCodeAt(i++)];",
|
|
50
|
+
"bytes[j++] = (c0 << 2) | (c1 >> 4);",
|
|
51
|
+
"bytes[j++] = (c1 << 4) | (c2 >> 2);",
|
|
52
|
+
"bytes[j++] = (c2 << 6) | c3;"
|
|
53
|
+
]),
|
|
54
|
+
"}",
|
|
55
|
+
"return bytes"
|
|
56
|
+
])}`
|
|
57
|
+
])})();`
|
|
58
|
+
: ""
|
|
59
|
+
}`
|
|
60
|
+
]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
module.exports = ToBinaryRuntimeModule;
|
|
@@ -6,37 +6,10 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const NormalModule = require("../NormalModule");
|
|
9
|
+
const { URIRegEx, decodeDataURI } = require("../util/dataURL");
|
|
9
10
|
|
|
10
11
|
/** @typedef {import("../Compiler")} Compiler */
|
|
11
12
|
|
|
12
|
-
// data URL scheme: "data:text/javascript;charset=utf-8;base64,some-string"
|
|
13
|
-
// http://www.ietf.org/rfc/rfc2397.txt
|
|
14
|
-
const URIRegEx = /^data:([^;,]+)?((?:;[^;,]+)*?)(?:;(base64)?)?,(.*)$/i;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @param {string} uri data URI
|
|
18
|
-
* @returns {Buffer | null} decoded data
|
|
19
|
-
*/
|
|
20
|
-
const decodeDataURI = (uri) => {
|
|
21
|
-
const match = URIRegEx.exec(uri);
|
|
22
|
-
if (!match) return null;
|
|
23
|
-
|
|
24
|
-
const isBase64 = match[3];
|
|
25
|
-
const body = match[4];
|
|
26
|
-
|
|
27
|
-
if (isBase64) {
|
|
28
|
-
return Buffer.from(body, "base64");
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// CSS allows to use `data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" style="stroke: rgb(223,224,225); stroke-width: 2px; fill: none; stroke-dasharray: 6px 3px" /></svg>`
|
|
32
|
-
// so we return original body if we can't `decodeURIComponent`
|
|
33
|
-
try {
|
|
34
|
-
return Buffer.from(decodeURIComponent(body), "ascii");
|
|
35
|
-
} catch (_) {
|
|
36
|
-
return Buffer.from(body, "ascii");
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
13
|
const PLUGIN_NAME = "DataUriPlugin";
|
|
41
14
|
|
|
42
15
|
class DataUriPlugin {
|
|
@@ -62,6 +35,7 @@ class DataUriPlugin {
|
|
|
62
35
|
resourceData.data.encodedContent = match[4] || "";
|
|
63
36
|
}
|
|
64
37
|
});
|
|
38
|
+
|
|
65
39
|
NormalModule.getCompilationHooks(compilation)
|
|
66
40
|
.readResourceForScheme.for("data")
|
|
67
41
|
.tap(PLUGIN_NAME, (resource) => decodeDataURI(resource));
|
|
@@ -40,8 +40,11 @@ class FileUriPlugin {
|
|
|
40
40
|
.for(undefined)
|
|
41
41
|
.tapAsync(PLUGIN_NAME, (loaderContext, callback) => {
|
|
42
42
|
const { resourcePath } = loaderContext;
|
|
43
|
-
loaderContext.
|
|
44
|
-
|
|
43
|
+
loaderContext.fs.readFile(resourcePath, (err, result) => {
|
|
44
|
+
if (err) return callback(err);
|
|
45
|
+
loaderContext.addDependency(resourcePath);
|
|
46
|
+
callback(null, result);
|
|
47
|
+
});
|
|
45
48
|
});
|
|
46
49
|
}
|
|
47
50
|
);
|
|
@@ -1199,8 +1199,10 @@ Run build with un-frozen lockfile to automatically fix lockfile.`
|
|
|
1199
1199
|
getInfo(resource, (err, _result) => {
|
|
1200
1200
|
if (err) return callback(err);
|
|
1201
1201
|
const result = /** @type {Info} */ (_result);
|
|
1202
|
-
|
|
1203
|
-
|
|
1202
|
+
if (module) {
|
|
1203
|
+
/** @type {BuildInfo} */
|
|
1204
|
+
(module.buildInfo).resourceIntegrity = result.entry.integrity;
|
|
1205
|
+
}
|
|
1204
1206
|
callback(null, result.content);
|
|
1205
1207
|
})
|
|
1206
1208
|
);
|
|
@@ -11,9 +11,6 @@ const { parseResourceWithoutFragment } = require("../util/identifier");
|
|
|
11
11
|
|
|
12
12
|
/** @typedef {import("../Compiler")} Compiler */
|
|
13
13
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
14
|
-
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
15
|
-
/** @typedef {import("../Module").ValueCacheVersions} ValueCacheVersions */
|
|
16
|
-
/** @typedef {string | Set<string>} ValueCacheVersion */
|
|
17
14
|
|
|
18
15
|
/**
|
|
19
16
|
* @template T
|
|
@@ -23,18 +20,21 @@ const { parseResourceWithoutFragment } = require("../util/identifier");
|
|
|
23
20
|
const PLUGIN_NAME = "VirtualUrlPlugin";
|
|
24
21
|
const DEFAULT_SCHEME = "virtual";
|
|
25
22
|
|
|
23
|
+
/** @typedef {(loaderContext: LoaderContext<EXPECTED_ANY>) => Promise<string | Buffer> | string | Buffer} SourceFn */
|
|
24
|
+
/** @typedef {() => string} VersionFn */
|
|
25
|
+
|
|
26
26
|
/**
|
|
27
27
|
* @typedef {object} VirtualModuleConfig
|
|
28
|
-
* @property {string=} type
|
|
29
|
-
* @property {
|
|
30
|
-
* @property {
|
|
28
|
+
* @property {string=} type the module type
|
|
29
|
+
* @property {SourceFn} source the source function
|
|
30
|
+
* @property {VersionFn | true | string=} version optional version function or value
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* @typedef {string |
|
|
34
|
+
* @typedef {string | SourceFn | VirtualModuleConfig} VirtualModuleInput
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
|
-
/** @typedef {{[key: string]: VirtualModuleInput}} VirtualModules */
|
|
37
|
+
/** @typedef {{ [key: string]: VirtualModuleInput }} VirtualModules */
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Normalizes a virtual module definition into a standard format
|
|
@@ -62,13 +62,13 @@ function normalizeModule(virtualConfig) {
|
|
|
62
62
|
* Normalizes all virtual modules with the given scheme
|
|
63
63
|
* @param {VirtualModules} virtualConfigs The virtual modules to normalize
|
|
64
64
|
* @param {string} scheme The URL scheme to use
|
|
65
|
-
* @returns {{[key: string]: VirtualModuleConfig}} The normalized virtual modules
|
|
65
|
+
* @returns {{ [key: string]: VirtualModuleConfig }} The normalized virtual modules
|
|
66
66
|
*/
|
|
67
67
|
function normalizeModules(virtualConfigs, scheme) {
|
|
68
68
|
return Object.keys(virtualConfigs).reduce((pre, id) => {
|
|
69
69
|
pre[toVid(id, scheme)] = normalizeModule(virtualConfigs[id]);
|
|
70
70
|
return pre;
|
|
71
|
-
}, /** @type {{[key: string]: VirtualModuleConfig}} */ ({}));
|
|
71
|
+
}, /** @type {{ [key: string]: VirtualModuleConfig }} */ ({}));
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
/**
|
|
@@ -207,7 +207,7 @@ class VirtualUrlPlugin {
|
|
|
207
207
|
|
|
208
208
|
/**
|
|
209
209
|
* Get the cache version for a given version value
|
|
210
|
-
* @param {
|
|
210
|
+
* @param {VersionFn | true | string} version The version value or function
|
|
211
211
|
* @returns {string | undefined} The cache version
|
|
212
212
|
*/
|
|
213
213
|
getCacheVersion(version) {
|
|
@@ -55,7 +55,7 @@ const WRITE_LIMIT_CHUNK = 511 * 1024 * 1024;
|
|
|
55
55
|
const hashForName = (buffers, hashFunction) => {
|
|
56
56
|
const hash = createHash(hashFunction);
|
|
57
57
|
for (const buf of buffers) hash.update(buf);
|
|
58
|
-
return
|
|
58
|
+
return hash.digest("hex");
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
const COMPRESSION_CHUNK_SIZE = 100 * 1024 * 1024;
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
/** @typedef {import("./ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
8
8
|
/** @typedef {import("./ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
9
9
|
|
|
10
|
+
/** @typedef {string[]} Keys */
|
|
11
|
+
|
|
10
12
|
class NullPrototypeObjectSerializer {
|
|
11
13
|
/**
|
|
12
14
|
* @template {object} T
|
|
@@ -14,7 +16,7 @@ class NullPrototypeObjectSerializer {
|
|
|
14
16
|
* @param {ObjectSerializerContext} context context
|
|
15
17
|
*/
|
|
16
18
|
serialize(obj, context) {
|
|
17
|
-
/** @type {
|
|
19
|
+
/** @type {Keys} */
|
|
18
20
|
const keys = Object.keys(obj);
|
|
19
21
|
for (const key of keys) {
|
|
20
22
|
context.write(key);
|
|
@@ -33,9 +35,9 @@ class NullPrototypeObjectSerializer {
|
|
|
33
35
|
deserialize(context) {
|
|
34
36
|
/** @type {T} */
|
|
35
37
|
const obj = Object.create(null);
|
|
36
|
-
/** @type {
|
|
38
|
+
/** @type {Keys} */
|
|
37
39
|
const keys = [];
|
|
38
|
-
/** @type {
|
|
40
|
+
/** @type {Keys[number] | null} */
|
|
39
41
|
let key = context.read();
|
|
40
42
|
while (key !== null) {
|
|
41
43
|
keys.push(key);
|
|
@@ -56,29 +56,29 @@ Technically any value can be used.
|
|
|
56
56
|
* @property {number} objectTypeLookupSize
|
|
57
57
|
* @property {number} currentPosTypeLookup
|
|
58
58
|
*/
|
|
59
|
-
|
|
59
|
+
|
|
60
60
|
/** @typedef {EXPECTED_OBJECT | string} ReferenceableItem */
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* @typedef {object} ObjectSerializerContext
|
|
64
|
-
* @property {(value:
|
|
64
|
+
* @property {(value: EXPECTED_ANY) => void} write
|
|
65
65
|
* @property {(value: ReferenceableItem) => void} setCircularReference
|
|
66
66
|
* @property {() => ObjectSerializerSnapshot} snapshot
|
|
67
67
|
* @property {(snapshot: ObjectSerializerSnapshot) => void} rollback
|
|
68
|
-
* @property {((item:
|
|
69
|
-
* @property {((item: (
|
|
68
|
+
* @property {((item: EXPECTED_ANY | (() => EXPECTED_ANY)) => void)=} writeLazy
|
|
69
|
+
* @property {((item: (EXPECTED_ANY | (() => EXPECTED_ANY)), obj: LazyOptions | undefined) => import("./SerializerMiddleware").LazyFunction<EXPECTED_ANY, EXPECTED_ANY, EXPECTED_ANY, LazyOptions>)=} writeSeparate
|
|
70
70
|
*/
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* @typedef {object} ObjectDeserializerContext
|
|
74
|
-
* @property {() =>
|
|
74
|
+
* @property {() => EXPECTED_ANY} read
|
|
75
75
|
* @property {(value: ReferenceableItem) => void} setCircularReference
|
|
76
76
|
*/
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* @typedef {object} ObjectSerializer
|
|
80
|
-
* @property {(value:
|
|
81
|
-
* @property {(context: ObjectDeserializerContext) =>
|
|
80
|
+
* @property {(value: EXPECTED_ANY, context: ObjectSerializerContext) => void} serialize
|
|
81
|
+
* @property {(context: ObjectDeserializerContext) => EXPECTED_ANY} deserialize
|
|
82
82
|
*/
|
|
83
83
|
|
|
84
84
|
/**
|
|
@@ -117,7 +117,7 @@ const setMapSize = (map, size) => {
|
|
|
117
117
|
const toHash = (buffer, hashFunction) => {
|
|
118
118
|
const hash = createHash(hashFunction);
|
|
119
119
|
hash.update(buffer);
|
|
120
|
-
return
|
|
120
|
+
return hash.digest("latin1");
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
const ESCAPE = null;
|
|
@@ -130,7 +130,7 @@ const CURRENT_VERSION = 2;
|
|
|
130
130
|
/** @typedef {{ request?: string, name?: string | number | null, serializer?: ObjectSerializer }} SerializerConfig */
|
|
131
131
|
/** @typedef {{ request?: string, name?: string | number | null, serializer: ObjectSerializer }} SerializerConfigWithSerializer */
|
|
132
132
|
|
|
133
|
-
/** @type {Map<Constructor, SerializerConfig>} */
|
|
133
|
+
/** @type {Map<Constructor | null, SerializerConfig>} */
|
|
134
134
|
const serializers = new Map();
|
|
135
135
|
/** @type {Map<string | number, ObjectSerializer>} */
|
|
136
136
|
const serializerInversed = new Map();
|
|
@@ -140,6 +140,7 @@ const loadedRequests = new Set();
|
|
|
140
140
|
|
|
141
141
|
const NOT_SERIALIZABLE = {};
|
|
142
142
|
|
|
143
|
+
/** @type {Map<Constructor | null, ObjectSerializer>} */
|
|
143
144
|
const jsTypes = new Map();
|
|
144
145
|
|
|
145
146
|
jsTypes.set(Object, new PlainObjectSerializer());
|
|
@@ -335,7 +336,7 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
|
335
336
|
* @returns {SerializedType | Promise<SerializedType> | null} serialized data
|
|
336
337
|
*/
|
|
337
338
|
serialize(data, context) {
|
|
338
|
-
/** @type {
|
|
339
|
+
/** @type {PrimitiveSerializableType[]} */
|
|
339
340
|
let result = [CURRENT_VERSION];
|
|
340
341
|
let currentPos = 0;
|
|
341
342
|
/** @type {Map<ReferenceableItem, number>} */
|
|
@@ -412,7 +413,7 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
|
412
413
|
let objectTypeLookup = new Map();
|
|
413
414
|
const cycleStack = new Set();
|
|
414
415
|
/**
|
|
415
|
-
* @param {
|
|
416
|
+
* @param {ComplexSerializableType} item item to stack
|
|
416
417
|
* @returns {string} stack
|
|
417
418
|
*/
|
|
418
419
|
const stackToString = (item) => {
|
|
@@ -511,7 +512,7 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
|
511
512
|
};
|
|
512
513
|
this.extendContext(ctx);
|
|
513
514
|
/**
|
|
514
|
-
* @param {
|
|
515
|
+
* @param {ComplexSerializableType} item item to serialize
|
|
515
516
|
*/
|
|
516
517
|
const process = (item) => {
|
|
517
518
|
if (Buffer.isBuffer(item)) {
|
|
@@ -533,7 +534,7 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
|
533
534
|
}
|
|
534
535
|
addReferenceable(item);
|
|
535
536
|
|
|
536
|
-
result.push(item);
|
|
537
|
+
result.push(/** @type {Buffer} */ (item));
|
|
537
538
|
} else if (item === ESCAPE) {
|
|
538
539
|
result.push(ESCAPE, ESCAPE_ESCAPE_VALUE);
|
|
539
540
|
} else if (
|
|
@@ -553,8 +554,10 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
|
553
554
|
);
|
|
554
555
|
}
|
|
555
556
|
|
|
556
|
-
const { request, name, serializer } =
|
|
557
|
-
|
|
557
|
+
const { request, name, serializer } = ObjectMiddleware.getSerializerFor(
|
|
558
|
+
/** @type {Constructor} */
|
|
559
|
+
(item)
|
|
560
|
+
);
|
|
558
561
|
const key = `${request}/${name}`;
|
|
559
562
|
const lastIndex = objectTypeLookup.get(key);
|
|
560
563
|
|
|
@@ -616,9 +619,13 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
|
616
619
|
} else if (SerializerMiddleware.isLazy(item, this)) {
|
|
617
620
|
throw new Error("Not implemented");
|
|
618
621
|
} else {
|
|
619
|
-
const data =
|
|
620
|
-
|
|
621
|
-
|
|
622
|
+
const data =
|
|
623
|
+
/** @type {() => PrimitiveSerializableType[] | Promise<PrimitiveSerializableType[]>} */
|
|
624
|
+
(
|
|
625
|
+
SerializerMiddleware.serializeLazy(item, (data) =>
|
|
626
|
+
this.serialize([data], context)
|
|
627
|
+
)
|
|
628
|
+
);
|
|
622
629
|
SerializerMiddleware.setLazySerializedValue(item, data);
|
|
623
630
|
result.push(data);
|
|
624
631
|
}
|
|
@@ -677,7 +684,7 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
|
677
684
|
/** @type {ReferenceableItem[]} */
|
|
678
685
|
let referenceable = [];
|
|
679
686
|
/**
|
|
680
|
-
* @param {
|
|
687
|
+
* @param {ReferenceableItem} item referenceable item
|
|
681
688
|
*/
|
|
682
689
|
const addReferenceable = (item) => {
|
|
683
690
|
referenceable.push(item);
|
|
@@ -686,6 +693,7 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
|
686
693
|
let currentPosTypeLookup = 0;
|
|
687
694
|
/** @type {ObjectSerializer[]} */
|
|
688
695
|
let objectTypeLookup = [];
|
|
696
|
+
/** @type {ComplexSerializableType[]} */
|
|
689
697
|
let result = [];
|
|
690
698
|
/** @type {ObjectDeserializerContext} */
|
|
691
699
|
let ctx = {
|
|
@@ -698,6 +706,9 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
|
698
706
|
...context
|
|
699
707
|
};
|
|
700
708
|
this.extendContext(ctx);
|
|
709
|
+
/**
|
|
710
|
+
* @returns {ComplexSerializableType} deserialize value
|
|
711
|
+
*/
|
|
701
712
|
const decodeValue = () => {
|
|
702
713
|
const item = read();
|
|
703
714
|
|
|
@@ -789,7 +800,7 @@ class ObjectMiddleware extends SerializerMiddleware {
|
|
|
789
800
|
const name = !serializerEntry
|
|
790
801
|
? "unknown"
|
|
791
802
|
: !serializerEntry[1].request
|
|
792
|
-
? serializerEntry[0].name
|
|
803
|
+
? /** @type {Constructor[]} */ (serializerEntry)[0].name
|
|
793
804
|
: serializerEntry[1].name
|
|
794
805
|
? `${serializerEntry[1].request} ${serializerEntry[1].name}`
|
|
795
806
|
: serializerEntry[1].request;
|
|
@@ -96,7 +96,6 @@ class SerializerMiddleware {
|
|
|
96
96
|
* @template TLazyOutputValue
|
|
97
97
|
* @template {LazyTarget} TLazyTarget
|
|
98
98
|
* @template {Record<string, EXPECTED_ANY>} TLazyOptions
|
|
99
|
-
* @template TLazySerializedValue
|
|
100
99
|
* @param {LazyFunction<TLazyInputValue, TLazyOutputValue, TLazyTarget, TLazyOptions>} fn lazy function
|
|
101
100
|
* @returns {LazyOptions | undefined} options
|
|
102
101
|
*/
|
|
@@ -123,7 +122,7 @@ class SerializerMiddleware {
|
|
|
123
122
|
* @template TLazyOutputValue
|
|
124
123
|
* @template {LazyTarget} TLazyTarget
|
|
125
124
|
* @template {LazyOptions} TLazyOptions
|
|
126
|
-
* @param {LazyFunction<TLazyInputValue, TLazyOutputValue,
|
|
125
|
+
* @param {LazyFunction<TLazyInputValue, TLazyOutputValue, TLazyTarget, TLazyOptions>} fn lazy function
|
|
127
126
|
* @param {TLazyOutputValue} value serialized value
|
|
128
127
|
* @returns {void}
|
|
129
128
|
*/
|
|
@@ -168,7 +167,6 @@ class SerializerMiddleware {
|
|
|
168
167
|
/**
|
|
169
168
|
* @template TLazyInputValue SerializedValue
|
|
170
169
|
* @template TLazyOutputValue DeserializedValue
|
|
171
|
-
* @template SerializedValue
|
|
172
170
|
* @template {LazyTarget} TLazyTarget
|
|
173
171
|
* @template {LazyOptions | undefined} TLazyOptions
|
|
174
172
|
* @param {LazyFunction<TLazyInputValue, TLazyOutputValue, TLazyTarget, TLazyOptions>} lazy lazy function
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
"use strict";
|
|
6
6
|
|
|
7
|
-
/** @typedef {undefined | null | number | string | boolean | Buffer | EXPECTED_OBJECT | (() => ComplexSerializableType[] | Promise<ComplexSerializableType[]>)} ComplexSerializableType */
|
|
7
|
+
/** @typedef {undefined | null | number | bigint | string | boolean | Buffer | EXPECTED_OBJECT | (() => ComplexSerializableType[] | Promise<ComplexSerializableType[]>)} ComplexSerializableType */
|
|
8
8
|
|
|
9
9
|
/** @typedef {undefined | null | number | bigint | string | boolean | Buffer | (() => PrimitiveSerializableType[] | Promise<PrimitiveSerializableType[]>)} PrimitiveSerializableType */
|
|
10
10
|
|
|
@@ -17,21 +17,19 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
17
17
|
const { rangeToString, stringifyHoley } = require("../util/semver");
|
|
18
18
|
const ConsumeSharedFallbackDependency = require("./ConsumeSharedFallbackDependency");
|
|
19
19
|
|
|
20
|
-
/** @typedef {import("
|
|
21
|
-
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
22
|
-
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
|
20
|
+
/** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
23
21
|
/** @typedef {import("../Compilation")} Compilation */
|
|
24
22
|
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
|
25
23
|
/** @typedef {import("../Module").BuildCallback} BuildCallback */
|
|
26
24
|
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
|
27
25
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
|
28
26
|
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
|
|
27
|
+
/** @typedef {import("../Module").LibIdent} LibIdent */
|
|
29
28
|
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
|
|
30
29
|
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
|
|
31
30
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
32
31
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
33
32
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
34
|
-
/** @typedef {import("../WebpackError")} WebpackError */
|
|
35
33
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
36
34
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
37
35
|
/** @typedef {import("../util/Hash")} Hash */
|
|
@@ -104,7 +102,7 @@ class ConsumeSharedModule extends Module {
|
|
|
104
102
|
|
|
105
103
|
/**
|
|
106
104
|
* @param {LibIdentOptions} options options
|
|
107
|
-
* @returns {
|
|
105
|
+
* @returns {LibIdent | null} an identifier for library inclusion
|
|
108
106
|
*/
|
|
109
107
|
libIdent(options) {
|
|
110
108
|
const { shareKey, shareScope, import: request } = this.options;
|
|
@@ -23,8 +23,8 @@ const {
|
|
|
23
23
|
isRequiredVersion
|
|
24
24
|
} = require("./utils");
|
|
25
25
|
|
|
26
|
+
/** @typedef {import("enhanced-resolve").ResolveContext} ResolveContext */
|
|
26
27
|
/** @typedef {import("../../declarations/plugins/sharing/ConsumeSharedPlugin").ConsumeSharedPluginOptions} ConsumeSharedPluginOptions */
|
|
27
|
-
/** @typedef {import("../../declarations/plugins/sharing/ConsumeSharedPlugin").ConsumesConfig} ConsumesConfig */
|
|
28
28
|
/** @typedef {import("../Compiler")} Compiler */
|
|
29
29
|
/** @typedef {import("../ResolverFactory").ResolveOptionsWithDependencyType} ResolveOptionsWithDependencyType */
|
|
30
30
|
/** @typedef {import("../util/semver").SemVerRange} SemVerRange */
|
|
@@ -168,12 +168,10 @@ class ConsumeSharedPlugin {
|
|
|
168
168
|
resolve();
|
|
169
169
|
return;
|
|
170
170
|
}
|
|
171
|
+
/** @typedef {ResolveContext} */
|
|
171
172
|
const resolveContext = {
|
|
172
|
-
/** @type {LazySet<string>} */
|
|
173
173
|
fileDependencies: new LazySet(),
|
|
174
|
-
/** @type {LazySet<string>} */
|
|
175
174
|
contextDependencies: new LazySet(),
|
|
176
|
-
/** @type {LazySet<string>} */
|
|
177
175
|
missingDependencies: new LazySet()
|
|
178
176
|
};
|
|
179
177
|
resolver.resolve(
|
|
@@ -23,7 +23,7 @@ const {
|
|
|
23
23
|
/** @typedef {import("../Compilation")} Compilation */
|
|
24
24
|
/** @typedef {import("../Module")} Module */
|
|
25
25
|
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
|
26
|
-
/** @typedef {import("
|
|
26
|
+
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
|
27
27
|
|
|
28
28
|
class ConsumeSharedRuntimeModule extends RuntimeModule {
|
|
29
29
|
/**
|
|
@@ -40,17 +40,20 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
|
|
|
40
40
|
generate() {
|
|
41
41
|
const compilation = /** @type {Compilation} */ (this.compilation);
|
|
42
42
|
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
|
43
|
-
const
|
|
44
|
-
|
|
43
|
+
const codeGenerationResults =
|
|
44
|
+
/** @type {CodeGenerationResults} */
|
|
45
|
+
(compilation.codeGenerationResults);
|
|
46
|
+
const { runtimeTemplate } = compilation;
|
|
47
|
+
/** @type {Record<ChunkId, ModuleId[]>} */
|
|
45
48
|
const chunkToModuleMapping = {};
|
|
46
|
-
/** @type {Map<
|
|
49
|
+
/** @type {Map<ModuleId, Source>} */
|
|
47
50
|
const moduleIdToSourceMapping = new Map();
|
|
48
|
-
/** @type {
|
|
51
|
+
/** @type {ModuleId[]} */
|
|
49
52
|
const initialConsumes = [];
|
|
50
53
|
/**
|
|
51
54
|
* @param {Iterable<Module>} modules modules
|
|
52
55
|
* @param {Chunk} chunk the chunk
|
|
53
|
-
* @param {
|
|
56
|
+
* @param {ModuleId[]} list list of ids
|
|
54
57
|
*/
|
|
55
58
|
const addModules = (modules, chunk, list) => {
|
|
56
59
|
for (const m of modules) {
|
|
@@ -13,24 +13,20 @@ const RuntimeGlobals = require("../RuntimeGlobals");
|
|
|
13
13
|
const makeSerializable = require("../util/makeSerializable");
|
|
14
14
|
const ProvideForSharedDependency = require("./ProvideForSharedDependency");
|
|
15
15
|
|
|
16
|
-
/** @typedef {import("
|
|
17
|
-
/** @typedef {import("../Chunk")} Chunk */
|
|
18
|
-
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
|
19
|
-
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
|
16
|
+
/** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
|
20
17
|
/** @typedef {import("../Compilation")} Compilation */
|
|
21
18
|
/** @typedef {import("../Module").BuildCallback} BuildCallback */
|
|
22
19
|
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
|
23
20
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
|
24
21
|
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
|
|
22
|
+
/** @typedef {import("../Module").LibIdent} LibIdent */
|
|
25
23
|
/** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */
|
|
26
24
|
/** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */
|
|
27
25
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
28
26
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
29
27
|
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
|
30
|
-
/** @typedef {import("../WebpackError")} WebpackError */
|
|
31
28
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
32
29
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
33
|
-
/** @typedef {import("../util/Hash")} Hash */
|
|
34
30
|
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
|
35
31
|
|
|
36
32
|
class ProvideSharedModule extends Module {
|
|
@@ -69,7 +65,7 @@ class ProvideSharedModule extends Module {
|
|
|
69
65
|
|
|
70
66
|
/**
|
|
71
67
|
* @param {LibIdentOptions} options options
|
|
72
|
-
* @returns {
|
|
68
|
+
* @returns {LibIdent | null} an identifier for library inclusion
|
|
73
69
|
*/
|
|
74
70
|
libIdent(options) {
|
|
75
71
|
return `${this.layer ? `(${this.layer})/` : ""}webpack/sharing/provide/${
|
|
@@ -10,9 +10,7 @@ const ConsumeSharedPlugin = require("./ConsumeSharedPlugin");
|
|
|
10
10
|
const ProvideSharedPlugin = require("./ProvideSharedPlugin");
|
|
11
11
|
const { isRequiredVersion } = require("./utils");
|
|
12
12
|
|
|
13
|
-
/** @typedef {import("../../declarations/plugins/sharing/ConsumeSharedPlugin").ConsumeSharedPluginOptions} ConsumeSharedPluginOptions */
|
|
14
13
|
/** @typedef {import("../../declarations/plugins/sharing/ConsumeSharedPlugin").ConsumesConfig} ConsumesConfig */
|
|
15
|
-
/** @typedef {import("../../declarations/plugins/sharing/ProvideSharedPlugin").ProvideSharedPluginOptions} ProvideSharedPluginOptions */
|
|
16
14
|
/** @typedef {import("../../declarations/plugins/sharing/ProvideSharedPlugin").ProvidesConfig} ProvidesConfig */
|
|
17
15
|
/** @typedef {import("../../declarations/plugins/sharing/SharePlugin").SharePluginOptions} SharePluginOptions */
|
|
18
16
|
/** @typedef {import("../../declarations/plugins/sharing/SharePlugin").SharedConfig} SharedConfig */
|