webpack 5.99.9 → 5.100.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/bin/webpack.js +8 -2
- package/hot/log.js +15 -15
- package/hot/poll.js +1 -0
- package/lib/APIPlugin.js +3 -3
- package/lib/AbstractMethodError.js +1 -0
- package/lib/AutomaticPrefetchPlugin.js +1 -0
- package/lib/BannerPlugin.js +1 -1
- package/lib/CaseSensitiveModulesWarning.js +4 -4
- package/lib/Chunk.js +6 -6
- package/lib/ChunkGraph.js +37 -31
- package/lib/ChunkGroup.js +4 -4
- package/lib/ChunkTemplate.js +1 -1
- package/lib/CleanPlugin.js +94 -17
- package/lib/CodeGenerationResults.js +1 -1
- package/lib/CompatibilityPlugin.js +5 -2
- package/lib/Compilation.js +67 -45
- package/lib/Compiler.js +46 -16
- package/lib/ConcatenationScope.js +15 -6
- package/lib/ConstPlugin.js +5 -3
- package/lib/ContextModule.js +16 -12
- package/lib/ContextModuleFactory.js +4 -3
- package/lib/ContextReplacementPlugin.js +4 -2
- package/lib/CssModule.js +2 -2
- package/lib/DefinePlugin.js +111 -3
- package/lib/DelegatedModuleFactoryPlugin.js +18 -18
- package/lib/Dependency.js +11 -4
- package/lib/DependencyTemplate.js +1 -0
- package/lib/DllEntryPlugin.js +3 -1
- package/lib/DllPlugin.js +4 -3
- package/lib/DllReferencePlugin.js +2 -2
- package/lib/DynamicEntryPlugin.js +1 -1
- package/lib/EntryOptionPlugin.js +5 -0
- package/lib/ErrorHelpers.js +4 -4
- package/lib/EvalDevToolModulePlugin.js +3 -3
- package/lib/EvalSourceMapDevToolPlugin.js +7 -7
- package/lib/ExportsInfo.js +48 -39
- package/lib/ExternalModule.js +15 -11
- package/lib/ExternalModuleFactoryPlugin.js +5 -2
- package/lib/FileSystemInfo.js +51 -36
- package/lib/FlagDependencyExportsPlugin.js +14 -7
- package/lib/FlagDependencyUsagePlugin.js +1 -1
- package/lib/Generator.js +14 -1
- package/lib/HookWebpackError.js +1 -0
- package/lib/HotModuleReplacementPlugin.js +77 -50
- package/lib/IgnorePlugin.js +5 -2
- package/lib/InvalidDependenciesModuleWarning.js +1 -1
- package/lib/JavascriptMetaInfoPlugin.js +0 -1
- package/lib/LibManifestPlugin.js +4 -2
- package/lib/LoaderOptionsPlugin.js +6 -4
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +21 -6
- package/lib/ModuleFactory.js +1 -0
- package/lib/ModuleGraph.js +24 -2
- package/lib/ModuleGraphConnection.js +5 -5
- package/lib/ModuleInfoHeaderPlugin.js +2 -1
- package/lib/ModuleParseError.js +1 -0
- package/lib/ModuleSourceTypesConstants.js +12 -12
- package/lib/ModuleTemplate.js +1 -1
- package/lib/ModuleTypeConstants.js +21 -21
- package/lib/MultiCompiler.js +6 -6
- package/lib/NormalModule.js +31 -44
- package/lib/NormalModuleFactory.js +34 -20
- package/lib/NormalModuleReplacementPlugin.js +1 -1
- package/lib/NullFactory.js +1 -0
- package/lib/OptimizationStages.js +1 -1
- package/lib/Parser.js +1 -0
- package/lib/ProgressPlugin.js +12 -5
- package/lib/ProvidePlugin.js +5 -1
- package/lib/RawModule.js +14 -0
- package/lib/RecordIdsPlugin.js +3 -3
- package/lib/RuntimeGlobals.js +175 -155
- package/lib/RuntimeModule.js +1 -0
- package/lib/RuntimePlugin.js +33 -7
- package/lib/RuntimeTemplate.js +111 -11
- package/lib/SourceMapDevToolModuleOptionsPlugin.js +15 -25
- package/lib/SourceMapDevToolPlugin.js +19 -17
- package/lib/Template.js +2 -2
- package/lib/TemplatedPathPlugin.js +1 -1
- package/lib/WarnDeprecatedOptionPlugin.js +7 -8
- package/lib/WatchIgnorePlugin.js +4 -3
- package/lib/WebpackIsIncludedPlugin.js +2 -1
- package/lib/WebpackOptionsApply.js +115 -27
- package/lib/asset/AssetGenerator.js +15 -11
- package/lib/asset/AssetModulesPlugin.js +19 -17
- package/lib/asset/AssetSourceGenerator.js +4 -4
- package/lib/asset/RawDataUrlModule.js +4 -2
- package/lib/async-modules/AwaitDependenciesInitFragment.js +1 -1
- package/lib/buildChunkGraph.js +6 -3
- package/lib/cache/AddBuildDependenciesPlugin.js +5 -6
- package/lib/cache/IdleFileCachePlugin.js +7 -4
- package/lib/cache/MemoryCachePlugin.js +1 -0
- package/lib/cache/MemoryWithGcCachePlugin.js +1 -0
- package/lib/cache/PackFileCacheStrategy.js +26 -20
- package/lib/cache/ResolverCachePlugin.js +16 -8
- package/lib/cli.js +15 -10
- package/lib/config/browserslistTargetHandler.js +3 -3
- package/lib/config/defaults.js +25 -17
- package/lib/config/normalization.js +2 -1
- package/lib/config/target.js +6 -5
- package/lib/container/ContainerPlugin.js +1 -1
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/container/FallbackModule.js +2 -1
- package/lib/container/HoistContainerReferencesPlugin.js +1 -1
- package/lib/container/ModuleFederationPlugin.js +2 -2
- package/lib/container/RemoteModule.js +1 -1
- package/lib/css/CssGenerator.js +9 -6
- package/lib/css/CssModulesPlugin.js +44 -31
- package/lib/css/CssParser.js +6 -4
- package/lib/css/walkCssTokens.js +33 -37
- package/lib/debug/ProfilingPlugin.js +6 -6
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -8
- package/lib/dependencies/AMDPlugin.js +12 -8
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +28 -26
- package/lib/dependencies/CachedConstDependency.js +1 -5
- package/lib/dependencies/CommonJsExportRequireDependency.js +6 -4
- package/lib/dependencies/CommonJsExportsParserPlugin.js +22 -25
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -9
- package/lib/dependencies/CommonJsImportsParserPlugin.js +100 -114
- package/lib/dependencies/CommonJsPlugin.js +15 -16
- package/lib/dependencies/ContextDependencyHelpers.js +2 -1
- package/lib/dependencies/ContextDependencyTemplateAsId.js +1 -0
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +1 -0
- package/lib/dependencies/CssIcssExportDependency.js +1 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -2
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/DynamicExports.js +9 -9
- package/lib/dependencies/ExportsInfoDependency.js +1 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +122 -101
- package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +95 -19
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +11 -5
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +238 -162
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +4 -1
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +20 -9
- package/lib/dependencies/HarmonyModulesPlugin.js +23 -12
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -0
- package/lib/dependencies/ImportMetaContextPlugin.js +2 -1
- package/lib/dependencies/ImportMetaPlugin.js +2 -2
- package/lib/dependencies/ImportParserPlugin.js +40 -9
- package/lib/dependencies/ImportPlugin.js +3 -1
- package/lib/dependencies/LoaderPlugin.js +1 -0
- package/lib/dependencies/ModuleDependency.js +3 -1
- package/lib/dependencies/ModuleDependencyTemplateAsRequireId.js +1 -0
- package/lib/dependencies/RequireContextPlugin.js +3 -1
- package/lib/dependencies/RequireEnsurePlugin.js +6 -6
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +33 -34
- package/lib/dependencies/RequireIncludePlugin.js +1 -0
- package/lib/dependencies/RuntimeRequirementsDependency.js +1 -1
- package/lib/dependencies/SystemPlugin.js +1 -1
- package/lib/dependencies/URLContextDependency.js +65 -0
- package/lib/dependencies/URLPlugin.js +17 -157
- package/lib/dependencies/WorkerPlugin.js +23 -10
- package/lib/dependencies/processExportInfo.js +2 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +269 -185
- package/lib/esm/ModuleChunkLoadingPlugin.js +39 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +70 -3
- package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
- package/lib/hmr/HotModuleReplacementRuntimeModule.js +1 -1
- package/lib/hmr/JavascriptHotModuleReplacementHelper.js +37 -0
- package/lib/hmr/LazyCompilationPlugin.js +4 -2
- package/lib/hmr/lazyCompilationBackend.js +4 -2
- package/lib/ids/ChunkModuleIdRangePlugin.js +6 -3
- package/lib/ids/DeterministicChunkIdsPlugin.js +30 -35
- package/lib/ids/DeterministicModuleIdsPlugin.js +4 -3
- package/lib/ids/HashedModuleIdsPlugin.js +5 -4
- package/lib/ids/IdHelpers.js +21 -17
- package/lib/ids/NamedChunkIdsPlugin.js +5 -5
- package/lib/ids/NamedModuleIdsPlugin.js +4 -4
- package/lib/ids/NaturalChunkIdsPlugin.js +2 -1
- package/lib/ids/NaturalModuleIdsPlugin.js +1 -1
- package/lib/ids/OccurrenceChunkIdsPlugin.js +3 -2
- package/lib/ids/OccurrenceModuleIdsPlugin.js +1 -1
- package/lib/ids/SyncModuleIdsPlugin.js +1 -1
- package/lib/index.js +13 -3
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +113 -119
- package/lib/javascript/BasicEvaluatedExpression.js +2 -1
- package/lib/javascript/ChunkHelpers.js +1 -0
- package/lib/javascript/CommonJsChunkFormatPlugin.js +121 -136
- package/lib/javascript/EnableChunkLoadingPlugin.js +6 -3
- package/lib/javascript/JavascriptGenerator.js +14 -2
- package/lib/javascript/JavascriptModulesPlugin.js +68 -27
- package/lib/javascript/JavascriptParser.js +117 -76
- package/lib/javascript/JavascriptParserHelpers.js +41 -41
- package/lib/javascript/StartupHelpers.js +17 -17
- package/lib/json/JsonGenerator.js +4 -2
- package/lib/json/JsonModulesPlugin.js +2 -2
- package/lib/json/JsonParser.js +1 -1
- package/lib/library/AbstractLibraryPlugin.js +6 -2
- package/lib/library/AssignLibraryPlugin.js +21 -6
- package/lib/library/EnableLibraryPlugin.js +23 -3
- package/lib/library/UmdLibraryPlugin.js +15 -6
- package/lib/logging/createConsoleLogger.js +3 -3
- package/lib/logging/runtime.js +9 -9
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/RequireChunkLoadingRuntimeModule.js +4 -22
- package/lib/node/nodeConsole.js +4 -2
- package/lib/optimize/AggressiveMergingPlugin.js +45 -46
- package/lib/optimize/AggressiveSplittingPlugin.js +13 -12
- package/lib/optimize/ConcatenatedModule.js +227 -57
- package/lib/optimize/EnsureChunkConditionsPlugin.js +58 -58
- package/lib/optimize/FlagIncludedChunksPlugin.js +3 -1
- package/lib/optimize/InnerGraph.js +115 -112
- package/lib/optimize/InnerGraphPlugin.js +2 -2
- package/lib/optimize/LimitChunkCountPlugin.js +4 -2
- package/lib/optimize/MangleExportsPlugin.js +4 -3
- package/lib/optimize/MergeDuplicateChunksPlugin.js +80 -81
- package/lib/optimize/MinChunkSizePlugin.js +6 -3
- package/lib/optimize/ModuleConcatenationPlugin.js +31 -22
- package/lib/optimize/RealContentHashPlugin.js +26 -20
- package/lib/optimize/RemoveEmptyChunksPlugin.js +2 -1
- package/lib/optimize/RemoveParentModulesPlugin.js +1 -0
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -2
- package/lib/optimize/SplitChunksPlugin.js +16 -13
- package/lib/rules/BasicEffectRulePlugin.js +4 -2
- package/lib/rules/BasicMatcherRulePlugin.js +3 -1
- package/lib/rules/ObjectMatcherRulePlugin.js +3 -1
- package/lib/rules/RuleSetCompiler.js +19 -5
- package/lib/rules/UseEffectRulePlugin.js +17 -9
- package/lib/runtime/AsyncModuleRuntimeModule.js +64 -9
- package/lib/runtime/CreateFakeNamespaceObjectRuntimeModule.js +1 -1
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +214 -0
- package/lib/runtime/RuntimeIdRuntimeModule.js +2 -1
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +8 -7
- package/lib/schemes/FileUriPlugin.js +1 -1
- package/lib/schemes/HttpUriPlugin.js +27 -19
- package/lib/schemes/VirtualUrlPlugin.js +222 -0
- package/lib/serialization/AggregateErrorSerializer.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +5 -4
- package/lib/serialization/FileMiddleware.js +7 -4
- package/lib/serialization/ObjectMiddleware.js +14 -8
- package/lib/serialization/Serializer.js +5 -3
- package/lib/serialization/SerializerMiddleware.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +1 -1
- package/lib/sharing/ConsumeSharedPlugin.js +3 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +2 -2
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/ProvideSharedPlugin.js +3 -2
- package/lib/sharing/SharePlugin.js +2 -1
- package/lib/sharing/ShareRuntimeModule.js +3 -5
- package/lib/sharing/utils.js +34 -34
- package/lib/stats/DefaultStatsFactoryPlugin.js +49 -46
- package/lib/stats/DefaultStatsPresetPlugin.js +13 -13
- package/lib/stats/DefaultStatsPrinterPlugin.js +15 -9
- package/lib/stats/StatsFactory.js +6 -3
- package/lib/stats/StatsPrinter.js +6 -7
- package/lib/url/URLParserPlugin.js +266 -0
- package/lib/util/ArrayQueue.js +1 -1
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/Hash.js +2 -0
- package/lib/util/IterableHelpers.js +1 -1
- package/lib/util/LazyBucketSortedSet.js +2 -1
- package/lib/util/LazySet.js +11 -6
- package/lib/util/ParallelismFactorCalculator.js +1 -1
- package/lib/util/SetHelpers.js +3 -3
- package/lib/util/SortableSet.js +2 -2
- package/lib/util/StackedCacheMap.js +3 -1
- package/lib/util/StackedMap.js +2 -2
- package/lib/util/StringXor.js +1 -0
- package/lib/util/TupleSet.js +1 -0
- package/lib/util/URLAbsoluteSpecifier.js +1 -1
- package/lib/util/cleverMerge.js +95 -58
- package/lib/util/comparators.js +154 -127
- package/lib/util/compileBooleanMatcher.js +8 -3
- package/lib/util/concatenate.js +8 -7
- package/lib/util/conventions.js +72 -73
- package/lib/util/create-schema-validation.js +2 -1
- package/lib/util/createHash.js +10 -4
- package/lib/util/deprecation.js +69 -66
- package/lib/util/deterministicGrouping.js +4 -2
- package/lib/util/extractUrlAndGlobal.js +1 -1
- package/lib/util/findGraphRoots.js +2 -2
- package/lib/util/fs.js +30 -23
- package/lib/util/hash/md4.js +2 -2
- package/lib/util/hash/wasm-hash.js +4 -2
- package/lib/util/identifier.js +13 -12
- package/lib/util/internalSerializables.js +2 -0
- package/lib/util/magicComment.js +5 -5
- package/lib/util/processAsyncTree.js +1 -1
- package/lib/util/propertyAccess.js +1 -1
- package/lib/util/propertyName.js +1 -1
- package/lib/util/registerExternalSerializer.js +1 -2
- package/lib/util/removeBOM.js +1 -1
- package/lib/util/runtime.js +29 -21
- package/lib/util/semver.js +1 -1
- package/lib/util/serialization.js +3 -0
- package/lib/util/source.js +3 -2
- package/lib/validateSchema.js +1 -0
- package/lib/wasm/EnableWasmLoadingPlugin.js +6 -3
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +4 -1
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +46 -49
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +2 -3
- package/lib/wasm-sync/WebAssemblyInInitialChunkError.js +3 -2
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +3 -0
- package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -22
- package/lib/webpack.js +4 -5
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +1 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -24
- package/lib/webworker/WebWorkerTemplatePlugin.js +1 -0
- package/package.json +119 -113
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +17 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.d.ts +7 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +6 -0
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +77 -0
- package/types.d.ts +1243 -409
|
@@ -11,8 +11,12 @@ const HelperRuntimeModule = require("./HelperRuntimeModule");
|
|
|
11
11
|
/** @typedef {import("../Compilation")} Compilation */
|
|
12
12
|
|
|
13
13
|
class AsyncModuleRuntimeModule extends HelperRuntimeModule {
|
|
14
|
-
|
|
14
|
+
/**
|
|
15
|
+
* @param {boolean=} deferInterop if defer import is used.
|
|
16
|
+
*/
|
|
17
|
+
constructor(deferInterop = false) {
|
|
15
18
|
super("async module");
|
|
19
|
+
this._deferInterop = deferInterop;
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
/**
|
|
@@ -22,10 +26,20 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
|
|
|
22
26
|
const compilation = /** @type {Compilation} */ (this.compilation);
|
|
23
27
|
const { runtimeTemplate } = compilation;
|
|
24
28
|
const fn = RuntimeGlobals.asyncModule;
|
|
29
|
+
const defer = this._deferInterop;
|
|
25
30
|
return Template.asString([
|
|
26
|
-
'var
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
'var hasSymbol = typeof Symbol === "function";',
|
|
32
|
+
'var webpackQueues = hasSymbol ? Symbol("webpack queues") : "__webpack_queues__";',
|
|
33
|
+
`var webpackExports = ${
|
|
34
|
+
defer ? `${RuntimeGlobals.asyncModuleExportSymbol}= ` : ""
|
|
35
|
+
}hasSymbol ? Symbol("webpack exports") : "${RuntimeGlobals.exports}";`,
|
|
36
|
+
'var webpackError = hasSymbol ? Symbol("webpack error") : "__webpack_error__";',
|
|
37
|
+
defer
|
|
38
|
+
? `var webpackDone = ${RuntimeGlobals.asyncModuleDoneSymbol} = hasSymbol ? Symbol("webpack done") : "__webpack_done__";`
|
|
39
|
+
: "",
|
|
40
|
+
defer
|
|
41
|
+
? `var webpackDefer = ${RuntimeGlobals.makeDeferredNamespaceObjectSymbol} = hasSymbol ? Symbol("webpack defer") : "__webpack_defer__";`
|
|
42
|
+
: "",
|
|
29
43
|
`var resolveQueue = ${runtimeTemplate.basicFunction("queue", [
|
|
30
44
|
"if(queue && queue.d < 1) {",
|
|
31
45
|
Template.indent([
|
|
@@ -45,6 +59,39 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
|
|
|
45
59
|
`deps.map(${runtimeTemplate.basicFunction("dep", [
|
|
46
60
|
'if(dep !== null && typeof dep === "object") {',
|
|
47
61
|
Template.indent([
|
|
62
|
+
defer
|
|
63
|
+
? Template.asString([
|
|
64
|
+
"if(!dep[webpackQueues] && dep[webpackDefer]) {",
|
|
65
|
+
Template.indent([
|
|
66
|
+
"var asyncDeps = dep[webpackDefer];",
|
|
67
|
+
`var hasUnresolvedAsyncSubgraph = asyncDeps.some(${runtimeTemplate.basicFunction(
|
|
68
|
+
"id",
|
|
69
|
+
[
|
|
70
|
+
"var cache = __webpack_module_cache__[id];",
|
|
71
|
+
"return !cache || cache[webpackDone] === false;"
|
|
72
|
+
]
|
|
73
|
+
)});`,
|
|
74
|
+
"if (hasUnresolvedAsyncSubgraph) {",
|
|
75
|
+
Template.indent([
|
|
76
|
+
"var d = dep;",
|
|
77
|
+
"dep = {",
|
|
78
|
+
Template.indent([
|
|
79
|
+
"then(callback) {",
|
|
80
|
+
Template.indent([
|
|
81
|
+
"Promise.all(asyncDeps.map(__webpack_require__))",
|
|
82
|
+
`.then(${runtimeTemplate.returningFunction(
|
|
83
|
+
"callback(d)"
|
|
84
|
+
)});`
|
|
85
|
+
]),
|
|
86
|
+
"}"
|
|
87
|
+
]),
|
|
88
|
+
"};"
|
|
89
|
+
]),
|
|
90
|
+
"} else return dep;"
|
|
91
|
+
]),
|
|
92
|
+
"}"
|
|
93
|
+
])
|
|
94
|
+
: "",
|
|
48
95
|
"if(dep[webpackQueues]) return dep;",
|
|
49
96
|
"if(dep.then) {",
|
|
50
97
|
Template.indent([
|
|
@@ -58,6 +105,7 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
|
|
|
58
105
|
"resolveQueue(queue);"
|
|
59
106
|
])});`,
|
|
60
107
|
"var obj = {};",
|
|
108
|
+
defer ? "obj[webpackDefer] = false;" : "",
|
|
61
109
|
`obj[webpackQueues] = ${runtimeTemplate.expressionFunction(
|
|
62
110
|
"fn(queue)",
|
|
63
111
|
"fn"
|
|
@@ -92,11 +140,12 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
|
|
|
92
140
|
"fn"
|
|
93
141
|
)};`,
|
|
94
142
|
"module.exports = promise;",
|
|
95
|
-
`
|
|
143
|
+
`var handle = ${runtimeTemplate.basicFunction("deps", [
|
|
96
144
|
"currentDeps = wrapDeps(deps);",
|
|
97
145
|
"var fn;",
|
|
98
146
|
`var getResult = ${runtimeTemplate.returningFunction(
|
|
99
147
|
`currentDeps.map(${runtimeTemplate.basicFunction("d", [
|
|
148
|
+
defer ? "if(d[webpackDefer]) return d;" : "",
|
|
100
149
|
"if(d[webpackError]) throw d[webpackError];",
|
|
101
150
|
"return d[webpackExports];"
|
|
102
151
|
])})`
|
|
@@ -114,16 +163,22 @@ class AsyncModuleRuntimeModule extends HelperRuntimeModule {
|
|
|
114
163
|
"q"
|
|
115
164
|
)};`,
|
|
116
165
|
`currentDeps.map(${runtimeTemplate.expressionFunction(
|
|
117
|
-
|
|
166
|
+
`${
|
|
167
|
+
defer ? "dep[webpackDefer]||" : ""
|
|
168
|
+
}dep[webpackQueues](fnQueue)`,
|
|
118
169
|
"dep"
|
|
119
170
|
)});`
|
|
120
171
|
]
|
|
121
172
|
)});`,
|
|
122
173
|
"return fn.r ? promise : getResult();"
|
|
123
|
-
])}
|
|
124
|
-
|
|
174
|
+
])}`,
|
|
175
|
+
`var done = ${runtimeTemplate.expressionFunction(
|
|
176
|
+
`(err ? reject(promise[webpackError] = err) : outerResolve(exports)), resolveQueue(queue)${
|
|
177
|
+
defer ? ", promise[webpackDone] = true" : ""
|
|
178
|
+
}`,
|
|
125
179
|
"err"
|
|
126
|
-
)}
|
|
180
|
+
)}`,
|
|
181
|
+
"body(handle, done);",
|
|
127
182
|
"queue && queue.d < 0 && (queue.d = 0);"
|
|
128
183
|
])};`
|
|
129
184
|
]);
|
|
@@ -49,7 +49,7 @@ class CreateFakeNamespaceObjectRuntimeModule extends HelperRuntimeModule {
|
|
|
49
49
|
`${RuntimeGlobals.makeNamespaceObject}(ns);`,
|
|
50
50
|
"var def = {};",
|
|
51
51
|
"leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];",
|
|
52
|
-
"for(var current = mode & 2 && value; typeof current == 'object' && !~leafPrototypes.indexOf(current); current = getProto(current)) {",
|
|
52
|
+
"for(var current = mode & 2 && value; (typeof current == 'object' || typeof current == 'function') && !~leafPrototypes.indexOf(current); current = getProto(current)) {",
|
|
53
53
|
Template.indent([
|
|
54
54
|
`Object.getOwnPropertyNames(current).forEach(${runtimeTemplate.expressionFunction(
|
|
55
55
|
`def[key] = ${runtimeTemplate.returningFunction("value[key]", "")}`,
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";
|
|
6
|
+
|
|
7
|
+
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
8
|
+
const Template = require("../Template");
|
|
9
|
+
const HelperRuntimeModule = require("./HelperRuntimeModule");
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {import("../Module").ExportsType} exportsType exports type
|
|
13
|
+
* @returns {string} mode
|
|
14
|
+
*/
|
|
15
|
+
function getMakeDeferredNamespaceModeFromExportsType(exportsType) {
|
|
16
|
+
if (exportsType === "namespace") return `/* ${exportsType} */ 0`;
|
|
17
|
+
if (exportsType === "default-only") return `/* ${exportsType} */ 1`;
|
|
18
|
+
if (exportsType === "default-with-named") return `/* ${exportsType} */ 2`;
|
|
19
|
+
if (exportsType === "dynamic") return `/* ${exportsType} */ 3`;
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @param {import("../ModuleTemplate").RuntimeTemplate} _runtimeTemplate runtimeTemplate
|
|
24
|
+
* @param {import("../Module").ExportsType} exportsType exportsType
|
|
25
|
+
* @param {string} moduleId moduleId
|
|
26
|
+
* @param {(import("../ChunkGraph").ModuleId | null)[]} asyncDepsIds asyncDepsIds
|
|
27
|
+
* @returns {string} function
|
|
28
|
+
*/
|
|
29
|
+
function getOptimizedDeferredModule(
|
|
30
|
+
_runtimeTemplate,
|
|
31
|
+
exportsType,
|
|
32
|
+
moduleId,
|
|
33
|
+
asyncDepsIds
|
|
34
|
+
) {
|
|
35
|
+
const isAsync = asyncDepsIds && asyncDepsIds.length;
|
|
36
|
+
const init = `${RuntimeGlobals.require}(${moduleId})${
|
|
37
|
+
isAsync ? `[${RuntimeGlobals.asyncModuleExportSymbol}]` : ""
|
|
38
|
+
}`;
|
|
39
|
+
const props = [
|
|
40
|
+
`/* ${exportsType} */ get a() {`,
|
|
41
|
+
// if exportsType is "namespace" we can generate the most optimized code,
|
|
42
|
+
// on the second access, we can avoid trigger the getter.
|
|
43
|
+
// we can also do this if exportsType is "dynamic" and there is a "__esModule" property on it.
|
|
44
|
+
exportsType === "namespace" || exportsType === "dynamic"
|
|
45
|
+
? Template.indent([
|
|
46
|
+
`var exports = ${init};`,
|
|
47
|
+
`${
|
|
48
|
+
exportsType === "dynamic" ? "if (exports.__esModule) " : ""
|
|
49
|
+
}Object.defineProperty(this, "a", { value: exports });`,
|
|
50
|
+
"return exports;"
|
|
51
|
+
])
|
|
52
|
+
: Template.indent([`return ${init};`]),
|
|
53
|
+
isAsync ? "}," : "}",
|
|
54
|
+
isAsync
|
|
55
|
+
? `[${
|
|
56
|
+
RuntimeGlobals.makeDeferredNamespaceObjectSymbol
|
|
57
|
+
}]: ${JSON.stringify(asyncDepsIds.filter(x => x !== null))}`
|
|
58
|
+
: ""
|
|
59
|
+
];
|
|
60
|
+
return Template.asString(["{", Template.indent(props), "}"]);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const strictModuleCache = [
|
|
64
|
+
"if (cachedModule && cachedModule.error === undefined) {",
|
|
65
|
+
Template.indent([
|
|
66
|
+
"var exports = cachedModule.exports;",
|
|
67
|
+
"if (mode == 0) return exports;",
|
|
68
|
+
`if (mode == 1) return ${RuntimeGlobals.createFakeNamespaceObject}(exports);`,
|
|
69
|
+
`if (mode == 2) return ${RuntimeGlobals.createFakeNamespaceObject}(exports, 2);`,
|
|
70
|
+
`if (mode == 3) return ${RuntimeGlobals.createFakeNamespaceObject}(exports, 6);` // 2 | 4
|
|
71
|
+
]),
|
|
72
|
+
"}"
|
|
73
|
+
];
|
|
74
|
+
const nonStrictModuleCache = [
|
|
75
|
+
"// optimization not applied when output.strictModuleErrorHandling is off"
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
class MakeDeferredNamespaceObjectRuntimeModule extends HelperRuntimeModule {
|
|
79
|
+
/**
|
|
80
|
+
* @param {boolean} hasAsyncRuntime if async module is used.
|
|
81
|
+
*/
|
|
82
|
+
constructor(hasAsyncRuntime) {
|
|
83
|
+
super("make deferred namespace object");
|
|
84
|
+
this.hasAsyncRuntime = hasAsyncRuntime;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @returns {string | null} runtime code
|
|
89
|
+
*/
|
|
90
|
+
generate() {
|
|
91
|
+
if (!this.compilation) return null;
|
|
92
|
+
const { runtimeTemplate } = this.compilation;
|
|
93
|
+
const fn = RuntimeGlobals.makeDeferredNamespaceObject;
|
|
94
|
+
const hasAsync = this.hasAsyncRuntime;
|
|
95
|
+
const strictError =
|
|
96
|
+
this.compilation.options.output.strictModuleErrorHandling;
|
|
97
|
+
const init = runtimeTemplate.supportsOptionalChaining()
|
|
98
|
+
? "init?.();"
|
|
99
|
+
: "if (init) init();";
|
|
100
|
+
return `${fn} = ${runtimeTemplate.basicFunction("moduleId, mode", [
|
|
101
|
+
"// mode: 0 => namespace (esm)",
|
|
102
|
+
"// mode: 1 => default-only (esm strict cjs)",
|
|
103
|
+
"// mode: 2 => default-with-named (esm-cjs compat)",
|
|
104
|
+
"// mode: 3 => dynamic (if exports has __esModule, then esm, otherwise default-with-named)",
|
|
105
|
+
"",
|
|
106
|
+
"var cachedModule = __webpack_module_cache__[moduleId];",
|
|
107
|
+
...(strictError ? strictModuleCache : nonStrictModuleCache),
|
|
108
|
+
"",
|
|
109
|
+
`var init = ${runtimeTemplate.basicFunction("", [
|
|
110
|
+
`ns = ${RuntimeGlobals.require}(moduleId);`,
|
|
111
|
+
hasAsync
|
|
112
|
+
? `if (${RuntimeGlobals.asyncModuleExportSymbol} in ns) ns = ns[${RuntimeGlobals.asyncModuleExportSymbol}];`
|
|
113
|
+
: "",
|
|
114
|
+
"init = null;",
|
|
115
|
+
"if (mode == 0 || mode == 3 && ns.__esModule && typeof ns === 'object') {",
|
|
116
|
+
Template.indent([
|
|
117
|
+
"delete handler.defineProperty;",
|
|
118
|
+
"delete handler.deleteProperty;",
|
|
119
|
+
"delete handler.set;",
|
|
120
|
+
"delete handler.get;",
|
|
121
|
+
"delete handler.has;",
|
|
122
|
+
"delete handler.ownKeys;",
|
|
123
|
+
"delete handler.getOwnPropertyDescriptor;"
|
|
124
|
+
]),
|
|
125
|
+
"} else if (mode == 1) {",
|
|
126
|
+
Template.indent([
|
|
127
|
+
`ns = ${RuntimeGlobals.createFakeNamespaceObject}(ns);`
|
|
128
|
+
]),
|
|
129
|
+
"} else if (mode == 2) {",
|
|
130
|
+
Template.indent([
|
|
131
|
+
`ns = ${RuntimeGlobals.createFakeNamespaceObject}(ns, 2);`
|
|
132
|
+
]),
|
|
133
|
+
"} else if (mode == 3) {",
|
|
134
|
+
Template.indent([
|
|
135
|
+
`ns = ${RuntimeGlobals.createFakeNamespaceObject}(ns, 6);`
|
|
136
|
+
]),
|
|
137
|
+
"}"
|
|
138
|
+
])};`,
|
|
139
|
+
"",
|
|
140
|
+
`var ns = ${
|
|
141
|
+
strictError ? "" : "cachedModule && cachedModule.exports || "
|
|
142
|
+
}__webpack_module_deferred_exports__[moduleId] || (__webpack_module_deferred_exports__[moduleId] = { __proto__: null });`,
|
|
143
|
+
"var handler = {",
|
|
144
|
+
Template.indent([
|
|
145
|
+
"__proto__: null,",
|
|
146
|
+
`get: ${runtimeTemplate.basicFunction("_, name", [
|
|
147
|
+
"switch (name) {",
|
|
148
|
+
Template.indent([
|
|
149
|
+
'case "__esModule": return true;',
|
|
150
|
+
'case Symbol.toStringTag: return "Deferred Module";',
|
|
151
|
+
'case "then": return undefined;'
|
|
152
|
+
]),
|
|
153
|
+
"}",
|
|
154
|
+
init,
|
|
155
|
+
"return ns[name];"
|
|
156
|
+
])},`,
|
|
157
|
+
`has: ${runtimeTemplate.basicFunction("_, name", [
|
|
158
|
+
"switch (name) {",
|
|
159
|
+
Template.indent(
|
|
160
|
+
[
|
|
161
|
+
'case "__esModule":',
|
|
162
|
+
"case Symbol.toStringTag:",
|
|
163
|
+
hasAsync
|
|
164
|
+
? `case ${RuntimeGlobals.makeDeferredNamespaceObjectSymbol}:`
|
|
165
|
+
: "",
|
|
166
|
+
Template.indent("return true;"),
|
|
167
|
+
'case "then":',
|
|
168
|
+
Template.indent("return false;")
|
|
169
|
+
].filter(Boolean)
|
|
170
|
+
),
|
|
171
|
+
"}",
|
|
172
|
+
init,
|
|
173
|
+
"return name in ns;"
|
|
174
|
+
])},`,
|
|
175
|
+
`ownKeys: ${runtimeTemplate.basicFunction("", [
|
|
176
|
+
init,
|
|
177
|
+
`var keys = Reflect.ownKeys(ns).filter(${runtimeTemplate.expressionFunction('x !== "then"', "x")}).concat([Symbol.toStringTag]);`,
|
|
178
|
+
"return keys;"
|
|
179
|
+
])},`,
|
|
180
|
+
`getOwnPropertyDescriptor: ${runtimeTemplate.basicFunction("_, name", [
|
|
181
|
+
"switch (name) {",
|
|
182
|
+
Template.indent([
|
|
183
|
+
'case "__esModule": return { value: true, configurable: !!mode };',
|
|
184
|
+
'case Symbol.toStringTag: return { value: "Deferred Module", configurable: !!mode };',
|
|
185
|
+
'case "then": return undefined;'
|
|
186
|
+
]),
|
|
187
|
+
"}",
|
|
188
|
+
init,
|
|
189
|
+
"var desc = Reflect.getOwnPropertyDescriptor(ns, name);",
|
|
190
|
+
'if (mode == 2 && name == "default" && !desc) {',
|
|
191
|
+
Template.indent("desc = { value: ns, configurable: true };"),
|
|
192
|
+
"}",
|
|
193
|
+
"return desc;"
|
|
194
|
+
])},`,
|
|
195
|
+
`defineProperty: ${runtimeTemplate.basicFunction("_, name", [
|
|
196
|
+
init,
|
|
197
|
+
// Note: This behavior does not match the spec one, but since webpack does not do it either
|
|
198
|
+
// for a normal Module Namespace object (in MakeNamespaceObjectRuntimeModule), let's keep it simple.
|
|
199
|
+
"return false;"
|
|
200
|
+
])},`,
|
|
201
|
+
`deleteProperty: ${runtimeTemplate.returningFunction("false")},`,
|
|
202
|
+
`set: ${runtimeTemplate.returningFunction("false")},`
|
|
203
|
+
]),
|
|
204
|
+
"}",
|
|
205
|
+
// we don't fully emulate ES Module semantics in this Proxy to align with normal webpack esm namespace object.
|
|
206
|
+
"return new Proxy(ns, handler);"
|
|
207
|
+
])};`;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
module.exports = MakeDeferredNamespaceObjectRuntimeModule;
|
|
212
|
+
module.exports.getMakeDeferredNamespaceModeFromExportsType =
|
|
213
|
+
getMakeDeferredNamespaceModeFromExportsType;
|
|
214
|
+
module.exports.getOptimizedDeferredModule = getOptimizedDeferredModule;
|
|
@@ -22,8 +22,9 @@ class RuntimeIdRuntimeModule extends RuntimeModule {
|
|
|
22
22
|
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
|
23
23
|
const chunk = /** @type {Chunk} */ (this.chunk);
|
|
24
24
|
const runtime = chunk.runtime;
|
|
25
|
-
if (typeof runtime !== "string")
|
|
25
|
+
if (typeof runtime !== "string") {
|
|
26
26
|
throw new Error("RuntimeIdRuntimeModule must be in a single runtime");
|
|
27
|
+
}
|
|
27
28
|
const id = chunkGraph.getRuntimeId(runtime);
|
|
28
29
|
return `${RuntimeGlobals.runtimeId} = ${JSON.stringify(id)};`;
|
|
29
30
|
}
|
|
@@ -28,9 +28,9 @@ class StartupChunkDependenciesRuntimeModule extends RuntimeModule {
|
|
|
28
28
|
generate() {
|
|
29
29
|
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
|
30
30
|
const chunk = /** @type {Chunk} */ (this.chunk);
|
|
31
|
-
const chunkIds =
|
|
32
|
-
chunkGraph.getChunkEntryDependentChunksIterable(chunk)
|
|
33
|
-
|
|
31
|
+
const chunkIds = [
|
|
32
|
+
...chunkGraph.getChunkEntryDependentChunksIterable(chunk)
|
|
33
|
+
].map(chunk => chunk.id);
|
|
34
34
|
const compilation = /** @type {Compilation} */ (this.compilation);
|
|
35
35
|
const { runtimeTemplate } = compilation;
|
|
36
36
|
return Template.asString([
|
|
@@ -38,11 +38,12 @@ class StartupChunkDependenciesRuntimeModule extends RuntimeModule {
|
|
|
38
38
|
`${RuntimeGlobals.startup} = ${runtimeTemplate.basicFunction(
|
|
39
39
|
"",
|
|
40
40
|
!this.asyncChunkLoading
|
|
41
|
-
?
|
|
42
|
-
.map(
|
|
41
|
+
? [
|
|
42
|
+
...chunkIds.map(
|
|
43
43
|
id => `${RuntimeGlobals.ensureChunk}(${JSON.stringify(id)});`
|
|
44
|
-
)
|
|
45
|
-
|
|
44
|
+
),
|
|
45
|
+
"return next();"
|
|
46
|
+
]
|
|
46
47
|
: chunkIds.length === 1
|
|
47
48
|
? `return ${RuntimeGlobals.ensureChunk}(${JSON.stringify(
|
|
48
49
|
chunkIds[0]
|
|
@@ -6,13 +6,17 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const EventEmitter = require("events");
|
|
9
|
-
const {
|
|
10
|
-
const {
|
|
11
|
-
|
|
9
|
+
const { basename, extname } = require("path");
|
|
10
|
+
const {
|
|
11
|
+
// eslint-disable-next-line n/no-unsupported-features/node-builtins
|
|
12
|
+
createBrotliDecompress,
|
|
13
|
+
createGunzip,
|
|
14
|
+
createInflate
|
|
15
|
+
} = require("zlib");
|
|
12
16
|
const NormalModule = require("../NormalModule");
|
|
13
17
|
const createSchemaValidation = require("../util/create-schema-validation");
|
|
14
18
|
const createHash = require("../util/createHash");
|
|
15
|
-
const {
|
|
19
|
+
const { dirname, join, mkdirp } = require("../util/fs");
|
|
16
20
|
const memoize = require("../util/memoize");
|
|
17
21
|
|
|
18
22
|
/** @typedef {import("http").IncomingMessage} IncomingMessage */
|
|
@@ -32,7 +36,7 @@ const getHttps = memoize(() => require("https"));
|
|
|
32
36
|
|
|
33
37
|
/**
|
|
34
38
|
* @param {typeof import("http") | typeof import("https")} request request
|
|
35
|
-
* @param {string |
|
|
39
|
+
* @param {string | URL | undefined} proxy proxy
|
|
36
40
|
* @returns {(url: URL, requestOptions: RequestOptions, callback: (incomingMessage: IncomingMessage) => void) => EventEmitter} fn
|
|
37
41
|
*/
|
|
38
42
|
const proxyFetch = (request, proxy) => (url, options, callback) => {
|
|
@@ -85,7 +89,7 @@ const proxyFetch = (request, proxy) => (url, options, callback) => {
|
|
|
85
89
|
let inProgressWrite;
|
|
86
90
|
|
|
87
91
|
const validate = createSchemaValidation(
|
|
88
|
-
require("../../schemas/plugins/schemes/HttpUriPlugin.check
|
|
92
|
+
require("../../schemas/plugins/schemes/HttpUriPlugin.check"),
|
|
89
93
|
() => require("../../schemas/plugins/schemes/HttpUriPlugin.json"),
|
|
90
94
|
{
|
|
91
95
|
name: "Http Uri Plugin",
|
|
@@ -210,8 +214,9 @@ class Lockfile {
|
|
|
210
214
|
static parse(content) {
|
|
211
215
|
// TODO handle merge conflicts
|
|
212
216
|
const data = JSON.parse(content);
|
|
213
|
-
if (data.version !== 1)
|
|
217
|
+
if (data.version !== 1) {
|
|
214
218
|
throw new Error(`Unsupported lockfile version ${data.version}`);
|
|
219
|
+
}
|
|
215
220
|
const lockfile = new Lockfile();
|
|
216
221
|
for (const key of Object.keys(data)) {
|
|
217
222
|
if (key === "version") continue;
|
|
@@ -234,16 +239,15 @@ class Lockfile {
|
|
|
234
239
|
*/
|
|
235
240
|
toString() {
|
|
236
241
|
let str = "{\n";
|
|
237
|
-
const entries =
|
|
238
|
-
a < b ? -1 : 1
|
|
239
|
-
);
|
|
242
|
+
const entries = [...this.entries].sort(([a], [b]) => (a < b ? -1 : 1));
|
|
240
243
|
for (const [key, entry] of entries) {
|
|
241
244
|
if (typeof entry === "string") {
|
|
242
245
|
str += ` ${JSON.stringify(key)}: ${JSON.stringify(entry)},\n`;
|
|
243
246
|
} else {
|
|
244
247
|
str += ` ${JSON.stringify(key)}: { `;
|
|
245
|
-
if (entry.resolved !== key)
|
|
248
|
+
if (entry.resolved !== key) {
|
|
246
249
|
str += `"resolved": ${JSON.stringify(entry.resolved)}, `;
|
|
250
|
+
}
|
|
247
251
|
str += `"integrity": ${JSON.stringify(
|
|
248
252
|
entry.integrity
|
|
249
253
|
)}, "contentType": ${JSON.stringify(entry.contentType)} },\n`;
|
|
@@ -330,8 +334,9 @@ const cachedWithKey = (fn, forceFn = fn) => {
|
|
|
330
334
|
const resultFn = (arg, callback) => {
|
|
331
335
|
const cacheEntry = cache.get(arg);
|
|
332
336
|
if (cacheEntry !== undefined) {
|
|
333
|
-
if (cacheEntry.result !== undefined)
|
|
337
|
+
if (cacheEntry.result !== undefined) {
|
|
334
338
|
return callback(null, cacheEntry.result);
|
|
339
|
+
}
|
|
335
340
|
if (cacheEntry.error !== undefined) return callback(cacheEntry.error);
|
|
336
341
|
if (cacheEntry.callbacks === undefined) cacheEntry.callbacks = [callback];
|
|
337
342
|
else cacheEntry.callbacks.push(callback);
|
|
@@ -361,8 +366,9 @@ const cachedWithKey = (fn, forceFn = fn) => {
|
|
|
361
366
|
resultFn.force = (arg, callback) => {
|
|
362
367
|
const cacheEntry = cache.get(arg);
|
|
363
368
|
if (cacheEntry !== undefined && cacheEntry.force) {
|
|
364
|
-
if (cacheEntry.result !== undefined)
|
|
369
|
+
if (cacheEntry.result !== undefined) {
|
|
365
370
|
return callback(null, cacheEntry.result);
|
|
371
|
+
}
|
|
366
372
|
if (cacheEntry.error !== undefined) return callback(cacheEntry.error);
|
|
367
373
|
if (cacheEntry.callbacks === undefined) cacheEntry.callbacks = [callback];
|
|
368
374
|
else cacheEntry.callbacks.push(callback);
|
|
@@ -531,7 +537,7 @@ class HttpUriPlugin {
|
|
|
531
537
|
(err, s) => {
|
|
532
538
|
if (err) return callback(err);
|
|
533
539
|
const lockfile = buffer
|
|
534
|
-
? Lockfile.parse(buffer.toString("
|
|
540
|
+
? Lockfile.parse(buffer.toString("utf8"))
|
|
535
541
|
: new Lockfile();
|
|
536
542
|
lockfileCache = {
|
|
537
543
|
lockfile,
|
|
@@ -611,8 +617,9 @@ class HttpUriPlugin {
|
|
|
611
617
|
const storeResult = (lockfile, url, result, callback) => {
|
|
612
618
|
if (result.storeLock) {
|
|
613
619
|
storeLockEntry(lockfile, url, result.entry);
|
|
614
|
-
if (!cacheLocation || !result.content)
|
|
620
|
+
if (!cacheLocation || !result.content) {
|
|
615
621
|
return callback(null, result);
|
|
622
|
+
}
|
|
616
623
|
const key = getCacheKey(result.entry.resolved);
|
|
617
624
|
const filePath = join(intermediateFs, cacheLocation, key);
|
|
618
625
|
mkdirp(intermediateFs, dirname(intermediateFs, filePath), err => {
|
|
@@ -831,7 +838,7 @@ class HttpUriPlugin {
|
|
|
831
838
|
new Error(
|
|
832
839
|
`${url} request status code = ${
|
|
833
840
|
res.statusCode
|
|
834
|
-
}\n${content.toString("
|
|
841
|
+
}\n${content.toString("utf8")}`
|
|
835
842
|
)
|
|
836
843
|
);
|
|
837
844
|
}
|
|
@@ -938,8 +945,9 @@ class HttpUriPlugin {
|
|
|
938
945
|
const result =
|
|
939
946
|
/** @type {ResolveContentResult} */
|
|
940
947
|
(_result);
|
|
941
|
-
if (!result.storeLock || entryTag === "ignore")
|
|
948
|
+
if (!result.storeLock || entryTag === "ignore") {
|
|
942
949
|
return callback(null, result);
|
|
950
|
+
}
|
|
943
951
|
if (frozen) {
|
|
944
952
|
return callback(
|
|
945
953
|
new Error(
|
|
@@ -1058,7 +1066,7 @@ Remove this line from the lockfile to force upgrading.`
|
|
|
1058
1066
|
let isEolChanged = false;
|
|
1059
1067
|
try {
|
|
1060
1068
|
contentWithChangedEol = Buffer.from(
|
|
1061
|
-
content.toString("
|
|
1069
|
+
content.toString("utf8").replace(/\r\n/g, "\n")
|
|
1062
1070
|
);
|
|
1063
1071
|
isEolChanged = verifyIntegrity(
|
|
1064
1072
|
contentWithChangedEol,
|
|
@@ -1245,7 +1253,7 @@ Run build with un-frozen lockfile to automatically fix lockfile.`
|
|
|
1245
1253
|
return callback(err);
|
|
1246
1254
|
}
|
|
1247
1255
|
const lockfile = buffer
|
|
1248
|
-
? Lockfile.parse(buffer.toString("
|
|
1256
|
+
? Lockfile.parse(buffer.toString("utf8"))
|
|
1249
1257
|
: new Lockfile();
|
|
1250
1258
|
for (const [key, value] of /** @type {LockfileUpdates} */ (
|
|
1251
1259
|
lockfileUpdates
|