webpack 5.83.1 → 5.85.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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/README.md +2 -2
- package/lib/AsyncDependenciesBlock.js +2 -2
- package/lib/AutomaticPrefetchPlugin.js +1 -0
- package/lib/BannerPlugin.js +4 -0
- package/lib/CacheFacade.js +4 -0
- package/lib/ChunkGroup.js +5 -1
- package/lib/CleanPlugin.js +30 -7
- package/lib/CompatibilityPlugin.js +4 -3
- package/lib/Compilation.js +3 -3
- package/lib/Compiler.js +1 -1
- package/lib/ContextModule.js +3 -3
- package/lib/ContextModuleFactory.js +1 -1
- package/lib/DefinePlugin.js +11 -2
- package/lib/DllEntryPlugin.js +5 -0
- package/lib/DllModule.js +1 -1
- package/lib/DllModuleFactory.js +1 -1
- package/lib/EvalSourceMapDevToolPlugin.js +3 -1
- package/lib/HookWebpackError.js +1 -1
- package/lib/IgnoreErrorModuleFactory.js +1 -1
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +21 -9
- package/lib/ModuleFactory.js +1 -1
- package/lib/ModuleTypeConstants.js +2 -1
- package/lib/NormalModuleFactory.js +1 -1
- package/lib/NormalModuleReplacementPlugin.js +4 -2
- package/lib/NullFactory.js +1 -1
- package/lib/PrefetchPlugin.js +4 -0
- package/lib/RecordIdsPlugin.js +4 -4
- package/lib/RuntimeModule.js +5 -5
- package/lib/RuntimePlugin.js +4 -0
- package/lib/RuntimeTemplate.js +7 -7
- package/lib/SelfModuleFactory.js +12 -0
- package/lib/SourceMapDevToolPlugin.js +9 -2
- package/lib/Template.js +3 -2
- package/lib/UseStrictPlugin.js +4 -0
- package/lib/WarnDeprecatedOptionPlugin.js +7 -0
- package/lib/WatchIgnorePlugin.js +4 -0
- package/lib/WebpackOptionsApply.js +2 -1
- package/lib/asset/AssetGenerator.js +7 -2
- package/lib/asset/AssetModulesPlugin.js +7 -1
- package/lib/asset/AssetParser.js +4 -1
- package/lib/asset/RawDataUrlModule.js +5 -3
- package/lib/async-modules/InferAsyncModulesPlugin.js +1 -1
- package/lib/cache/PackFileCacheStrategy.js +7 -1
- package/lib/config/browserslistTargetHandler.js +3 -3
- package/lib/config/defaults.js +240 -73
- package/lib/config/normalization.js +104 -71
- package/lib/config/target.js +37 -10
- package/lib/container/ContainerEntryModule.js +4 -0
- package/lib/container/ContainerEntryModuleFactory.js +1 -1
- package/lib/container/FallbackDependency.js +7 -0
- package/lib/container/FallbackItemDependency.js +3 -0
- package/lib/container/FallbackModule.js +5 -1
- package/lib/container/FallbackModuleFactory.js +1 -1
- package/lib/container/RemoteModule.js +4 -0
- package/lib/container/RemoteRuntimeModule.js +2 -1
- package/lib/container/RemoteToExternalDependency.js +3 -0
- package/lib/css/CssParser.js +168 -73
- package/lib/debug/ProfilingPlugin.js +11 -0
- package/lib/dependencies/AMDDefineDependency.js +12 -6
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +8 -2
- package/lib/dependencies/AMDPlugin.js +7 -0
- package/lib/dependencies/AMDRequireArrayDependency.js +5 -0
- package/lib/dependencies/AMDRequireContextDependency.js +6 -0
- package/lib/dependencies/AMDRequireDependenciesBlock.js +6 -0
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +8 -2
- package/lib/dependencies/AMDRequireDependency.js +8 -1
- package/lib/dependencies/AMDRequireItemDependency.js +6 -0
- package/lib/dependencies/CachedConstDependency.js +6 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +11 -0
- package/lib/dependencies/CommonJsExportsDependency.js +8 -0
- package/lib/dependencies/CommonJsExportsParserPlugin.js +2 -2
- package/lib/dependencies/CommonJsFullRequireDependency.js +2 -1
- package/lib/dependencies/CommonJsPlugin.js +28 -12
- package/lib/dependencies/CommonJsRequireContextDependency.js +8 -0
- package/lib/dependencies/CommonJsRequireDependency.js +7 -0
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +8 -0
- package/lib/dependencies/ConstDependency.js +2 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -3
- package/lib/dependencies/CreateScriptUrlDependency.js +2 -1
- package/lib/dependencies/CriticalDependencyWarning.js +3 -0
- package/lib/dependencies/CssImportDependency.js +2 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +2 -1
- package/lib/dependencies/CssUrlDependency.js +12 -2
- package/lib/dependencies/DelegatedSourceDependency.js +3 -0
- package/lib/dependencies/ExportsInfoDependency.js +6 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +2 -1
- package/lib/dependencies/HarmonyAcceptImportDependency.js +3 -0
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +16 -0
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +12 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +3 -0
- package/lib/dependencies/HarmonyExportExpressionDependency.js +8 -0
- package/lib/dependencies/HarmonyExportHeaderDependency.js +5 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +2 -1
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +4 -0
- package/lib/dependencies/HarmonyExports.js +3 -1
- package/lib/dependencies/HarmonyImportDependency.js +2 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +18 -5
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +6 -0
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +86 -6
- package/lib/dependencies/HarmonyModulesPlugin.js +12 -0
- package/lib/dependencies/ImportContextDependency.js +6 -0
- package/lib/dependencies/ImportDependency.js +2 -1
- package/lib/dependencies/ImportEagerDependency.js +2 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +32 -13
- package/lib/dependencies/ImportMetaContextPlugin.js +7 -0
- package/lib/dependencies/ImportMetaHotAcceptDependency.js +6 -0
- package/lib/dependencies/ImportMetaHotDeclineDependency.js +6 -0
- package/lib/dependencies/ImportParserPlugin.js +5 -0
- package/lib/dependencies/ImportPlugin.js +7 -0
- package/lib/dependencies/ImportWeakDependency.js +2 -1
- package/lib/dependencies/LocalModule.js +16 -0
- package/lib/dependencies/LocalModuleDependency.js +7 -0
- package/lib/dependencies/LocalModulesHelpers.js +18 -0
- package/lib/dependencies/ModuleHotAcceptDependency.js +6 -0
- package/lib/dependencies/ModuleHotDeclineDependency.js +6 -0
- package/lib/dependencies/PrefetchDependency.js +3 -0
- package/lib/dependencies/ProvidedDependency.js +2 -1
- package/lib/dependencies/PureExpressionDependency.js +2 -1
- package/lib/dependencies/RequireContextDependency.js +6 -0
- package/lib/dependencies/RequireContextPlugin.js +7 -0
- package/lib/dependencies/RequireEnsureDependenciesBlock.js +4 -0
- package/lib/dependencies/RequireEnsureDependency.js +8 -2
- package/lib/dependencies/RequireEnsureItemDependency.js +3 -0
- package/lib/dependencies/RequireEnsurePlugin.js +14 -0
- package/lib/dependencies/RequireHeaderDependency.js +5 -1
- package/lib/dependencies/RequireIncludeDependency.js +5 -0
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +3 -0
- package/lib/dependencies/RequireIncludePlugin.js +14 -0
- package/lib/dependencies/RequireResolveContextDependency.js +8 -0
- package/lib/dependencies/RequireResolveDependency.js +6 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +4 -0
- package/lib/dependencies/SystemPlugin.js +10 -1
- package/lib/dependencies/URLDependency.js +3 -2
- package/lib/dependencies/URLPlugin.js +7 -5
- package/lib/dependencies/UnsupportedDependency.js +5 -0
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +6 -0
- package/lib/dependencies/WebpackIsIncludedDependency.js +5 -0
- package/lib/dependencies/WorkerDependency.js +2 -1
- package/lib/dependencies/WorkerPlugin.js +30 -3
- package/lib/dependencies/getFunctionExpression.js +7 -0
- package/lib/esm/ExportWebpackRequireRuntimeModule.js +2 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +15 -7
- package/lib/esm/ModuleChunkLoadingPlugin.js +9 -0
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +14 -9
- package/lib/hmr/LazyCompilationPlugin.js +1 -1
- package/lib/ids/ChunkModuleIdRangePlugin.js +11 -0
- package/lib/ids/DeterministicChunkIdsPlugin.js +11 -2
- package/lib/ids/DeterministicModuleIdsPlugin.js +11 -7
- package/lib/ids/HashedModuleIdsPlugin.js +8 -1
- package/lib/ids/IdHelpers.js +6 -0
- package/lib/ids/NamedChunkIdsPlugin.js +13 -1
- package/lib/ids/NamedModuleIdsPlugin.js +14 -3
- package/lib/ids/OccurrenceChunkIdsPlugin.js +6 -2
- package/lib/ids/SyncModuleIdsPlugin.js +2 -2
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +3 -3
- package/lib/javascript/BasicEvaluatedExpression.js +11 -1
- package/lib/javascript/ChunkHelpers.js +2 -2
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -1
- package/lib/javascript/EnableChunkLoadingPlugin.js +4 -0
- package/lib/javascript/JavascriptModulesPlugin.js +36 -31
- package/lib/javascript/JavascriptParser.js +586 -192
- package/lib/javascript/StartupHelpers.js +2 -2
- package/lib/json/JsonGenerator.js +7 -5
- package/lib/json/JsonParser.js +1 -1
- package/lib/library/AbstractLibraryPlugin.js +4 -0
- package/lib/library/AssignLibraryPlugin.js +6 -4
- package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
- package/lib/library/ModuleLibraryPlugin.js +6 -3
- package/lib/library/SystemLibraryPlugin.js +1 -0
- package/lib/library/UmdLibraryPlugin.js +4 -0
- package/lib/node/CommonJsChunkLoadingPlugin.js +17 -2
- package/lib/node/NodeTemplatePlugin.js +10 -2
- package/lib/node/NodeWatchFileSystem.js +1 -1
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +6 -3
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +8 -0
- package/lib/node/ReadFileCompileWasmPlugin.js +19 -2
- package/lib/node/RequireChunkLoadingRuntimeModule.js +6 -3
- package/lib/optimize/ConcatenatedModule.js +1 -1
- package/lib/optimize/InnerGraphPlugin.js +11 -4
- package/lib/runtime/AsyncModuleRuntimeModule.js +1 -1
- package/lib/runtime/AutoPublicPathRuntimeModule.js +5 -1
- package/lib/runtime/BaseUriRuntimeModule.js +5 -1
- package/lib/runtime/EnsureChunkRuntimeModule.js +3 -0
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +35 -16
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
- package/lib/runtime/LoadScriptRuntimeModule.js +1 -1
- package/lib/runtime/PublicPathRuntimeModule.js +5 -0
- package/lib/runtime/StartupChunkDependenciesPlugin.js +15 -0
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +4 -1
- package/lib/runtime/StartupEntrypointRuntimeModule.js +8 -5
- package/lib/serialization/ArraySerializer.js +22 -6
- package/lib/serialization/BinaryMiddleware.js +21 -0
- package/lib/serialization/DateObjectSerializer.js +15 -4
- package/lib/serialization/ErrorObjectSerializer.js +20 -8
- package/lib/serialization/FileMiddleware.js +17 -0
- package/lib/serialization/MapObjectSerializer.js +24 -8
- package/lib/serialization/NullPrototypeObjectSerializer.js +25 -8
- package/lib/serialization/ObjectMiddleware.js +23 -0
- package/lib/serialization/PlainObjectSerializer.js +23 -12
- package/lib/serialization/RegExpObjectSerializer.js +16 -5
- package/lib/serialization/SetObjectSerializer.js +21 -6
- package/lib/sharing/ProvideSharedModuleFactory.js +1 -1
- package/lib/sharing/ShareRuntimeModule.js +1 -1
- package/lib/util/createHash.js +1 -1
- package/lib/util/makeSerializable.js +7 -0
- package/lib/util/serialization.js +10 -0
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -0
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +9 -1
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +13 -3
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +19 -2
- package/lib/wasm-async/AsyncWebAssemblyParser.js +3 -0
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +25 -1
- package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +14 -5
- package/lib/wasm-sync/WebAssemblyGenerator.js +18 -5
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +12 -1
- package/lib/wasm-sync/WebAssemblyParser.js +9 -2
- package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
- package/lib/web/FetchCompileAsyncWasmPlugin.js +9 -0
- package/lib/web/FetchCompileWasmPlugin.js +19 -2
- package/lib/web/JsonpChunkLoadingPlugin.js +9 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +4 -1
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +9 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -2
- package/package.json +3 -3
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +12 -0
- package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
- package/schemas/plugins/SourceMapDevToolPlugin.json +4 -0
- package/types.d.ts +655 -290
package/lib/RuntimeTemplate.js
CHANGED
@@ -429,7 +429,7 @@ class RuntimeTemplate {
|
|
429
429
|
);
|
430
430
|
}
|
431
431
|
runtimeRequirements.add(RuntimeGlobals.require);
|
432
|
-
return
|
432
|
+
return `${RuntimeGlobals.require}(${this.moduleId({
|
433
433
|
module,
|
434
434
|
chunkGraph,
|
435
435
|
request,
|
@@ -625,7 +625,7 @@ class RuntimeTemplate {
|
|
625
625
|
)})`;
|
626
626
|
} else {
|
627
627
|
runtimeRequirements.add(RuntimeGlobals.require);
|
628
|
-
appending = `.then(
|
628
|
+
appending = `.then(${RuntimeGlobals.require}.bind(${RuntimeGlobals.require}, ${comment}${idExpr}))`;
|
629
629
|
}
|
630
630
|
break;
|
631
631
|
case "dynamic":
|
@@ -651,7 +651,7 @@ class RuntimeTemplate {
|
|
651
651
|
)})`;
|
652
652
|
} else {
|
653
653
|
runtimeRequirements.add(RuntimeGlobals.require);
|
654
|
-
appending = `.then(
|
654
|
+
appending = `.then(${RuntimeGlobals.require}.bind(${RuntimeGlobals.require}, ${comment}${idExpr}))`;
|
655
655
|
}
|
656
656
|
appending += `.then(${this.returningFunction(
|
657
657
|
`${RuntimeGlobals.createFakeNamespaceObject}(m, ${fakeType})`,
|
@@ -666,7 +666,7 @@ class RuntimeTemplate {
|
|
666
666
|
`${header}return ${returnExpression};`
|
667
667
|
)})`;
|
668
668
|
} else {
|
669
|
-
appending = `.then(${RuntimeGlobals.createFakeNamespaceObject}.bind(
|
669
|
+
appending = `.then(${RuntimeGlobals.createFakeNamespaceObject}.bind(${RuntimeGlobals.require}, ${comment}${idExpr}, ${fakeType}))`;
|
670
670
|
}
|
671
671
|
}
|
672
672
|
break;
|
@@ -773,7 +773,7 @@ class RuntimeTemplate {
|
|
773
773
|
originModule.buildMeta.strictHarmonyModule
|
774
774
|
);
|
775
775
|
runtimeRequirements.add(RuntimeGlobals.require);
|
776
|
-
const importContent = `/* harmony import */ ${optDeclaration}${importVar} =
|
776
|
+
const importContent = `/* harmony import */ ${optDeclaration}${importVar} = ${RuntimeGlobals.require}(${moduleId});\n`;
|
777
777
|
|
778
778
|
if (exportsType === "dynamic") {
|
779
779
|
runtimeRequirements.add(RuntimeGlobals.compatGetDefaultExport);
|
@@ -794,10 +794,10 @@ class RuntimeTemplate {
|
|
794
794
|
* @param {Module} options.originModule the origin module
|
795
795
|
* @param {boolean|undefined} options.asiSafe true, if location is safe for ASI, a bracket can be emitted
|
796
796
|
* @param {boolean} options.isCall true, if expression will be called
|
797
|
-
* @param {boolean} options.callContext when false, call context will not be preserved
|
797
|
+
* @param {boolean | null} options.callContext when false, call context will not be preserved
|
798
798
|
* @param {boolean} options.defaultInterop when true and accessing the default exports, interop code will be generated
|
799
799
|
* @param {string} options.importVar the identifier name of the import variable
|
800
|
-
* @param {InitFragment[]} options.initFragments init fragments will be added here
|
800
|
+
* @param {InitFragment<TODO>[]} options.initFragments init fragments will be added here
|
801
801
|
* @param {RuntimeSpec} options.runtime runtime for which this code will be generated
|
802
802
|
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
|
803
803
|
* @returns {string} expression
|
package/lib/SelfModuleFactory.js
CHANGED
@@ -5,11 +5,23 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
/** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
|
9
|
+
/** @typedef {import("./ModuleFactory").ModuleFactoryResult} ModuleFactoryResult */
|
10
|
+
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
11
|
+
|
8
12
|
class SelfModuleFactory {
|
13
|
+
/**
|
14
|
+
* @param {ModuleGraph} moduleGraph module graph
|
15
|
+
*/
|
9
16
|
constructor(moduleGraph) {
|
10
17
|
this.moduleGraph = moduleGraph;
|
11
18
|
}
|
12
19
|
|
20
|
+
/**
|
21
|
+
* @param {ModuleFactoryCreateData} data data object
|
22
|
+
* @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback
|
23
|
+
* @returns {void}
|
24
|
+
*/
|
13
25
|
create(data, callback) {
|
14
26
|
const module = this.moduleGraph.getParentModule(data.dependencies[0]);
|
15
27
|
callback(null, {
|
@@ -23,6 +23,7 @@ const { makePathsAbsolute } = require("./util/identifier");
|
|
23
23
|
/** @typedef {import("./CacheFacade").ItemCacheFacade} ItemCacheFacade */
|
24
24
|
/** @typedef {import("./Chunk")} Chunk */
|
25
25
|
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
|
26
|
+
/** @typedef {import("./Compilation").PathData} PathData */
|
26
27
|
/** @typedef {import("./Compiler")} Compiler */
|
27
28
|
/** @typedef {import("./Module")} Module */
|
28
29
|
/** @typedef {import("./NormalModule").SourceMap} SourceMap */
|
@@ -139,7 +140,7 @@ class SourceMapDevToolPlugin {
|
|
139
140
|
|
140
141
|
/** @type {string | false} */
|
141
142
|
this.sourceMapFilename = options.filename;
|
142
|
-
/** @type {string | false} */
|
143
|
+
/** @type {string | false | (function(PathData, AssetInfo=): string)}} */
|
143
144
|
this.sourceMappingURLComment =
|
144
145
|
options.append === false
|
145
146
|
? false
|
@@ -447,13 +448,14 @@ class SourceMapDevToolPlugin {
|
|
447
448
|
);
|
448
449
|
}
|
449
450
|
|
450
|
-
/** @type {string | false} */
|
451
|
+
/** @type {string | false | (function(PathData, AssetInfo=): string)} */
|
451
452
|
let currentSourceMappingURLComment = sourceMappingURLComment;
|
452
453
|
let cssExtensionDetected =
|
453
454
|
CSS_EXTENSION_DETECT_REGEXP.test(file);
|
454
455
|
resetRegexpState(CSS_EXTENSION_DETECT_REGEXP);
|
455
456
|
if (
|
456
457
|
currentSourceMappingURLComment !== false &&
|
458
|
+
typeof currentSourceMappingURLComment !== "function" &&
|
457
459
|
cssExtensionDetected
|
458
460
|
) {
|
459
461
|
currentSourceMappingURLComment =
|
@@ -534,6 +536,11 @@ class SourceMapDevToolPlugin {
|
|
534
536
|
"SourceMapDevToolPlugin: append can't be false when no filename is provided"
|
535
537
|
);
|
536
538
|
}
|
539
|
+
if (typeof currentSourceMappingURLComment === "function") {
|
540
|
+
throw new Error(
|
541
|
+
"SourceMapDevToolPlugin: append can't be a function when no filename is provided"
|
542
|
+
);
|
543
|
+
}
|
537
544
|
/**
|
538
545
|
* Add source map as data url to asset
|
539
546
|
*/
|
package/lib/Template.js
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
const { ConcatSource, PrefixSource } = require("webpack-sources");
|
9
9
|
const { WEBPACK_MODULE_TYPE_RUNTIME } = require("./ModuleTypeConstants");
|
10
|
+
const RuntimeGlobals = require("./RuntimeGlobals");
|
10
11
|
|
11
12
|
/** @typedef {import("webpack-sources").Source} Source */
|
12
13
|
/** @typedef {import("../declarations/WebpackOptions").Output} OutputOptions */
|
@@ -289,7 +290,7 @@ class Template {
|
|
289
290
|
* @param {Module[]} modules modules to render (should be ordered by identifier)
|
290
291
|
* @param {function(Module): Source} renderModule function to render a module
|
291
292
|
* @param {string=} prefix applying prefix strings
|
292
|
-
* @returns {Source} rendered chunk modules in a Source object
|
293
|
+
* @returns {Source | null} rendered chunk modules in a Source object or null if no modules
|
293
294
|
*/
|
294
295
|
static renderChunkModules(renderContext, modules, renderModule, prefix = "") {
|
295
296
|
const { chunkGraph } = renderContext;
|
@@ -405,7 +406,7 @@ class Template {
|
|
405
406
|
return new PrefixSource(
|
406
407
|
"/******/ ",
|
407
408
|
new ConcatSource(
|
408
|
-
|
409
|
+
`function(${RuntimeGlobals.require}) { // webpackRuntimeModules\n`,
|
409
410
|
this.renderRuntimeModules(runtimeModules, renderContext),
|
410
411
|
"}\n"
|
411
412
|
)
|
package/lib/UseStrictPlugin.js
CHANGED
@@ -13,6 +13,7 @@ const {
|
|
13
13
|
const ConstDependency = require("./dependencies/ConstDependency");
|
14
14
|
|
15
15
|
/** @typedef {import("./Compiler")} Compiler */
|
16
|
+
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
16
17
|
|
17
18
|
const PLUGIN_NAME = "UseStrictPlugin";
|
18
19
|
|
@@ -26,6 +27,9 @@ class UseStrictPlugin {
|
|
26
27
|
compiler.hooks.compilation.tap(
|
27
28
|
PLUGIN_NAME,
|
28
29
|
(compilation, { normalModuleFactory }) => {
|
30
|
+
/**
|
31
|
+
* @param {JavascriptParser} parser the parser
|
32
|
+
*/
|
29
33
|
const handler = parser => {
|
30
34
|
parser.hooks.program.tap(PLUGIN_NAME, ast => {
|
31
35
|
const firstNode = ast.body[0];
|
@@ -40,6 +40,13 @@ class WarnDeprecatedOptionPlugin {
|
|
40
40
|
}
|
41
41
|
|
42
42
|
class DeprecatedOptionWarning extends WebpackError {
|
43
|
+
/**
|
44
|
+
* Create an instance deprecated option warning
|
45
|
+
*
|
46
|
+
* @param {string} option the target option
|
47
|
+
* @param {string | number} value the deprecated option value
|
48
|
+
* @param {string} suggestion the suggestion replacement
|
49
|
+
*/
|
43
50
|
constructor(option, value, suggestion) {
|
44
51
|
super();
|
45
52
|
|
package/lib/WatchIgnorePlugin.js
CHANGED
@@ -36,6 +36,10 @@ class IgnoringWatchFileSystem {
|
|
36
36
|
watch(files, dirs, missing, startTime, options, callback, callbackUndelayed) {
|
37
37
|
files = Array.from(files);
|
38
38
|
dirs = Array.from(dirs);
|
39
|
+
/**
|
40
|
+
* @param {string} path path to check
|
41
|
+
* @returns {boolean} true, if path is ignored
|
42
|
+
*/
|
39
43
|
const ignored = path =>
|
40
44
|
this.paths.some(p =>
|
41
45
|
p instanceof RegExp ? p.test(path) : path.indexOf(p) === 0
|
@@ -657,7 +657,8 @@ class WebpackOptionsApply extends OptionsApply {
|
|
657
657
|
maxAge: cacheOptions.maxAge,
|
658
658
|
profile: cacheOptions.profile,
|
659
659
|
allowCollectingMemory: cacheOptions.allowCollectingMemory,
|
660
|
-
compression: cacheOptions.compression
|
660
|
+
compression: cacheOptions.compression,
|
661
|
+
readonly: cacheOptions.readonly
|
661
662
|
}),
|
662
663
|
cacheOptions.idleTimeout,
|
663
664
|
cacheOptions.idleTimeoutForInitialStore,
|
@@ -107,6 +107,11 @@ const encodeDataUri = (encoding, source) => {
|
|
107
107
|
return encodedContent;
|
108
108
|
};
|
109
109
|
|
110
|
+
/**
|
111
|
+
* @param {string} encoding encoding
|
112
|
+
* @param {string} content content
|
113
|
+
* @returns {Buffer} decoded content
|
114
|
+
*/
|
110
115
|
const decodeDataUriContent = (encoding, content) => {
|
111
116
|
const isBase64 = encoding === "base64";
|
112
117
|
|
@@ -230,10 +235,10 @@ class AssetGenerator extends Generator {
|
|
230
235
|
) {
|
231
236
|
switch (type) {
|
232
237
|
case ASSET_MODULE_TYPE:
|
233
|
-
return module.originalSource();
|
238
|
+
return /** @type {Source} */ (module.originalSource());
|
234
239
|
default: {
|
235
240
|
let content;
|
236
|
-
const originalSource = module.originalSource();
|
241
|
+
const originalSource = /** @type {Source} */ (module.originalSource());
|
237
242
|
if (module.buildInfo.dataUrl) {
|
238
243
|
let encodedSource;
|
239
244
|
if (typeof this.dataUrlOptions === "function") {
|
@@ -21,6 +21,10 @@ const memoize = require("../util/memoize");
|
|
21
21
|
/** @typedef {import("../Compiler")} Compiler */
|
22
22
|
/** @typedef {import("../Module")} Module */
|
23
23
|
|
24
|
+
/**
|
25
|
+
* @param {string} name name of definitions
|
26
|
+
* @returns {TODO} definition
|
27
|
+
*/
|
24
28
|
const getSchema = name => {
|
25
29
|
const { definitions } = require("../../schemas/WebpackOptions.json");
|
26
30
|
return {
|
@@ -204,7 +208,9 @@ class AssetModulesPlugin {
|
|
204
208
|
codeGenResult.data.get("fullContentHash")
|
205
209
|
});
|
206
210
|
} catch (e) {
|
207
|
-
|
211
|
+
/** @type {Error} */ (
|
212
|
+
e
|
213
|
+
).message += `\nduring rendering of asset ${module.identifier()}`;
|
208
214
|
throw e;
|
209
215
|
}
|
210
216
|
}
|
package/lib/asset/AssetParser.js
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
const Parser = require("../Parser");
|
9
9
|
|
10
|
+
/** @typedef {import("../../declarations/WebpackOptions").AssetParserDataUrlOptions} AssetParserDataUrlOptions */
|
10
11
|
/** @typedef {import("../../declarations/WebpackOptions").AssetParserOptions} AssetParserOptions */
|
11
12
|
/** @typedef {import("../Parser").ParserState} ParserState */
|
12
13
|
/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
|
@@ -45,7 +46,9 @@ class AssetParser extends Parser {
|
|
45
46
|
typeof this.dataUrlCondition === "object"
|
46
47
|
) {
|
47
48
|
state.module.buildInfo.dataUrl =
|
48
|
-
Buffer.byteLength(source) <=
|
49
|
+
Buffer.byteLength(source) <=
|
50
|
+
/** @type {NonNullable<AssetParserDataUrlOptions["maxSize"]>} */
|
51
|
+
(this.dataUrlCondition.maxSize);
|
49
52
|
} else {
|
50
53
|
throw new Error("Unexpected dataUrlCondition type");
|
51
54
|
}
|
@@ -60,7 +60,8 @@ class RawDataUrlModule extends Module {
|
|
60
60
|
* @returns {number} the estimated size of the module (must be non-zero)
|
61
61
|
*/
|
62
62
|
size(type) {
|
63
|
-
if (this.url === undefined)
|
63
|
+
if (this.url === undefined)
|
64
|
+
this.url = /** @type {Buffer} */ (this.urlBuffer).toString();
|
64
65
|
return Math.max(1, this.url.length);
|
65
66
|
}
|
66
67
|
|
@@ -102,7 +103,8 @@ class RawDataUrlModule extends Module {
|
|
102
103
|
* @returns {CodeGenerationResult} result
|
103
104
|
*/
|
104
105
|
codeGeneration(context) {
|
105
|
-
if (this.url === undefined)
|
106
|
+
if (this.url === undefined)
|
107
|
+
this.url = /** @type {Buffer} */ (this.urlBuffer).toString();
|
106
108
|
const sources = new Map();
|
107
109
|
sources.set(
|
108
110
|
"javascript",
|
@@ -121,7 +123,7 @@ class RawDataUrlModule extends Module {
|
|
121
123
|
* @returns {void}
|
122
124
|
*/
|
123
125
|
updateHash(hash, context) {
|
124
|
-
hash.update(this.urlBuffer);
|
126
|
+
hash.update(/** @type {Buffer} */ (this.urlBuffer));
|
125
127
|
super.updateHash(hash, context);
|
126
128
|
}
|
127
129
|
|
@@ -981,6 +981,7 @@ class PackFileCacheStrategy {
|
|
981
981
|
* @param {boolean} options.profile track and log detailed timing information for individual cache items
|
982
982
|
* @param {boolean} options.allowCollectingMemory allow to collect unused memory created during deserialization
|
983
983
|
* @param {false | "gzip" | "brotli"} options.compression compression used
|
984
|
+
* @param {boolean} options.readonly disable storing cache into filesystem
|
984
985
|
*/
|
985
986
|
constructor({
|
986
987
|
compiler,
|
@@ -993,7 +994,8 @@ class PackFileCacheStrategy {
|
|
993
994
|
maxAge,
|
994
995
|
profile,
|
995
996
|
allowCollectingMemory,
|
996
|
-
compression
|
997
|
+
compression,
|
998
|
+
readonly
|
997
999
|
}) {
|
998
1000
|
this.fileSerializer = createFileSerializer(
|
999
1001
|
fs,
|
@@ -1012,6 +1014,7 @@ class PackFileCacheStrategy {
|
|
1012
1014
|
this.logger = logger;
|
1013
1015
|
this.maxAge = maxAge;
|
1014
1016
|
this.profile = profile;
|
1017
|
+
this.readonly = readonly;
|
1015
1018
|
this.allowCollectingMemory = allowCollectingMemory;
|
1016
1019
|
this.compression = compression;
|
1017
1020
|
this._extension =
|
@@ -1213,6 +1216,8 @@ class PackFileCacheStrategy {
|
|
1213
1216
|
* @returns {Promise<void>} promise
|
1214
1217
|
*/
|
1215
1218
|
store(identifier, etag, data) {
|
1219
|
+
if (this.readonly) return Promise.resolve();
|
1220
|
+
|
1216
1221
|
return this._getPack().then(pack => {
|
1217
1222
|
pack.set(identifier, etag === null ? null : etag.toString(), data);
|
1218
1223
|
});
|
@@ -1239,6 +1244,7 @@ class PackFileCacheStrategy {
|
|
1239
1244
|
}
|
1240
1245
|
|
1241
1246
|
storeBuildDependencies(dependencies) {
|
1247
|
+
if (this.readonly) return;
|
1242
1248
|
this.newBuildDependencies.addAll(dependencies);
|
1243
1249
|
}
|
1244
1250
|
|
@@ -23,7 +23,7 @@ const inputRx = /^(?:((?:[A-Z]:)?[/\\].*?))?(?::(.+?))?$/i;
|
|
23
23
|
*/
|
24
24
|
|
25
25
|
/**
|
26
|
-
* @param {string} input input string
|
26
|
+
* @param {string | null | undefined} input input string
|
27
27
|
* @param {string} context the context directory
|
28
28
|
* @returns {BrowserslistHandlerConfig} config
|
29
29
|
*/
|
@@ -47,7 +47,7 @@ const parse = (input, context) => {
|
|
47
47
|
};
|
48
48
|
|
49
49
|
/**
|
50
|
-
* @param {string} input input string
|
50
|
+
* @param {string | null | undefined} input input string
|
51
51
|
* @param {string} context the context directory
|
52
52
|
* @returns {string[] | undefined} selected browsers
|
53
53
|
*/
|
@@ -66,7 +66,7 @@ const load = (input, context) => {
|
|
66
66
|
})
|
67
67
|
: browserslist.loadConfig({ path: context, env });
|
68
68
|
|
69
|
-
if (!config) return
|
69
|
+
if (!config) return;
|
70
70
|
return browserslist(config);
|
71
71
|
};
|
72
72
|
|