webpack 5.59.0 → 5.71.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 +1 -7
- package/hot/lazy-compilation-node.js +3 -1
- package/hot/poll.js +1 -1
- package/hot/signal.js +1 -1
- package/lib/APIPlugin.js +33 -0
- package/lib/BannerPlugin.js +10 -4
- package/lib/Cache.js +1 -1
- package/lib/CacheFacade.js +4 -11
- package/lib/Chunk.js +6 -3
- package/lib/ChunkGraph.js +1 -2
- package/lib/ChunkGroup.js +1 -1
- package/lib/CleanPlugin.js +81 -20
- package/lib/Compilation.js +179 -91
- package/lib/Compiler.js +86 -17
- package/lib/ConstPlugin.js +2 -2
- package/lib/ContextModule.js +142 -51
- package/lib/ContextModuleFactory.js +65 -25
- package/lib/DelegatedModule.js +1 -1
- package/lib/DelegatedModuleFactoryPlugin.js +1 -1
- package/lib/Dependency.js +17 -0
- package/lib/DependencyTemplate.js +9 -0
- package/lib/DependencyTemplates.js +1 -1
- package/lib/DllModule.js +1 -1
- package/lib/EntryOptionPlugin.js +2 -0
- package/lib/ErrorHelpers.js +2 -2
- package/lib/EvalDevToolModulePlugin.js +16 -1
- package/lib/EvalSourceMapDevToolPlugin.js +18 -1
- package/lib/ExportsInfo.js +4 -4
- package/lib/ExternalModule.js +94 -54
- package/lib/ExternalModuleFactoryPlugin.js +5 -5
- package/lib/FileSystemInfo.js +89 -44
- package/lib/Generator.js +3 -0
- package/lib/HookWebpackError.js +1 -1
- package/lib/HotModuleReplacementPlugin.js +3 -1
- package/lib/LoaderOptionsPlugin.js +1 -1
- package/lib/Module.js +27 -4
- package/lib/ModuleFilenameHelpers.js +8 -4
- package/lib/ModuleHashingError.js +29 -0
- package/lib/MultiCompiler.js +1 -1
- package/lib/MultiWatching.js +1 -1
- package/lib/NodeStuffPlugin.js +10 -0
- package/lib/NormalModule.js +41 -26
- package/lib/NormalModuleFactory.js +42 -37
- package/lib/ProgressPlugin.js +4 -5
- package/lib/RawModule.js +1 -1
- package/lib/RuntimeGlobals.js +29 -1
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimePlugin.js +77 -1
- package/lib/RuntimeTemplate.js +114 -2
- package/lib/Template.js +2 -1
- package/lib/TemplatedPathPlugin.js +48 -23
- package/lib/WatchIgnorePlugin.js +19 -7
- package/lib/Watching.js +33 -19
- package/lib/WebpackOptionsApply.js +57 -11
- package/lib/asset/AssetGenerator.js +193 -63
- package/lib/asset/AssetModulesPlugin.js +3 -0
- package/lib/asset/RawDataUrlModule.js +148 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +4 -4
- package/lib/buildChunkGraph.js +36 -6
- package/lib/cache/PackFileCacheStrategy.js +7 -4
- package/lib/cache/ResolverCachePlugin.js +90 -29
- package/lib/cli.js +44 -3
- package/lib/config/browserslistTargetHandler.js +41 -6
- package/lib/config/defaults.js +115 -19
- package/lib/config/normalization.js +9 -0
- package/lib/config/target.js +10 -0
- package/lib/container/ContainerEntryModule.js +8 -5
- package/lib/container/FallbackModule.js +4 -4
- package/lib/container/RemoteModule.js +4 -2
- package/lib/css/CssExportsGenerator.js +139 -0
- package/lib/css/CssGenerator.js +109 -0
- package/lib/css/CssLoadingRuntimeModule.js +440 -0
- package/lib/css/CssModulesPlugin.js +462 -0
- package/lib/css/CssParser.js +618 -0
- package/lib/css/walkCssTokens.js +659 -0
- package/lib/debug/ProfilingPlugin.js +24 -21
- package/lib/dependencies/AMDRequireDependency.js +6 -6
- package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -2
- package/lib/dependencies/CommonJsFullRequireDependency.js +5 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +5 -3
- package/lib/dependencies/CommonJsRequireContextDependency.js +5 -1
- package/lib/dependencies/ContextDependency.js +1 -0
- package/lib/dependencies/ContextDependencyHelpers.js +3 -3
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +4 -1
- package/lib/dependencies/ContextElementDependency.js +41 -3
- package/lib/dependencies/CreateScriptUrlDependency.js +12 -0
- package/lib/dependencies/CssExportDependency.js +85 -0
- package/lib/dependencies/CssImportDependency.js +75 -0
- package/lib/dependencies/CssLocalIdentifierDependency.js +119 -0
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +101 -0
- package/lib/dependencies/CssUrlDependency.js +132 -0
- package/lib/dependencies/ExportsInfoDependency.js +6 -0
- package/lib/dependencies/HarmonyAcceptImportDependency.js +5 -3
- package/lib/dependencies/HarmonyCompatibilityDependency.js +5 -5
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +95 -0
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +12 -3
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +25 -17
- package/lib/dependencies/HarmonyExportInitFragment.js +4 -1
- package/lib/dependencies/HarmonyImportDependency.js +23 -0
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +142 -45
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +46 -22
- package/lib/dependencies/HarmonyModulesPlugin.js +10 -0
- package/lib/dependencies/ImportContextDependency.js +0 -2
- package/lib/dependencies/ImportMetaContextDependency.js +35 -0
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +252 -0
- package/lib/dependencies/ImportMetaContextPlugin.js +59 -0
- package/lib/dependencies/ImportMetaPlugin.js +22 -3
- package/lib/dependencies/LoaderPlugin.js +4 -2
- package/lib/dependencies/RequireContextDependency.js +0 -16
- package/lib/dependencies/RequireEnsureDependency.js +2 -2
- package/lib/dependencies/URLDependency.js +3 -8
- package/lib/dependencies/URLPlugin.js +1 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +74 -49
- package/lib/esm/ModuleChunkLoadingPlugin.js +3 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +25 -9
- package/lib/hmr/HotModuleReplacement.runtime.js +29 -14
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +4 -3
- package/lib/hmr/LazyCompilationPlugin.js +54 -26
- package/lib/hmr/lazyCompilationBackend.js +51 -12
- package/lib/ids/DeterministicModuleIdsPlugin.js +55 -35
- package/lib/ids/HashedModuleIdsPlugin.js +11 -14
- package/lib/ids/IdHelpers.js +25 -11
- package/lib/ids/NamedModuleIdsPlugin.js +6 -9
- package/lib/ids/NaturalModuleIdsPlugin.js +10 -13
- package/lib/ids/OccurrenceModuleIdsPlugin.js +13 -10
- package/lib/ids/SyncModuleIdsPlugin.js +140 -0
- package/lib/index.js +13 -0
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +2 -2
- package/lib/javascript/BasicEvaluatedExpression.js +5 -2
- package/lib/javascript/ChunkHelpers.js +33 -0
- package/lib/javascript/JavascriptGenerator.js +1 -0
- package/lib/javascript/JavascriptModulesPlugin.js +27 -2
- package/lib/javascript/JavascriptParser.js +82 -48
- package/lib/javascript/StartupHelpers.js +7 -30
- package/lib/library/AssignLibraryPlugin.js +39 -15
- package/lib/library/EnableLibraryPlugin.js +11 -0
- package/lib/library/UmdLibraryPlugin.js +5 -3
- package/lib/node/NodeTargetPlugin.js +3 -0
- package/lib/node/NodeWatchFileSystem.js +85 -31
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +23 -8
- package/lib/node/RequireChunkLoadingRuntimeModule.js +24 -9
- package/lib/optimize/ConcatenatedModule.js +21 -9
- package/lib/optimize/ModuleConcatenationPlugin.js +5 -2
- package/lib/optimize/SplitChunksPlugin.js +8 -1
- package/lib/runtime/AsyncModuleRuntimeModule.js +27 -17
- package/lib/runtime/BaseUriRuntimeModule.js +31 -0
- package/lib/runtime/CreateScriptRuntimeModule.js +36 -0
- package/lib/runtime/CreateScriptUrlRuntimeModule.js +9 -34
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +76 -0
- package/lib/schemes/HttpUriPlugin.js +77 -14
- package/lib/serialization/FileMiddleware.js +44 -9
- package/lib/sharing/ConsumeSharedModule.js +8 -2
- package/lib/sharing/ConsumeSharedRuntimeModule.js +26 -5
- package/lib/sharing/ProvideSharedModule.js +4 -2
- package/lib/sharing/ShareRuntimeModule.js +1 -1
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +113 -68
- package/lib/stats/DefaultStatsPrinterPlugin.js +89 -24
- package/lib/util/ArrayHelpers.js +30 -0
- package/lib/util/AsyncQueue.js +1 -1
- package/lib/util/compileBooleanMatcher.js +1 -1
- package/lib/util/create-schema-validation.js +9 -2
- package/lib/util/createHash.js +12 -0
- package/lib/util/deprecation.js +10 -2
- package/lib/util/deterministicGrouping.js +1 -1
- package/lib/util/extractUrlAndGlobal.js +3 -0
- package/lib/util/fs.js +11 -0
- package/lib/util/hash/BatchedHash.js +7 -4
- package/lib/util/hash/md4.js +20 -0
- package/lib/util/hash/wasm-hash.js +163 -0
- package/lib/util/hash/xxhash64.js +5 -139
- package/lib/util/identifier.js +65 -44
- package/lib/util/internalSerializables.js +15 -0
- package/lib/util/nonNumericOnlyHash.js +22 -0
- package/lib/util/semver.js +17 -10
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +9 -3
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +20 -9
- package/lib/webpack.js +10 -3
- package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +3 -11
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +33 -22
- package/module.d.ts +215 -0
- package/package.json +23 -28
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +254 -29
- package/schemas/plugins/DllReferencePlugin.check.js +1 -1
- package/schemas/plugins/HashedModuleIdsPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetParserOptions.check.js +1 -1
- package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerPlugin.json +2 -1
- package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
- package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
- package/schemas/plugins/container/ExternalsType.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
- package/schemas/plugins/container/ModuleFederationPlugin.json +3 -1
- package/schemas/plugins/css/CssGeneratorOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssGeneratorOptions.check.js +6 -0
- package/schemas/plugins/css/CssGeneratorOptions.json +3 -0
- package/schemas/plugins/css/CssParserOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssParserOptions.json +3 -0
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.check.js +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.check.js +1 -1
- package/schemas/plugins/optimize/MinChunkSizePlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.json +4 -0
- package/types.d.ts +628 -179
@@ -51,6 +51,20 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
51
51
|
this._runtimeRequirements = runtimeRequirements;
|
52
52
|
}
|
53
53
|
|
54
|
+
/**
|
55
|
+
* @private
|
56
|
+
* @param {Chunk} chunk chunk
|
57
|
+
* @returns {string} generated code
|
58
|
+
*/
|
59
|
+
_generateBaseUri(chunk) {
|
60
|
+
const options = chunk.getEntryOptions();
|
61
|
+
if (options && options.baseUri) {
|
62
|
+
return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;
|
63
|
+
} else {
|
64
|
+
return `${RuntimeGlobals.baseURI} = document.baseURI || self.location.href;`;
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
54
68
|
/**
|
55
69
|
* @returns {string} runtime code
|
56
70
|
*/
|
@@ -59,13 +73,13 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
59
73
|
const {
|
60
74
|
runtimeTemplate,
|
61
75
|
outputOptions: {
|
62
|
-
globalObject,
|
63
76
|
chunkLoadingGlobal,
|
64
77
|
hotUpdateGlobal,
|
65
78
|
crossOriginLoading,
|
66
79
|
scriptType
|
67
80
|
}
|
68
81
|
} = compilation;
|
82
|
+
const globalObject = runtimeTemplate.globalObject;
|
69
83
|
const { linkPreload, linkPrefetch } =
|
70
84
|
JsonpChunkLoadingRuntimeModule.getCompilationHooks(compilation);
|
71
85
|
const fn = RuntimeGlobals.ensureChunkHandlers;
|
@@ -96,18 +110,14 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
96
110
|
)}]`;
|
97
111
|
const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);
|
98
112
|
const hasJsMatcher = compileBooleanMatcher(conditionMap);
|
99
|
-
const initialChunkIds = getInitialChunkIds(chunk, chunkGraph);
|
113
|
+
const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);
|
100
114
|
|
101
115
|
const stateExpression = withHmr
|
102
116
|
? `${RuntimeGlobals.hmrRuntimeStatePrefix}_jsonp`
|
103
117
|
: undefined;
|
104
118
|
|
105
119
|
return Template.asString([
|
106
|
-
withBaseURI
|
107
|
-
? Template.asString([
|
108
|
-
`${RuntimeGlobals.baseURI} = document.baseURI || self.location.href;`
|
109
|
-
])
|
110
|
-
: "// no baseURI",
|
120
|
+
withBaseURI ? this._generateBaseUri(chunk) : "// no baseURI",
|
111
121
|
"",
|
112
122
|
"// object to store loaded and loading chunks",
|
113
123
|
"// undefined = chunk not loaded, null = chunk preloaded/prefetched",
|
@@ -276,8 +286,9 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
276
286
|
? Template.asString([
|
277
287
|
"var currentUpdatedModulesList;",
|
278
288
|
"var waitingUpdateResolves = {};",
|
279
|
-
"function loadUpdateChunk(chunkId) {",
|
289
|
+
"function loadUpdateChunk(chunkId, updatedModulesList) {",
|
280
290
|
Template.indent([
|
291
|
+
"currentUpdatedModulesList = updatedModulesList;",
|
281
292
|
`return new Promise(${runtimeTemplate.basicFunction(
|
282
293
|
"resolve, reject",
|
283
294
|
[
|
@@ -419,7 +430,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|
419
430
|
`if(${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId) && installedChunks[chunkId]) {`,
|
420
431
|
Template.indent("installedChunks[chunkId][0]();"),
|
421
432
|
"}",
|
422
|
-
"installedChunks[
|
433
|
+
"installedChunks[chunkId] = 0;"
|
423
434
|
]),
|
424
435
|
"}",
|
425
436
|
withOnChunkLoad
|
package/lib/webpack.js
CHANGED
@@ -61,8 +61,7 @@ const createMultiCompiler = (childOptions, options) => {
|
|
61
61
|
const createCompiler = rawOptions => {
|
62
62
|
const options = getNormalizedWebpackOptions(rawOptions);
|
63
63
|
applyWebpackOptionsBaseDefaults(options);
|
64
|
-
const compiler = new Compiler(options.context);
|
65
|
-
compiler.options = options;
|
64
|
+
const compiler = new Compiler(options.context, options);
|
66
65
|
new NodeEnvironmentPlugin({
|
67
66
|
infrastructureLogging: options.infrastructureLogging
|
68
67
|
}).apply(compiler);
|
@@ -97,6 +96,9 @@ const createCompiler = rawOptions => {
|
|
97
96
|
* @returns {MultiCompiler} the multi compiler object
|
98
97
|
*/
|
99
98
|
|
99
|
+
const asArray = options =>
|
100
|
+
Array.isArray(options) ? Array.from(options) : [options];
|
101
|
+
|
100
102
|
const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
|
101
103
|
/**
|
102
104
|
* @param {WebpackOptions | (ReadonlyArray<WebpackOptions> & MultiCompilerOptions)} options options
|
@@ -105,8 +107,13 @@ const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
|
|
105
107
|
*/
|
106
108
|
(options, callback) => {
|
107
109
|
const create = () => {
|
108
|
-
if (!
|
110
|
+
if (!asArray(options).every(webpackOptionsSchemaCheck)) {
|
109
111
|
getValidateSchema()(webpackOptionsSchema, options);
|
112
|
+
util.deprecate(
|
113
|
+
() => {},
|
114
|
+
"webpack bug: Pre-compiled schema reports error while real schema is happy. This has performance drawbacks.",
|
115
|
+
"DEP_WEBPACK_PRE_COMPILED_SCHEMA_INVALID"
|
116
|
+
)();
|
110
117
|
}
|
111
118
|
/** @type {MultiCompiler|Compiler} */
|
112
119
|
let compiler;
|
@@ -6,7 +6,6 @@
|
|
6
6
|
"use strict";
|
7
7
|
|
8
8
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
9
|
-
const CreateScriptUrlRuntimeModule = require("../runtime/CreateScriptUrlRuntimeModule");
|
10
9
|
const StartupChunkDependenciesPlugin = require("../runtime/StartupChunkDependenciesPlugin");
|
11
10
|
const ImportScriptsChunkLoadingRuntimeModule = require("./ImportScriptsChunkLoadingRuntimeModule");
|
12
11
|
|
@@ -43,7 +42,9 @@ class ImportScriptsChunkLoadingPlugin {
|
|
43
42
|
const withCreateScriptUrl = !!compilation.outputOptions.trustedTypes;
|
44
43
|
set.add(RuntimeGlobals.moduleFactoriesAddOnly);
|
45
44
|
set.add(RuntimeGlobals.hasOwnProperty);
|
46
|
-
if (withCreateScriptUrl)
|
45
|
+
if (withCreateScriptUrl) {
|
46
|
+
set.add(RuntimeGlobals.createScriptUrl);
|
47
|
+
}
|
47
48
|
compilation.addRuntimeModule(
|
48
49
|
chunk,
|
49
50
|
new ImportScriptsChunkLoadingRuntimeModule(set, withCreateScriptUrl)
|
@@ -61,15 +62,6 @@ class ImportScriptsChunkLoadingPlugin {
|
|
61
62
|
compilation.hooks.runtimeRequirementInTree
|
62
63
|
.for(RuntimeGlobals.baseURI)
|
63
64
|
.tap("ImportScriptsChunkLoadingPlugin", handler);
|
64
|
-
compilation.hooks.runtimeRequirementInTree
|
65
|
-
.for(RuntimeGlobals.createScriptUrl)
|
66
|
-
.tap("RuntimePlugin", (chunk, set) => {
|
67
|
-
compilation.addRuntimeModule(
|
68
|
-
chunk,
|
69
|
-
new CreateScriptUrlRuntimeModule()
|
70
|
-
);
|
71
|
-
return true;
|
72
|
-
});
|
73
65
|
|
74
66
|
compilation.hooks.runtimeRequirementInTree
|
75
67
|
.for(RuntimeGlobals.ensureChunkHandlers)
|
@@ -15,6 +15,8 @@ const { getInitialChunkIds } = require("../javascript/StartupHelpers");
|
|
15
15
|
const compileBooleanMatcher = require("../util/compileBooleanMatcher");
|
16
16
|
const { getUndoPath } = require("../util/identifier");
|
17
17
|
|
18
|
+
/** @typedef {import("../Chunk")} Chunk */
|
19
|
+
|
18
20
|
class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
19
21
|
constructor(runtimeRequirements, withCreateScriptUrl) {
|
20
22
|
super("importScripts chunk loading", RuntimeModule.STAGE_ATTACH);
|
@@ -22,6 +24,33 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
22
24
|
this._withCreateScriptUrl = withCreateScriptUrl;
|
23
25
|
}
|
24
26
|
|
27
|
+
/**
|
28
|
+
* @private
|
29
|
+
* @param {Chunk} chunk chunk
|
30
|
+
* @returns {string} generated code
|
31
|
+
*/
|
32
|
+
_generateBaseUri(chunk) {
|
33
|
+
const options = chunk.getEntryOptions();
|
34
|
+
if (options && options.baseUri) {
|
35
|
+
return `${RuntimeGlobals.baseURI} = ${JSON.stringify(options.baseUri)};`;
|
36
|
+
}
|
37
|
+
const outputName = this.compilation.getPath(
|
38
|
+
getChunkFilenameTemplate(chunk, this.compilation.outputOptions),
|
39
|
+
{
|
40
|
+
chunk,
|
41
|
+
contentHashType: "javascript"
|
42
|
+
}
|
43
|
+
);
|
44
|
+
const rootOutputDir = getUndoPath(
|
45
|
+
outputName,
|
46
|
+
this.compilation.outputOptions.path,
|
47
|
+
false
|
48
|
+
);
|
49
|
+
return `${RuntimeGlobals.baseURI} = self.location + ${JSON.stringify(
|
50
|
+
rootOutputDir ? "/../" + rootOutputDir : ""
|
51
|
+
)};`;
|
52
|
+
}
|
53
|
+
|
25
54
|
/**
|
26
55
|
* @returns {string} runtime code
|
27
56
|
*/
|
@@ -31,10 +60,11 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
31
60
|
chunkGraph,
|
32
61
|
compilation: {
|
33
62
|
runtimeTemplate,
|
34
|
-
outputOptions: {
|
63
|
+
outputOptions: { chunkLoadingGlobal, hotUpdateGlobal }
|
35
64
|
},
|
36
65
|
_withCreateScriptUrl: withCreateScriptUrl
|
37
66
|
} = this;
|
67
|
+
const globalObject = runtimeTemplate.globalObject;
|
38
68
|
const fn = RuntimeGlobals.ensureChunkHandlers;
|
39
69
|
const withBaseURI = this.runtimeRequirements.has(RuntimeGlobals.baseURI);
|
40
70
|
const withLoading = this.runtimeRequirements.has(
|
@@ -52,33 +82,14 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
|
52
82
|
const hasJsMatcher = compileBooleanMatcher(
|
53
83
|
chunkGraph.getChunkConditionMap(chunk, chunkHasJs)
|
54
84
|
);
|
55
|
-
const initialChunkIds = getInitialChunkIds(chunk, chunkGraph);
|
56
|
-
|
57
|
-
const outputName = this.compilation.getPath(
|
58
|
-
getChunkFilenameTemplate(chunk, this.compilation.outputOptions),
|
59
|
-
{
|
60
|
-
chunk,
|
61
|
-
contentHashType: "javascript"
|
62
|
-
}
|
63
|
-
);
|
64
|
-
const rootOutputDir = getUndoPath(
|
65
|
-
outputName,
|
66
|
-
this.compilation.outputOptions.path,
|
67
|
-
false
|
68
|
-
);
|
85
|
+
const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);
|
69
86
|
|
70
87
|
const stateExpression = withHmr
|
71
88
|
? `${RuntimeGlobals.hmrRuntimeStatePrefix}_importScripts`
|
72
89
|
: undefined;
|
73
90
|
|
74
91
|
return Template.asString([
|
75
|
-
withBaseURI
|
76
|
-
? Template.asString([
|
77
|
-
`${RuntimeGlobals.baseURI} = self.location + ${JSON.stringify(
|
78
|
-
rootOutputDir ? "/../" + rootOutputDir : ""
|
79
|
-
)};`
|
80
|
-
])
|
81
|
-
: "// no baseURI",
|
92
|
+
withBaseURI ? this._generateBaseUri(chunk) : "// no baseURI",
|
82
93
|
"",
|
83
94
|
"// object to store loaded chunks",
|
84
95
|
'// "1" means "already loaded"',
|
package/module.d.ts
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
declare namespace webpack {
|
2
|
+
type HotEvent =
|
3
|
+
| {
|
4
|
+
type: "disposed";
|
5
|
+
/** The module in question. */
|
6
|
+
moduleId: number;
|
7
|
+
}
|
8
|
+
| {
|
9
|
+
type: "self-declined" | "unaccepted";
|
10
|
+
/** The module in question. */
|
11
|
+
moduleId: number;
|
12
|
+
/** the chain from where the update was propagated. */
|
13
|
+
chain: number[];
|
14
|
+
}
|
15
|
+
| {
|
16
|
+
type: "declined";
|
17
|
+
/** The module in question. */
|
18
|
+
moduleId: number;
|
19
|
+
/** the chain from where the update was propagated. */
|
20
|
+
chain: number[];
|
21
|
+
/** the module id of the declining parent */
|
22
|
+
parentId: number;
|
23
|
+
}
|
24
|
+
| {
|
25
|
+
type: "accepted";
|
26
|
+
/** The module in question. */
|
27
|
+
moduleId: number;
|
28
|
+
/** the chain from where the update was propagated. */
|
29
|
+
chain: number[];
|
30
|
+
/** the modules that are outdated and will be disposed */
|
31
|
+
outdatedModules: number[];
|
32
|
+
/** the accepted dependencies that are outdated */
|
33
|
+
outdatedDependencies: {
|
34
|
+
[id: number]: number[];
|
35
|
+
};
|
36
|
+
}
|
37
|
+
| {
|
38
|
+
type: "accept-error-handler-errored";
|
39
|
+
/** The module in question. */
|
40
|
+
moduleId: number;
|
41
|
+
/** the module id owning the accept handler. */
|
42
|
+
dependencyId: number;
|
43
|
+
/** the thrown error */
|
44
|
+
error: Error;
|
45
|
+
/** the error thrown by the module before the error handler tried to handle it. */
|
46
|
+
originalError: Error;
|
47
|
+
}
|
48
|
+
| {
|
49
|
+
type: "self-accept-error-handler-errored";
|
50
|
+
/** The module in question. */
|
51
|
+
moduleId: number;
|
52
|
+
/** the thrown error */
|
53
|
+
error: Error;
|
54
|
+
/** the error thrown by the module before the error handler tried to handle it. */
|
55
|
+
originalError: Error;
|
56
|
+
}
|
57
|
+
| {
|
58
|
+
type: "accept-errored";
|
59
|
+
/** The module in question. */
|
60
|
+
moduleId: number;
|
61
|
+
/** the module id owning the accept handler. */
|
62
|
+
dependencyId: number;
|
63
|
+
/** the thrown error */
|
64
|
+
error: Error;
|
65
|
+
}
|
66
|
+
| {
|
67
|
+
type: "self-accept-errored";
|
68
|
+
/** The module in question. */
|
69
|
+
moduleId: number;
|
70
|
+
/** the thrown error */
|
71
|
+
error: Error;
|
72
|
+
};
|
73
|
+
|
74
|
+
interface ApplyOptions {
|
75
|
+
ignoreUnaccepted?: boolean;
|
76
|
+
ignoreDeclined?: boolean;
|
77
|
+
ignoreErrored?: boolean;
|
78
|
+
onDeclined?(callback: (info: HotEvent) => void): void;
|
79
|
+
onUnaccepted?(callback: (info: HotEvent) => void): void;
|
80
|
+
onAccepted?(callback: (info: HotEvent) => void): void;
|
81
|
+
onDisposed?(callback: (info: HotEvent) => void): void;
|
82
|
+
onErrored?(callback: (info: HotEvent) => void): void;
|
83
|
+
}
|
84
|
+
|
85
|
+
const enum HotUpdateStatus {
|
86
|
+
idle = "idle",
|
87
|
+
check = "check",
|
88
|
+
prepare = "prepare",
|
89
|
+
ready = "ready",
|
90
|
+
dispose = "dispose",
|
91
|
+
apply = "apply",
|
92
|
+
abort = "abort",
|
93
|
+
fail = "fail"
|
94
|
+
}
|
95
|
+
|
96
|
+
interface Hot {
|
97
|
+
accept: {
|
98
|
+
(
|
99
|
+
modules: string | string[],
|
100
|
+
callback?: (outdatedDependencies: string[]) => void,
|
101
|
+
errorHandler?: (
|
102
|
+
err: Error,
|
103
|
+
context: { moduleId: string | number; dependencyId: string | number }
|
104
|
+
) => void
|
105
|
+
): void;
|
106
|
+
(
|
107
|
+
errorHandler?: (
|
108
|
+
err: Error,
|
109
|
+
ids: { moduleId: string | number; module: NodeJS.Module }
|
110
|
+
) => void
|
111
|
+
): void;
|
112
|
+
};
|
113
|
+
status(): HotUpdateStatus;
|
114
|
+
decline(module?: string | string[]): void;
|
115
|
+
dispose(callback: (data: object) => void): void;
|
116
|
+
addDisposeHandler(callback: (data: object) => void): void;
|
117
|
+
removeDisposeHandler(callback: (data: object) => void): void;
|
118
|
+
invalidate(): void;
|
119
|
+
addStatusHandler(callback: (status: HotUpdateStatus) => void): void;
|
120
|
+
removeStatusHandler(callback: (status: HotUpdateStatus) => void): void;
|
121
|
+
data: object;
|
122
|
+
check(
|
123
|
+
autoApply?: boolean | ApplyOptions
|
124
|
+
): Promise<(string | number)[] | null>;
|
125
|
+
apply(options?: ApplyOptions): Promise<(string | number)[] | null>;
|
126
|
+
}
|
127
|
+
|
128
|
+
interface ExportInfo {
|
129
|
+
used: boolean;
|
130
|
+
provideInfo: boolean | null | undefined;
|
131
|
+
useInfo: boolean | null | undefined;
|
132
|
+
canMangle: boolean;
|
133
|
+
}
|
134
|
+
|
135
|
+
interface ExportsInfo {
|
136
|
+
[k: string]: ExportInfo & ExportsInfo;
|
137
|
+
}
|
138
|
+
|
139
|
+
interface Context {
|
140
|
+
resolve(dependency: string): string | number;
|
141
|
+
keys(): Array<string>;
|
142
|
+
id: string | number;
|
143
|
+
(dependency: string): unknown;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
interface ImportMeta {
|
148
|
+
url: string;
|
149
|
+
webpack: number;
|
150
|
+
webpackHot: webpack.Hot;
|
151
|
+
webpackContext: (
|
152
|
+
request: string,
|
153
|
+
options?: {
|
154
|
+
recursive?: boolean;
|
155
|
+
regExp?: RegExp;
|
156
|
+
include?: RegExp;
|
157
|
+
exclude?: RegExp;
|
158
|
+
preload?: boolean | number;
|
159
|
+
prefetch?: boolean | number;
|
160
|
+
chunkName?: string;
|
161
|
+
exports?: string | string[][];
|
162
|
+
mode?: "sync" | "eager" | "weak" | "lazy" | "lazy-once";
|
163
|
+
}
|
164
|
+
) => webpack.Context;
|
165
|
+
}
|
166
|
+
|
167
|
+
declare const __resourceQuery: string;
|
168
|
+
declare var __webpack_public_path__: string;
|
169
|
+
declare var __webpack_nonce__: string;
|
170
|
+
declare const __webpack_chunkname__: string;
|
171
|
+
declare var __webpack_base_uri__: string;
|
172
|
+
declare var __webpack_runtime_id__: string;
|
173
|
+
declare const __webpack_hash__: string;
|
174
|
+
declare const __webpack_modules__: Record<string | number, NodeJS.Module>;
|
175
|
+
declare const __webpack_require__: (id: string | number) => unknown;
|
176
|
+
declare var __webpack_chunk_load__: (chunkId: string | number) => Promise<void>;
|
177
|
+
declare var __webpack_get_script_filename__: (
|
178
|
+
chunkId: string | number
|
179
|
+
) => string;
|
180
|
+
declare var __webpack_is_included__: (request: string) => boolean;
|
181
|
+
declare var __webpack_exports_info__: webpack.ExportsInfo;
|
182
|
+
declare const __webpack_share_scopes__: Record<
|
183
|
+
string,
|
184
|
+
Record<
|
185
|
+
string,
|
186
|
+
{ loaded?: 1; get: () => Promise<unknown>; from: string; eager: boolean }
|
187
|
+
>
|
188
|
+
>;
|
189
|
+
declare var __webpack_init_sharing__: (scope: string) => Promise<void>;
|
190
|
+
declare var __non_webpack_require__: (id: any) => unknown;
|
191
|
+
declare const __system_context__: object;
|
192
|
+
|
193
|
+
declare namespace NodeJS {
|
194
|
+
interface Module {
|
195
|
+
hot: webpack.Hot;
|
196
|
+
}
|
197
|
+
|
198
|
+
interface Require {
|
199
|
+
ensure(
|
200
|
+
dependencies: string[],
|
201
|
+
callback: (require: (module: string) => void) => void,
|
202
|
+
errorCallback?: (error: Error) => void,
|
203
|
+
chunkName?: string
|
204
|
+
): void;
|
205
|
+
context(
|
206
|
+
request: string,
|
207
|
+
includeSubdirectories?: boolean,
|
208
|
+
filter?: RegExp,
|
209
|
+
mode?: "sync" | "eager" | "weak" | "lazy" | "lazy-once"
|
210
|
+
): webpack.Context;
|
211
|
+
include(dependency: string): void;
|
212
|
+
resolveWeak(dependency: string): void;
|
213
|
+
onError?: (error: Error) => void;
|
214
|
+
}
|
215
|
+
}
|
package/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.71.0",
|
4
4
|
"author": "Tobias Koppers @sokra",
|
5
5
|
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
|
6
6
|
"license": "MIT",
|
7
7
|
"dependencies": {
|
8
|
-
"@types/eslint-scope": "^3.7.
|
9
|
-
"@types/estree": "^0.0.
|
8
|
+
"@types/eslint-scope": "^3.7.3",
|
9
|
+
"@types/estree": "^0.0.51",
|
10
10
|
"@webassemblyjs/ast": "1.11.1",
|
11
11
|
"@webassemblyjs/wasm-edit": "1.11.1",
|
12
12
|
"@webassemblyjs/wasm-parser": "1.11.1",
|
@@ -14,12 +14,12 @@
|
|
14
14
|
"acorn-import-assertions": "^1.7.6",
|
15
15
|
"browserslist": "^4.14.5",
|
16
16
|
"chrome-trace-event": "^1.0.2",
|
17
|
-
"enhanced-resolve": "^5.
|
17
|
+
"enhanced-resolve": "^5.9.2",
|
18
18
|
"es-module-lexer": "^0.9.0",
|
19
19
|
"eslint-scope": "5.1.1",
|
20
20
|
"events": "^3.2.0",
|
21
21
|
"glob-to-regexp": "^0.4.1",
|
22
|
-
"graceful-fs": "^4.2.
|
22
|
+
"graceful-fs": "^4.2.9",
|
23
23
|
"json-parse-better-errors": "^1.0.2",
|
24
24
|
"loader-runner": "^4.2.0",
|
25
25
|
"mime-types": "^2.1.27",
|
@@ -27,8 +27,8 @@
|
|
27
27
|
"schema-utils": "^3.1.0",
|
28
28
|
"tapable": "^2.1.1",
|
29
29
|
"terser-webpack-plugin": "^5.1.3",
|
30
|
-
"watchpack": "^2.
|
31
|
-
"webpack-sources": "^3.2.
|
30
|
+
"watchpack": "^2.3.1",
|
31
|
+
"webpack-sources": "^3.2.3"
|
32
32
|
},
|
33
33
|
"peerDependenciesMeta": {
|
34
34
|
"webpack-cli": {
|
@@ -39,8 +39,8 @@
|
|
39
39
|
"@babel/core": "^7.11.1",
|
40
40
|
"@babel/preset-react": "^7.10.4",
|
41
41
|
"@types/es-module-lexer": "^0.4.1",
|
42
|
-
"@types/jest": "^27.0
|
43
|
-
"@types/node": "^
|
42
|
+
"@types/jest": "^27.4.0",
|
43
|
+
"@types/node": "^17.0.16",
|
44
44
|
"assemblyscript": "^0.19.16",
|
45
45
|
"babel-loader": "^8.1.0",
|
46
46
|
"benchmark": "^2.1.4",
|
@@ -56,7 +56,7 @@
|
|
56
56
|
"es6-promise-polyfill": "^1.2.0",
|
57
57
|
"eslint": "^7.14.0",
|
58
58
|
"eslint-config-prettier": "^8.1.0",
|
59
|
-
"eslint-plugin-jest": "^24.
|
59
|
+
"eslint-plugin-jest": "^24.7.0",
|
60
60
|
"eslint-plugin-jsdoc": "^33.0.0",
|
61
61
|
"eslint-plugin-node": "^11.0.0",
|
62
62
|
"eslint-plugin-prettier": "^4.0.0",
|
@@ -66,11 +66,11 @@
|
|
66
66
|
"husky": "^6.0.0",
|
67
67
|
"is-ci": "^3.0.0",
|
68
68
|
"istanbul": "^0.4.5",
|
69
|
-
"jest": "^27.0
|
70
|
-
"jest-circus": "^27.0
|
71
|
-
"jest-cli": "^27.0
|
72
|
-
"jest-diff": "^27.0
|
73
|
-
"jest-junit": "^
|
69
|
+
"jest": "^27.5.0",
|
70
|
+
"jest-circus": "^27.5.0",
|
71
|
+
"jest-cli": "^27.5.0",
|
72
|
+
"jest-diff": "^27.5.0",
|
73
|
+
"jest-junit": "^13.0.0",
|
74
74
|
"json-loader": "^0.5.7",
|
75
75
|
"json5": "^2.1.3",
|
76
76
|
"less": "^4.0.0",
|
@@ -98,9 +98,9 @@
|
|
98
98
|
"style-loader": "^2.0.0",
|
99
99
|
"terser": "^5.7.0",
|
100
100
|
"toml": "^3.0.0",
|
101
|
-
"tooling": "webpack/tooling#v1.
|
101
|
+
"tooling": "webpack/tooling#v1.21.0",
|
102
102
|
"ts-loader": "^8.0.2",
|
103
|
-
"typescript": "^4.
|
103
|
+
"typescript": "^4.5.5",
|
104
104
|
"url-loader": "^4.1.0",
|
105
105
|
"wast-loader": "^1.11.0",
|
106
106
|
"webassembly-feature": "1.3.0",
|
@@ -132,6 +132,7 @@
|
|
132
132
|
"hot/",
|
133
133
|
"schemas/",
|
134
134
|
"SECURITY.md",
|
135
|
+
"module.d.ts",
|
135
136
|
"types.d.ts"
|
136
137
|
],
|
137
138
|
"scripts": {
|
@@ -142,28 +143,22 @@
|
|
142
143
|
"test:integration": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.{basictest,longtest,test}.js\"",
|
143
144
|
"test:basic": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage --testMatch \"<rootDir>/test/*.basictest.js\"",
|
144
145
|
"test:unit": "node --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --testMatch \"<rootDir>/test/*.unittest.js\"",
|
145
|
-
"travis:integration": "yarn cover:integration --ci $JEST",
|
146
|
-
"travis:basic": "yarn cover:basic --ci $JEST",
|
147
|
-
"travis:lintunit": "yarn lint && yarn cover:unit --ci $JEST",
|
148
|
-
"travis:benchmark": "yarn benchmark --ci",
|
149
|
-
"appveyor:integration": "yarn cover:integration --ci %JEST%",
|
150
|
-
"appveyor:unit": "yarn cover:unit --ci %JEST%",
|
151
|
-
"appveyor:benchmark": "yarn benchmark --ci",
|
152
146
|
"build:examples": "cd examples && node buildAll.js",
|
153
147
|
"type-report": "rimraf coverage && yarn cover:types && yarn cover:report && open-cli coverage/lcov-report/index.html",
|
154
148
|
"pretest": "yarn lint",
|
155
149
|
"prelint": "yarn setup",
|
156
|
-
"lint": "yarn code-lint && yarn special-lint && yarn type-lint && yarn typings-
|
150
|
+
"lint": "yarn code-lint && yarn special-lint && yarn type-lint && yarn typings-test && yarn module-typings-test && yarn yarn-lint && yarn pretty-lint && yarn spellcheck",
|
157
151
|
"code-lint": "eslint . --ext '.js' --cache",
|
158
152
|
"type-lint": "tsc",
|
159
|
-
"typings-
|
160
|
-
"
|
153
|
+
"typings-test": "tsc -p tsconfig.types.test.json",
|
154
|
+
"module-typings-test": "tsc -p tsconfig.module.test.json",
|
155
|
+
"spellcheck": "cspell \"**/*\"",
|
161
156
|
"special-lint": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node tooling/generate-runtime-code.js && node tooling/generate-wasm-code.js && node node_modules/tooling/format-file-header && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/precompile-schemas && node node_modules/tooling/generate-types --no-template-literals",
|
162
157
|
"special-lint-fix": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node tooling/generate-runtime-code.js --write && node tooling/generate-wasm-code.js --write && node node_modules/tooling/format-file-header --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/precompile-schemas --write && node node_modules/tooling/generate-types --no-template-literals --write",
|
163
158
|
"fix": "yarn code-lint --fix && yarn special-lint-fix && yarn pretty-lint-fix",
|
164
159
|
"prepare": "husky install",
|
165
160
|
"pretty-lint-base": "prettier \"*.{ts,json,yml,yaml,md}\" \"{setup,lib,bin,hot,benchmark,tooling,schemas}/**/*.json\" \"examples/*.md\"",
|
166
|
-
"pretty-lint-base-all": "yarn pretty-lint-base \"*.js\" \"{setup,lib,bin,hot,benchmark,tooling,schemas}/**/*.js\" \"test/*.js\" \"test/helpers/*.js\" \"test/{configCases,watchCases,statsCases,hotCases,benchmarkCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
|
161
|
+
"pretty-lint-base-all": "yarn pretty-lint-base \"*.js\" \"{setup,lib,bin,hot,benchmark,tooling,schemas}/**/*.js\" \"module.d.ts\" \"test/*.js\" \"test/helpers/*.js\" \"test/{configCases,watchCases,statsCases,hotCases,benchmarkCases}/**/webpack.config.js\" \"examples/**/webpack.config.js\"",
|
167
162
|
"pretty-lint-fix": "yarn pretty-lint-base-all --loglevel warn --write",
|
168
163
|
"pretty-lint": "yarn pretty-lint-base --check",
|
169
164
|
"yarn-lint": "yarn-deduplicate --fail --list -s highest yarn.lock",
|