webpack 5.89.0 → 5.90.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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/README.md +3 -0
- package/bin/webpack.js +1 -3
- package/hot/log.js +0 -2
- package/lib/APIPlugin.js +17 -13
- package/lib/ChunkGraph.js +1 -1
- package/lib/CleanPlugin.js +12 -12
- package/lib/Compilation.js +26 -17
- package/lib/Compiler.js +13 -0
- package/lib/ConcatenationScope.js +2 -2
- package/lib/ConditionalInitFragment.js +3 -3
- package/lib/ContextModule.js +4 -4
- package/lib/ContextModuleFactory.js +1 -1
- package/lib/DefinePlugin.js +47 -26
- package/lib/DependencyTemplate.js +3 -1
- package/lib/EnvironmentNotSupportAsyncWarning.js +52 -0
- package/lib/EvalDevToolModulePlugin.js +1 -1
- package/lib/EvalSourceMapDevToolPlugin.js +2 -2
- package/lib/ExportsInfoApiPlugin.js +2 -2
- package/lib/ExternalModule.js +47 -12
- package/lib/ExternalModuleFactoryPlugin.js +1 -1
- package/lib/FileSystemInfo.js +20 -3
- package/lib/FlagDependencyExportsPlugin.js +1 -1
- package/lib/Generator.js +1 -0
- package/lib/HotModuleReplacementPlugin.js +3 -3
- package/lib/InitFragment.js +7 -7
- package/lib/LibManifestPlugin.js +4 -1
- package/lib/Module.js +2 -1
- package/lib/ModuleFilenameHelpers.js +1 -1
- package/lib/ModuleInfoHeaderPlugin.js +1 -1
- package/lib/MultiStats.js +2 -2
- package/lib/NodeStuffPlugin.js +48 -0
- package/lib/NormalModule.js +13 -11
- package/lib/NormalModuleFactory.js +7 -7
- package/lib/RuntimeTemplate.js +15 -11
- package/lib/SourceMapDevToolPlugin.js +2 -2
- package/lib/Stats.js +4 -0
- package/lib/WebpackOptionsApply.js +4 -3
- package/lib/asset/AssetModulesPlugin.js +2 -3
- package/lib/async-modules/AwaitDependenciesInitFragment.js +2 -2
- package/lib/buildChunkGraph.js +53 -0
- package/lib/cache/AddManagedPathsPlugin.js +6 -1
- package/lib/cache/IdleFileCachePlugin.js +12 -5
- package/lib/cache/PackFileCacheStrategy.js +3 -3
- package/lib/cache/ResolverCachePlugin.js +2 -2
- package/lib/config/browserslistTargetHandler.js +35 -14
- package/lib/config/defaults.js +88 -52
- package/lib/config/normalization.js +17 -18
- package/lib/config/target.js +5 -0
- package/lib/container/ContainerReferencePlugin.js +1 -1
- package/lib/css/CssExportsGenerator.js +14 -1
- package/lib/css/CssGenerator.js +14 -1
- package/lib/css/CssLoadingRuntimeModule.js +23 -23
- package/lib/css/CssModulesPlugin.js +68 -32
- package/lib/css/CssParser.js +8 -3
- package/lib/debug/ProfilingPlugin.js +2 -2
- package/lib/dependencies/AMDDefineDependency.js +4 -4
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +126 -34
- package/lib/dependencies/AMDPlugin.js +11 -4
- package/lib/dependencies/AMDRequireArrayDependency.js +13 -1
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +159 -43
- package/lib/dependencies/AMDRequireDependency.js +2 -2
- package/lib/dependencies/AMDRequireItemDependency.js +1 -1
- package/lib/dependencies/CachedConstDependency.js +8 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +1 -1
- package/lib/dependencies/ExternalModuleDependency.js +107 -0
- package/lib/dependencies/ExternalModuleInitFragment.js +131 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +1 -1
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +7 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +18 -18
- package/lib/dependencies/HarmonyExportInitFragment.js +6 -6
- package/lib/dependencies/HarmonyImportDependency.js +4 -4
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +6 -6
- package/lib/dependencies/ImportDependency.js +26 -6
- package/lib/dependencies/JsonExportsDependency.js +1 -1
- package/lib/dependencies/LoaderPlugin.js +2 -1
- package/lib/dependencies/LocalModuleDependency.js +1 -1
- package/lib/dependencies/PureExpressionDependency.js +12 -4
- package/lib/dependencies/RequireIncludeDependency.js +1 -1
- package/lib/dependencies/WebpackIsIncludedDependency.js +1 -1
- package/lib/dependencies/WorkerPlugin.js +10 -3
- package/lib/dependencies/getFunctionExpression.js +2 -2
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +6 -6
- package/lib/hmr/HotModuleReplacement.runtime.js +3 -5
- package/lib/hmr/lazyCompilationBackend.js +4 -4
- package/lib/ids/DeterministicModuleIdsPlugin.js +1 -1
- package/lib/index.js +4 -0
- package/lib/javascript/JavascriptGenerator.js +16 -1
- package/lib/javascript/JavascriptModulesPlugin.js +33 -33
- package/lib/javascript/JavascriptParser.js +220 -74
- package/lib/json/JsonGenerator.js +1 -1
- package/lib/library/AmdLibraryPlugin.js +5 -1
- package/lib/library/AssignLibraryPlugin.js +1 -1
- package/lib/library/SystemLibraryPlugin.js +1 -1
- package/lib/library/UmdLibraryPlugin.js +39 -39
- package/lib/logging/createConsoleLogger.js +1 -19
- package/lib/node/ReadFileChunkLoadingRuntimeModule.js +8 -8
- package/lib/node/RequireChunkLoadingRuntimeModule.js +8 -8
- package/lib/node/nodeConsole.js +1 -5
- package/lib/optimize/ConcatenatedModule.js +7 -7
- package/lib/optimize/InnerGraphPlugin.js +9 -1
- package/lib/optimize/MangleExportsPlugin.js +5 -1
- package/lib/optimize/ModuleConcatenationPlugin.js +2 -2
- package/lib/optimize/RemoveParentModulesPlugin.js +123 -47
- package/lib/optimize/SideEffectsFlagPlugin.js +15 -3
- package/lib/optimize/SplitChunksPlugin.js +16 -16
- package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +2 -2
- package/lib/rules/RuleSetCompiler.js +1 -1
- package/lib/runtime/AutoPublicPathRuntimeModule.js +2 -2
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +4 -4
- package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +4 -4
- package/lib/runtime/LoadScriptRuntimeModule.js +2 -2
- package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +23 -22
- package/lib/runtime/StartupEntrypointRuntimeModule.js +2 -2
- package/lib/schemes/HttpUriPlugin.js +1 -1
- package/lib/serialization/FileMiddleware.js +4 -4
- package/lib/serialization/ObjectMiddleware.js +4 -4
- package/lib/sharing/ConsumeSharedPlugin.js +5 -5
- package/lib/sharing/ConsumeSharedRuntimeModule.js +8 -4
- package/lib/sharing/ProvideSharedModule.js +2 -2
- package/lib/sharing/SharePlugin.js +2 -2
- package/lib/sharing/ShareRuntimeModule.js +1 -1
- package/lib/sharing/utils.js +24 -28
- package/lib/stats/DefaultStatsFactoryPlugin.js +10 -10
- package/lib/stats/DefaultStatsPresetPlugin.js +3 -7
- package/lib/stats/DefaultStatsPrinterPlugin.js +34 -31
- package/lib/util/chainedImports.js +7 -6
- package/lib/util/cleverMerge.js +4 -4
- package/lib/util/comparators.js +59 -23
- package/lib/util/hash/xxhash64.js +2 -2
- package/lib/util/identifier.js +2 -2
- package/lib/util/internalSerializables.js +6 -0
- package/lib/util/numberHash.js +64 -52
- package/lib/util/runtime.js +18 -1
- package/lib/util/semver.js +19 -24
- package/lib/util/smartGrouping.js +1 -1
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +53 -28
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +2 -2
- package/lib/wasm-async/AsyncWebAssemblyParser.js +6 -0
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +2 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +13 -13
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +6 -6
- package/package.json +25 -80
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +140 -32
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +6 -0
- package/schemas/plugins/css/CssAutoGeneratorOptions.json +3 -0
- package/schemas/plugins/css/CssAutoParserOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssAutoParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssAutoParserOptions.json +3 -0
- package/schemas/plugins/css/CssGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +6 -0
- package/schemas/plugins/css/CssGlobalGeneratorOptions.json +3 -0
- package/schemas/plugins/css/CssGlobalParserOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssGlobalParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssGlobalParserOptions.json +3 -0
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +6 -0
- package/schemas/plugins/css/CssModuleGeneratorOptions.json +3 -0
- package/schemas/plugins/css/CssModuleParserOptions.check.d.ts +7 -0
- package/schemas/plugins/css/CssModuleParserOptions.check.js +6 -0
- package/schemas/plugins/css/CssModuleParserOptions.json +3 -0
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/types.d.ts +273 -94
@@ -5,6 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
const EnvironmentNotSupportAsyncWarning = require("../EnvironmentNotSupportAsyncWarning");
|
8
9
|
const { JAVASCRIPT_MODULE_TYPE_ESM } = require("../ModuleTypeConstants");
|
9
10
|
const DynamicExports = require("./DynamicExports");
|
10
11
|
const HarmonyCompatibilityDependency = require("./HarmonyCompatibilityDependency");
|
@@ -65,7 +66,7 @@ module.exports = class HarmonyDetectionParserPlugin {
|
|
65
66
|
const module = parser.state.module;
|
66
67
|
if (!this.topLevelAwait) {
|
67
68
|
throw new Error(
|
68
|
-
"The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to
|
69
|
+
"The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enable it)"
|
69
70
|
);
|
70
71
|
}
|
71
72
|
if (!HarmonyExports.isEnabled(parser.state)) {
|
@@ -75,6 +76,11 @@ module.exports = class HarmonyDetectionParserPlugin {
|
|
75
76
|
}
|
76
77
|
/** @type {BuildMeta} */
|
77
78
|
(module.buildMeta).async = true;
|
79
|
+
EnvironmentNotSupportAsyncWarning.check(
|
80
|
+
module,
|
81
|
+
parser.state.compilation.runtimeTemplate,
|
82
|
+
"topLevelAwait"
|
83
|
+
);
|
78
84
|
});
|
79
85
|
|
80
86
|
/**
|
@@ -31,10 +31,10 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
31
31
|
options.reexportExportsPresence !== undefined
|
32
32
|
? ExportPresenceModes.fromUserOption(options.reexportExportsPresence)
|
33
33
|
: options.exportsPresence !== undefined
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
? ExportPresenceModes.fromUserOption(options.exportsPresence)
|
35
|
+
: options.strictExportPresence
|
36
|
+
? ExportPresenceModes.ERROR
|
37
|
+
: ExportPresenceModes.AUTO;
|
38
38
|
}
|
39
39
|
|
40
40
|
apply(parser) {
|
@@ -97,20 +97,20 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
97
97
|
expr.type.endsWith("Declaration") && expr.id
|
98
98
|
? expr.id.name
|
99
99
|
: isFunctionDeclaration
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
100
|
+
? {
|
101
|
+
id: expr.id ? expr.id.name : undefined,
|
102
|
+
range: [
|
103
|
+
expr.range[0],
|
104
|
+
expr.params.length > 0
|
105
|
+
? expr.params[0].range[0]
|
106
|
+
: expr.body.range[0]
|
107
|
+
],
|
108
|
+
prefix: `${expr.async ? "async " : ""}function${
|
109
|
+
expr.generator ? "*" : ""
|
110
|
+
} `,
|
111
|
+
suffix: `(${expr.params.length > 0 ? "" : ") "}`
|
112
|
+
}
|
113
|
+
: undefined
|
114
114
|
);
|
115
115
|
dep.loc = Object.create(statement.loc);
|
116
116
|
dep.loc.index = -1;
|
@@ -130,8 +130,8 @@ class HarmonyExportInitFragment extends InitFragment {
|
|
130
130
|
}
|
131
131
|
|
132
132
|
/**
|
133
|
-
* @param {
|
134
|
-
* @returns {string|Source} the source code that will be included as initialization code
|
133
|
+
* @param {GenerateContext} context context
|
134
|
+
* @returns {string | Source} the source code that will be included as initialization code
|
135
135
|
*/
|
136
136
|
getContent({ runtimeTemplate, runtimeRequirements }) {
|
137
137
|
runtimeRequirements.add(RuntimeGlobals.exports);
|
@@ -141,10 +141,10 @@ class HarmonyExportInitFragment extends InitFragment {
|
|
141
141
|
this.unusedExports.size > 1
|
142
142
|
? `/* unused harmony exports ${joinIterableWithComma(
|
143
143
|
this.unusedExports
|
144
|
-
|
144
|
+
)} */\n`
|
145
145
|
: this.unusedExports.size > 0
|
146
|
-
|
147
|
-
|
146
|
+
? `/* unused harmony export ${first(this.unusedExports)} */\n`
|
147
|
+
: "";
|
148
148
|
const definitions = [];
|
149
149
|
const orderedExportMap = Array.from(this.exportMap).sort(([a], [b]) =>
|
150
150
|
a < b ? -1 : 1
|
@@ -160,7 +160,7 @@ class HarmonyExportInitFragment extends InitFragment {
|
|
160
160
|
this.exportMap.size > 0
|
161
161
|
? `/* harmony export */ ${RuntimeGlobals.definePropertyGetters}(${
|
162
162
|
this.exportsArgument
|
163
|
-
|
163
|
+
}, {${definitions.join(",")}\n/* harmony export */ });\n`
|
164
164
|
: "";
|
165
165
|
return `${definePart}${unusedPart}`;
|
166
166
|
}
|
@@ -157,8 +157,8 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
157
157
|
const moreInfo = !Array.isArray(providedExports)
|
158
158
|
? " (possible exports unknown)"
|
159
159
|
: providedExports.length === 0
|
160
|
-
|
161
|
-
|
160
|
+
? " (module has no exports)"
|
161
|
+
: ` (possible exports: ${providedExports.join(", ")})`;
|
162
162
|
return [
|
163
163
|
new HarmonyLinkingError(
|
164
164
|
`export ${ids
|
@@ -287,8 +287,8 @@ HarmonyImportDependency.Template = class HarmonyImportDependencyTemplate extends
|
|
287
287
|
const runtimeCondition = dep.weak
|
288
288
|
? false
|
289
289
|
: connection
|
290
|
-
|
291
|
-
|
290
|
+
? filterRuntime(runtime, r => connection.isTargetActive(r))
|
291
|
+
: true;
|
292
292
|
|
293
293
|
if (module && referencedModule) {
|
294
294
|
let emittedModules = importEmittedMap.get(module);
|
@@ -75,10 +75,10 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
75
75
|
options.importExportsPresence !== undefined
|
76
76
|
? ExportPresenceModes.fromUserOption(options.importExportsPresence)
|
77
77
|
: options.exportsPresence !== undefined
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
? ExportPresenceModes.fromUserOption(options.exportsPresence)
|
79
|
+
: options.strictExportPresence
|
80
|
+
? ExportPresenceModes.ERROR
|
81
|
+
: ExportPresenceModes.AUTO;
|
82
82
|
this.strictThisContextOnImports = options.strictThisContextOnImports;
|
83
83
|
}
|
84
84
|
|
@@ -240,7 +240,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
240
240
|
? getNonOptionalMemberChain(
|
241
241
|
expression,
|
242
242
|
members.length - nonOptionalMembers.length
|
243
|
-
|
243
|
+
)
|
244
244
|
: expression;
|
245
245
|
const ids = settings.ids.concat(nonOptionalMembers);
|
246
246
|
const dep = new HarmonyImportSpecifierDependency(
|
@@ -286,7 +286,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
286
286
|
? getNonOptionalMemberChain(
|
287
287
|
callee,
|
288
288
|
members.length - nonOptionalMembers.length
|
289
|
-
|
289
|
+
)
|
290
290
|
: callee;
|
291
291
|
const ids = settings.ids.concat(nonOptionalMembers);
|
292
292
|
const dep = new HarmonyImportSpecifierDependency(
|
@@ -48,12 +48,32 @@ class ImportDependency extends ModuleDependency {
|
|
48
48
|
* @returns {(string[] | ReferencedExport)[]} referenced exports
|
49
49
|
*/
|
50
50
|
getReferencedExports(moduleGraph, runtime) {
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
51
|
+
if (!this.referencedExports) return Dependency.EXPORTS_OBJECT_REFERENCED;
|
52
|
+
const refs = [];
|
53
|
+
for (const referencedExport of this.referencedExports) {
|
54
|
+
if (referencedExport[0] === "default") {
|
55
|
+
const selfModule = moduleGraph.getParentModule(this);
|
56
|
+
const importedModule =
|
57
|
+
/** @type {Module} */
|
58
|
+
(moduleGraph.getModule(this));
|
59
|
+
const exportsType = importedModule.getExportsType(
|
60
|
+
moduleGraph,
|
61
|
+
/** @type {BuildMeta} */
|
62
|
+
(selfModule.buildMeta).strictHarmonyModule
|
63
|
+
);
|
64
|
+
if (
|
65
|
+
exportsType === "default-only" ||
|
66
|
+
exportsType === "default-with-named"
|
67
|
+
) {
|
68
|
+
return Dependency.EXPORTS_OBJECT_REFERENCED;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
refs.push({
|
72
|
+
name: referencedExport,
|
73
|
+
canMangle: false
|
74
|
+
});
|
75
|
+
}
|
76
|
+
return refs;
|
57
77
|
}
|
58
78
|
|
59
79
|
/**
|
@@ -19,7 +19,7 @@ const NullDependency = require("./NullDependency");
|
|
19
19
|
class LocalModuleDependency extends NullDependency {
|
20
20
|
/**
|
21
21
|
* @param {LocalModule} localModule local module
|
22
|
-
* @param {Range} range range
|
22
|
+
* @param {Range | undefined} range range
|
23
23
|
* @param {boolean} callNew true, when the local module should be called with new
|
24
24
|
*/
|
25
25
|
constructor(localModule, range, callNew) {
|
@@ -7,7 +7,7 @@
|
|
7
7
|
|
8
8
|
const { UsageState } = require("../ExportsInfo");
|
9
9
|
const makeSerializable = require("../util/makeSerializable");
|
10
|
-
const { filterRuntime } = require("../util/runtime");
|
10
|
+
const { filterRuntime, deepMergeRuntime } = require("../util/runtime");
|
11
11
|
const NullDependency = require("./NullDependency");
|
12
12
|
|
13
13
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
@@ -93,7 +93,14 @@ PureExpressionDependency.Template = class PureExpressionDependencyTemplate exten
|
|
93
93
|
apply(
|
94
94
|
dependency,
|
95
95
|
source,
|
96
|
-
{
|
96
|
+
{
|
97
|
+
chunkGraph,
|
98
|
+
moduleGraph,
|
99
|
+
runtime,
|
100
|
+
runtimes,
|
101
|
+
runtimeTemplate,
|
102
|
+
runtimeRequirements
|
103
|
+
}
|
97
104
|
) {
|
98
105
|
const dep = /** @type {PureExpressionDependency} */ (dependency);
|
99
106
|
|
@@ -101,7 +108,8 @@ PureExpressionDependency.Template = class PureExpressionDependencyTemplate exten
|
|
101
108
|
if (usedByExports !== false) {
|
102
109
|
const selfModule = moduleGraph.getParentModule(dep);
|
103
110
|
const exportsInfo = moduleGraph.getExportsInfo(selfModule);
|
104
|
-
const
|
111
|
+
const merged = deepMergeRuntime(runtimes, runtime);
|
112
|
+
const runtimeCondition = filterRuntime(merged, runtime => {
|
105
113
|
for (const exportName of usedByExports) {
|
106
114
|
if (exportsInfo.getUsed(exportName, runtime) !== UsageState.Unused) {
|
107
115
|
return true;
|
@@ -113,7 +121,7 @@ PureExpressionDependency.Template = class PureExpressionDependencyTemplate exten
|
|
113
121
|
if (runtimeCondition !== false) {
|
114
122
|
const condition = runtimeTemplate.runtimeConditionExpression({
|
115
123
|
chunkGraph,
|
116
|
-
runtime,
|
124
|
+
runtime: merged,
|
117
125
|
runtimeCondition,
|
118
126
|
runtimeRequirements
|
119
127
|
});
|
@@ -69,7 +69,7 @@ RequireIncludeDependency.Template = class RequireIncludeDependencyTemplate exten
|
|
69
69
|
`require.include ${runtimeTemplate.requestShortener.shorten(
|
70
70
|
dep.request
|
71
71
|
)}`
|
72
|
-
|
72
|
+
)
|
73
73
|
: "";
|
74
74
|
|
75
75
|
source.replace(dep.range[0], dep.range[1] - 1, `undefined${comment}`);
|
@@ -184,8 +184,9 @@ class WorkerPlugin {
|
|
184
184
|
}
|
185
185
|
}
|
186
186
|
const insertType = expr.properties.length > 0 ? "comma" : "single";
|
187
|
-
const insertLocation =
|
188
|
-
expr.properties[expr.properties.length - 1].range
|
187
|
+
const insertLocation = /** @type {Range} */ (
|
188
|
+
expr.properties[expr.properties.length - 1].range
|
189
|
+
)[1];
|
189
190
|
return {
|
190
191
|
expressions,
|
191
192
|
otherElements,
|
@@ -240,7 +241,7 @@ class WorkerPlugin {
|
|
240
241
|
insertLocation: arg2
|
241
242
|
? /** @type {Range} */ (arg2.range)
|
242
243
|
: /** @type {Range} */ (arg1.range)[1]
|
243
|
-
|
244
|
+
};
|
244
245
|
const { options: importOptions, errors: commentErrors } =
|
245
246
|
parser.parseCommentOptions(/** @type {Range} */ (expr.range));
|
246
247
|
|
@@ -429,6 +430,12 @@ class WorkerPlugin {
|
|
429
430
|
const pattern = item.slice(1, firstDot);
|
430
431
|
const itemMembers = item.slice(firstDot + 1, -2);
|
431
432
|
|
433
|
+
parser.hooks.preDeclarator.tap(PLUGIN_NAME, (decl, statement) => {
|
434
|
+
if (decl.id.type === "Identifier" && decl.id.name === pattern) {
|
435
|
+
parser.tagVariable(decl.id.name, WorkerSpecifierTag);
|
436
|
+
return true;
|
437
|
+
}
|
438
|
+
});
|
432
439
|
parser.hooks.pattern.for(pattern).tap(PLUGIN_NAME, pattern => {
|
433
440
|
parser.tagVariable(pattern.name, WorkerSpecifierTag);
|
434
441
|
return true;
|
@@ -9,8 +9,8 @@
|
|
9
9
|
/** @typedef {import("estree").SpreadElement} SpreadElement */
|
10
10
|
|
11
11
|
/**
|
12
|
-
* @param {Expression} expr expressions
|
13
|
-
* @returns {{fn: TODO, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined }} function expression with additional information
|
12
|
+
* @param {Expression | SpreadElement} expr expressions
|
13
|
+
* @returns {{fn: TODO, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined } | undefined} function expression with additional information
|
14
14
|
*/
|
15
15
|
module.exports = expr => {
|
16
16
|
// <FunctionExpression>
|
@@ -172,7 +172,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
172
172
|
]),
|
173
173
|
"}",
|
174
174
|
withOnChunkLoad ? `${RuntimeGlobals.onChunksLoaded}();` : ""
|
175
|
-
|
175
|
+
])}`
|
176
176
|
: "// no install chunk",
|
177
177
|
"",
|
178
178
|
withLoading
|
@@ -222,25 +222,25 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
222
222
|
"}"
|
223
223
|
]),
|
224
224
|
"}"
|
225
|
-
|
225
|
+
])
|
226
226
|
: Template.indent(["installedChunks[chunkId] = 0;"])
|
227
227
|
)};`
|
228
|
-
|
228
|
+
])
|
229
229
|
: "// no chunk on demand loading",
|
230
230
|
"",
|
231
231
|
withExternalInstallChunk
|
232
232
|
? Template.asString([
|
233
233
|
`${RuntimeGlobals.externalInstallChunk} = installChunk;`
|
234
|
-
|
234
|
+
])
|
235
235
|
: "// no external install chunk",
|
236
236
|
"",
|
237
237
|
withOnChunkLoad
|
238
238
|
? `${
|
239
239
|
RuntimeGlobals.onChunksLoaded
|
240
|
-
|
240
|
+
}.j = ${runtimeTemplate.returningFunction(
|
241
241
|
"installedChunks[chunkId] === 0",
|
242
242
|
"chunkId"
|
243
|
-
|
243
|
+
)};`
|
244
244
|
: "// no on chunks loaded"
|
245
245
|
]);
|
246
246
|
}
|
@@ -35,7 +35,6 @@ module.exports = function () {
|
|
35
35
|
var currentUpdateApplyHandlers;
|
36
36
|
var queuedInvalidatedModules;
|
37
37
|
|
38
|
-
// eslint-disable-next-line no-unused-vars
|
39
38
|
$hmrModuleData$ = currentModuleData;
|
40
39
|
|
41
40
|
$interceptModuleExecution$.push(function (options) {
|
@@ -96,8 +95,8 @@ module.exports = function () {
|
|
96
95
|
Object.defineProperty(fn, name, createPropertyDescriptor(name));
|
97
96
|
}
|
98
97
|
}
|
99
|
-
fn.e = function (chunkId) {
|
100
|
-
return trackBlockingPromise(require.e(chunkId));
|
98
|
+
fn.e = function (chunkId, fetchPriority) {
|
99
|
+
return trackBlockingPromise(require.e(chunkId, fetchPriority));
|
101
100
|
};
|
102
101
|
return fn;
|
103
102
|
}
|
@@ -289,8 +288,7 @@ module.exports = function () {
|
|
289
288
|
updatedModules
|
290
289
|
);
|
291
290
|
return promises;
|
292
|
-
},
|
293
|
-
[])
|
291
|
+
}, [])
|
294
292
|
).then(function () {
|
295
293
|
return waitForBlockingPromises(function () {
|
296
294
|
if (applyOnUpdate) {
|
@@ -37,7 +37,7 @@ module.exports = options => (compiler, callback) => {
|
|
37
37
|
: (() => {
|
38
38
|
const http = isHttps ? require("https") : require("http");
|
39
39
|
return http.createServer.bind(http, options.server);
|
40
|
-
|
40
|
+
})();
|
41
41
|
const listen =
|
42
42
|
typeof options.listen === "function"
|
43
43
|
? options.listen
|
@@ -46,7 +46,7 @@ module.exports = options => (compiler, callback) => {
|
|
46
46
|
if (typeof listen === "object" && !("port" in listen))
|
47
47
|
listen = { ...listen, port: undefined };
|
48
48
|
server.listen(listen);
|
49
|
-
|
49
|
+
};
|
50
50
|
|
51
51
|
const protocol = options.protocol || (isHttps ? "https" : "http");
|
52
52
|
|
@@ -109,8 +109,8 @@ module.exports = options => (compiler, callback) => {
|
|
109
109
|
addr.address === "::" || addr.address === "0.0.0.0"
|
110
110
|
? `${protocol}://localhost:${addr.port}`
|
111
111
|
: addr.family === "IPv6"
|
112
|
-
|
113
|
-
|
112
|
+
? `${protocol}://[${addr.address}]:${addr.port}`
|
113
|
+
: `${protocol}://${addr.address}:${addr.port}`;
|
114
114
|
logger.log(
|
115
115
|
`Server-Sent-Events server for lazy compilation open at ${urlBase}.`
|
116
116
|
);
|
package/lib/index.js
CHANGED
@@ -37,6 +37,7 @@ const memoize = require("./util/memoize");
|
|
37
37
|
/** @typedef {import("./Compilation").EntryOptions} EntryOptions */
|
38
38
|
/** @typedef {import("./Compilation").PathData} PathData */
|
39
39
|
/** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */
|
40
|
+
/** @typedef {import("./MultiCompiler").MultiCompilerOptions} MultiCompilerOptions */
|
40
41
|
/** @typedef {import("./MultiStats")} MultiStats */
|
41
42
|
/** @typedef {import("./NormalModuleFactory").ResolveData} ResolveData */
|
42
43
|
/** @typedef {import("./Parser").ParserState} ParserState */
|
@@ -270,6 +271,9 @@ module.exports = mergeExports(fn, {
|
|
270
271
|
get MultiCompiler() {
|
271
272
|
return require("./MultiCompiler");
|
272
273
|
},
|
274
|
+
get OptimizationStages() {
|
275
|
+
return require("./OptimizationStages");
|
276
|
+
},
|
273
277
|
get Parser() {
|
274
278
|
return require("./Parser");
|
275
279
|
},
|
@@ -190,6 +190,8 @@ class JavascriptGenerator extends Generator {
|
|
190
190
|
);
|
191
191
|
}
|
192
192
|
|
193
|
+
let chunkInitFragments;
|
194
|
+
|
193
195
|
const templateContext = {
|
194
196
|
runtimeTemplate: generateContext.runtimeTemplate,
|
195
197
|
dependencyTemplates: generateContext.dependencyTemplates,
|
@@ -197,10 +199,23 @@ class JavascriptGenerator extends Generator {
|
|
197
199
|
chunkGraph: generateContext.chunkGraph,
|
198
200
|
module,
|
199
201
|
runtime: generateContext.runtime,
|
202
|
+
runtimes: generateContext.runtimes,
|
200
203
|
runtimeRequirements: generateContext.runtimeRequirements,
|
201
204
|
concatenationScope: generateContext.concatenationScope,
|
202
205
|
codeGenerationResults: generateContext.codeGenerationResults,
|
203
|
-
initFragments
|
206
|
+
initFragments,
|
207
|
+
get chunkInitFragments() {
|
208
|
+
if (!chunkInitFragments) {
|
209
|
+
const data = generateContext.getData();
|
210
|
+
chunkInitFragments = data.get("chunkInitFragments");
|
211
|
+
if (!chunkInitFragments) {
|
212
|
+
chunkInitFragments = [];
|
213
|
+
data.set("chunkInitFragments", chunkInitFragments);
|
214
|
+
}
|
215
|
+
}
|
216
|
+
|
217
|
+
return chunkInitFragments;
|
218
|
+
}
|
204
219
|
};
|
205
220
|
|
206
221
|
template.apply(dependency, source, templateContext);
|
@@ -679,8 +679,8 @@ class JavascriptModulesPlugin {
|
|
679
679
|
return strictHeader
|
680
680
|
? new ConcatSource(strictHeader, source, ";")
|
681
681
|
: renderContext.runtimeTemplate.isModule()
|
682
|
-
|
683
|
-
|
682
|
+
? source
|
683
|
+
: new ConcatSource(source, ";");
|
684
684
|
}
|
685
685
|
|
686
686
|
/**
|
@@ -751,7 +751,7 @@ class JavascriptModulesPlugin {
|
|
751
751
|
inlinedModules
|
752
752
|
? allModules.filter(
|
753
753
|
m => !(/** @type {Set<Module>} */ (inlinedModules).has(m))
|
754
|
-
|
754
|
+
)
|
755
755
|
: allModules,
|
756
756
|
module => this.renderModule(module, chunkRenderContext, hooks, true),
|
757
757
|
prefix
|
@@ -837,14 +837,14 @@ class JavascriptModulesPlugin {
|
|
837
837
|
let iife = innerStrict
|
838
838
|
? "it need to be in strict mode."
|
839
839
|
: inlinedModules.size > 1
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
840
|
+
? // TODO check globals and top-level declarations of other entries and chunk modules
|
841
|
+
// to make a better decision
|
842
|
+
"it need to be isolated against other entry modules."
|
843
|
+
: chunkModules
|
844
|
+
? "it need to be isolated against other modules in the chunk."
|
845
|
+
: exports && !webpackExports
|
846
|
+
? `it uses a non-standard name for the exports (${m.exportsArgument}).`
|
847
|
+
: hooks.embedInRuntimeBailout.call(m, renderContext);
|
848
848
|
let footer;
|
849
849
|
if (iife !== undefined) {
|
850
850
|
startupSource.add(
|
@@ -1310,14 +1310,14 @@ class JavascriptModulesPlugin {
|
|
1310
1310
|
`${RuntimeGlobals.interceptModuleExecution}.forEach(function(handler) { handler(execOptions); });`,
|
1311
1311
|
"module = execOptions.module;",
|
1312
1312
|
"execOptions.factory.call(module.exports, module, module.exports, execOptions.require);"
|
1313
|
-
|
1313
|
+
])
|
1314
1314
|
: runtimeRequirements.has(RuntimeGlobals.thisAsExports)
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1315
|
+
? Template.asString([
|
1316
|
+
`__webpack_modules__[moduleId].call(module.exports, module, module.exports, ${RuntimeGlobals.require});`
|
1317
|
+
])
|
1318
|
+
: Template.asString([
|
1319
|
+
`__webpack_modules__[moduleId](module, module.exports, ${RuntimeGlobals.require});`
|
1320
|
+
]);
|
1321
1321
|
const needModuleId = runtimeRequirements.has(RuntimeGlobals.moduleId);
|
1322
1322
|
const needModuleLoaded = runtimeRequirements.has(
|
1323
1323
|
RuntimeGlobals.moduleLoaded
|
@@ -1330,7 +1330,7 @@ class JavascriptModulesPlugin {
|
|
1330
1330
|
? Template.indent([
|
1331
1331
|
"if (cachedModule.error !== undefined) throw cachedModule.error;",
|
1332
1332
|
"return cachedModule.exports;"
|
1333
|
-
|
1333
|
+
])
|
1334
1334
|
: Template.indent("return cachedModule.exports;"),
|
1335
1335
|
"}",
|
1336
1336
|
"// Create a new module (and put it into the cache)",
|
@@ -1353,27 +1353,27 @@ class JavascriptModulesPlugin {
|
|
1353
1353
|
"if(threw) delete __webpack_module_cache__[moduleId];"
|
1354
1354
|
]),
|
1355
1355
|
"}"
|
1356
|
-
|
1356
|
+
])
|
1357
1357
|
: outputOptions.strictModuleErrorHandling
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1358
|
+
? Template.asString([
|
1359
|
+
"// Execute the module function",
|
1360
|
+
"try {",
|
1361
|
+
Template.indent(moduleExecution),
|
1362
|
+
"} catch(e) {",
|
1363
|
+
Template.indent(["module.error = e;", "throw e;"]),
|
1364
|
+
"}"
|
1365
|
+
])
|
1366
|
+
: Template.asString([
|
1367
|
+
"// Execute the module function",
|
1368
|
+
moduleExecution
|
1369
|
+
]),
|
1370
1370
|
needModuleLoaded
|
1371
1371
|
? Template.asString([
|
1372
1372
|
"",
|
1373
1373
|
"// Flag the module as loaded",
|
1374
1374
|
`${RuntimeGlobals.moduleLoaded} = true;`,
|
1375
1375
|
""
|
1376
|
-
|
1376
|
+
])
|
1377
1377
|
: "",
|
1378
1378
|
"// Return the exports of the module",
|
1379
1379
|
"return module.exports;"
|