webpack 5.108.3 → 5.109.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.
- package/lib/APIPlugin.js +48 -29
- package/lib/CacheFacade.js +8 -0
- package/lib/ChunkGroup.js +1 -0
- package/lib/CompatibilityPlugin.js +31 -29
- package/lib/Compilation.js +50 -8
- package/lib/ConstPlugin.js +11 -11
- package/lib/ContextModule.js +239 -6
- package/lib/ContextModuleFactory.js +139 -14
- package/lib/DefinePlugin.js +396 -101
- package/lib/Entrypoint.js +1 -1
- package/lib/ExportsInfoApiPlugin.js +2 -2
- package/lib/ExternalModule.js +107 -5
- package/lib/ExternalModuleFactoryPlugin.js +20 -1
- package/lib/FileSystemInfo.js +130 -74
- package/lib/FlagDependencyExportsPlugin.js +55 -8
- package/lib/HotModuleReplacementPlugin.js +18 -15
- package/lib/LazyBarrel.js +30 -3
- package/lib/Module.js +3 -0
- package/lib/ModuleFilenameHelpers.js +2 -2
- package/lib/ModuleTypeConstants.js +8 -1
- package/lib/MultiCompiler.js +13 -2
- package/lib/MultiWatching.js +1 -0
- package/lib/NodeStuffPlugin.js +51 -33
- package/lib/NormalModule.js +169 -405
- package/lib/NormalModuleFactory.js +76 -2
- package/lib/ProgressPlugin.js +211 -119
- package/lib/ProvidePlugin.js +2 -2
- package/lib/RuntimeGlobals.js +47 -0
- package/lib/RuntimePlugin.js +33 -0
- package/lib/RuntimeTemplate.js +304 -16
- package/lib/UseStrictPlugin.js +1 -1
- package/lib/WebpackIsIncludedPlugin.js +1 -1
- package/lib/WebpackOptionsApply.js +24 -19
- package/lib/asset/AssetGenerator.js +110 -28
- package/lib/asset/AssetModulesPlugin.js +92 -2
- package/lib/asset/WebManifestGenerator.js +164 -0
- package/lib/asset/WebManifestParser.js +130 -0
- package/lib/async-modules/AwaitDependenciesInitFragment.js +14 -4
- package/lib/async-modules/isGeneratorLowered.js +26 -0
- package/lib/cache/PackFileCacheStrategy.js +9 -3
- package/lib/config/browserslistTargetHandler.js +40 -0
- package/lib/config/defaults.js +222 -32
- package/lib/config/normalization.js +26 -0
- package/lib/config/target.js +9 -1
- package/lib/css/CssGenerator.js +73 -73
- package/lib/css/CssLoadingRuntimeModule.js +5 -1
- package/lib/css/CssModulesPlugin.js +92 -53
- package/lib/css/CssParser.js +843 -302
- package/lib/css/syntax.js +1219 -483
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -6
- package/lib/dependencies/AMDPlugin.js +2 -2
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +13 -13
- package/lib/dependencies/CommonJsDependencyHelpers.js +39 -0
- package/lib/dependencies/CommonJsExportsDependency.js +47 -2
- package/lib/dependencies/CommonJsExportsParserPlugin.js +10 -10
- package/lib/dependencies/CommonJsImportsParserPlugin.js +18 -18
- package/lib/dependencies/CommonJsPlugin.js +2 -2
- package/lib/dependencies/CommonJsRequireDependency.js +26 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +32 -1
- package/lib/dependencies/ContextDependencyHelpers.js +3 -3
- package/lib/dependencies/CreateRequireParserPlugin.js +6 -6
- package/lib/dependencies/CssIcssExportDependency.js +190 -87
- package/lib/dependencies/CssUrlDependency.js +35 -4
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +2 -2
- package/lib/dependencies/HarmonyCompatibilityDependency.js +32 -14
- package/lib/dependencies/HarmonyDetectionParserPlugin.js +43 -13
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +7 -19
- package/lib/dependencies/HarmonyImportDependency.js +12 -1
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +34 -107
- package/lib/dependencies/HarmonyImportGuard.js +192 -20
- package/lib/dependencies/HarmonyModulesPlugin.js +6 -0
- package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +1 -1
- package/lib/dependencies/HtmlEntryDependency.js +797 -172
- package/lib/dependencies/HtmlSourceDependency.js +26 -0
- package/lib/dependencies/ImportDependency.js +43 -1
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +31 -18
- package/lib/dependencies/ImportMetaContextPlugin.js +38 -7
- package/lib/dependencies/ImportMetaGlobDependency.js +81 -0
- package/lib/dependencies/ImportMetaGlobDependencyParserPlugin.js +78 -0
- package/lib/dependencies/ImportMetaGlobHelpers.js +660 -0
- package/lib/dependencies/ImportMetaPlugin.js +532 -180
- package/lib/dependencies/ImportMetaResolveDependency.js +90 -0
- package/lib/dependencies/ImportParserPlugin.js +87 -26
- package/lib/dependencies/ImportPhase.js +10 -8
- package/lib/dependencies/LoaderPlugin.js +5 -1
- package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +3 -6
- package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +4 -11
- package/lib/dependencies/SystemPlugin.js +2 -4
- package/lib/dependencies/TopLevelAwaitDependency.js +93 -0
- package/lib/dependencies/URLDependency.js +141 -21
- package/lib/dependencies/{WorkerPlugin.js → WorkerAndWorkletPlugin.js} +324 -112
- package/lib/dependencies/WorkerDependency.js +86 -18
- package/lib/dependencies/WorkletDependency.js +278 -0
- package/lib/dll/DelegatedModuleFactoryPlugin.js +19 -0
- package/lib/errors/EnvironmentNotSupportAsyncWarning.js +1 -1
- package/lib/errors/LoaderLoadingError.js +20 -0
- package/lib/errors/ModuleParseError.js +39 -22
- package/lib/errors/NodeStuffInWebError.js +1 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +47 -14
- package/lib/esm/ModuleChunkLoadingPlugin.js +8 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +29 -1
- package/lib/hmr/lazyCompilationBackend.js +32 -8
- package/lib/html/HtmlGenerator.js +940 -91
- package/lib/html/HtmlModule.js +3 -2
- package/lib/html/HtmlModulesPlugin.js +625 -170
- package/lib/html/HtmlParser.js +812 -340
- package/lib/html/favicon.svg +1 -0
- package/lib/html/syntax.js +2116 -834
- package/lib/ids/IdHelpers.js +1 -1
- package/lib/index.js +6 -0
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -5
- package/lib/javascript/BasicEvaluatedExpression.js +366 -48
- package/lib/javascript/JavascriptGenerator.js +197 -49
- package/lib/javascript/JavascriptModulesPlugin.js +178 -24
- package/lib/javascript/JavascriptParser.js +711 -355
- package/lib/javascript/JavascriptParserHelpers.js +3 -6
- package/lib/javascript/syntax.js +4380 -0
- package/lib/library/ModuleLibraryPlugin.js +38 -1
- package/lib/loaders/LoaderRunner.js +714 -0
- package/lib/loaders/loadLoader.js +100 -0
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +19 -0
- package/lib/node/ReadFileCompileWasmPlugin.js +14 -0
- package/lib/optimize/ConcatenatedModule.js +120 -16
- package/lib/optimize/FlagIncludedChunksPlugin.js +13 -3
- package/lib/optimize/InnerGraphPlugin.js +50 -30
- package/lib/optimize/ModuleConcatenationPlugin.js +69 -3
- package/lib/optimize/SideEffectsFlagPlugin.js +86 -43
- package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +15 -0
- package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +24 -13
- package/lib/prefetch/ResourceHintPlugin.js +663 -0
- package/lib/prefetch/ResourceHintRuntimeModule.js +149 -0
- package/lib/prefetch/StartupAssetHintRuntimeModule.js +210 -0
- package/lib/prefetch/parseResourceHintOptions.js +103 -0
- package/lib/rules/RuleSetCompiler.js +114 -0
- package/lib/runtime/AsyncModuleGeneratorRuntimeModule.js +56 -0
- package/lib/runtime/AsyncModuleRuntimeModule.js +24 -8
- package/lib/runtime/AutoPublicPathRuntimeModule.js +7 -1
- package/lib/runtime/CommonJsWrapRuntimeModule.js +37 -0
- package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +59 -0
- package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +204 -8
- package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +4 -1
- package/lib/schemes/HttpUriPlugin.js +40 -1
- package/lib/schemes/VirtualUrlPlugin.js +1 -2
- package/lib/serialization/FileMiddleware.js +29 -3
- package/lib/stats/DefaultStatsFactoryPlugin.js +32 -3
- package/lib/stats/DefaultStatsPresetPlugin.js +2 -0
- package/lib/stats/DefaultStatsPrinterPlugin.js +12 -2
- package/lib/stats/StatsFactory.js +15 -8
- package/lib/url/URLParserPlugin.js +98 -19
- package/lib/util/AsyncQueue.js +122 -72
- package/lib/util/LocConverter.js +9 -8
- package/lib/util/SetHelpers.js +1 -1
- package/lib/util/SourceProcessor.js +41 -28
- package/lib/util/StackedMap.js +122 -48
- package/lib/util/binarySearchBounds.js +2 -2
- package/lib/util/concatenate.js +40 -14
- package/lib/util/createHooksRegistry.js +13 -5
- package/lib/util/dataURL.js +2 -2
- package/lib/util/deterministicGrouping.js +7 -5
- package/lib/util/formatSize.js +6 -2
- package/lib/util/globUtils.js +710 -0
- package/lib/util/identifier.js +23 -6
- package/lib/util/implicitTypeLoaderFallback.js +62 -0
- package/lib/util/internalSerializables.js +88 -71
- package/lib/util/magicComment.js +121 -25
- package/lib/util/numberHash.js +2 -2
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +24 -18
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +33 -22
- package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +79 -16
- package/lib/web/FetchCompileAsyncWasmPlugin.js +19 -0
- package/lib/web/FetchCompileWasmPlugin.js +14 -0
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -0
- package/lib/webpack.js +65 -0
- package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +3 -0
- package/module.d.ts +21 -0
- package/package.json +14 -13
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +759 -36
- package/schemas/plugins/HtmlParserOptions.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.check.js +1 -1
- package/schemas/plugins/ProgressPlugin.json +17 -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 +1 -0
- package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/types.d.ts +1300 -325
|
@@ -12,6 +12,7 @@ const ModuleDependency = require("./ModuleDependency");
|
|
|
12
12
|
|
|
13
13
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
14
14
|
/** @typedef {import("../AsyncDependenciesBlock")} AsyncDependenciesBlock */
|
|
15
|
+
/** @typedef {import("../Chunk")} Chunk */
|
|
15
16
|
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
|
16
17
|
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
|
17
18
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
@@ -23,12 +24,23 @@ const ModuleDependency = require("./ModuleDependency");
|
|
|
23
24
|
/** @typedef {import("../util/Hash")} Hash */
|
|
24
25
|
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
25
26
|
|
|
27
|
+
/**
|
|
28
|
+
* @typedef {object} ResourceHint
|
|
29
|
+
* @property {true=} prefetch emit `<link rel="prefetch">`
|
|
30
|
+
* @property {true=} preload emit `<link rel="preload">` (wins over prefetch when both are set)
|
|
31
|
+
* @property {("high" | "low" | "auto")=} fetchPriority value for the `fetchpriority` attribute
|
|
32
|
+
* @property {string=} as override for the `as` attribute (defaults to `"script"`)
|
|
33
|
+
* @property {string=} type value for the `type` attribute
|
|
34
|
+
* @property {string=} media value for the `media` attribute
|
|
35
|
+
*/
|
|
36
|
+
|
|
26
37
|
/**
|
|
27
38
|
* Represents the worker dependency runtime component.
|
|
28
39
|
* @typedef {object} WorkerDependencyOptions
|
|
29
40
|
* @property {string=} publicPath public path for the worker
|
|
30
41
|
* @property {boolean=} needNewUrl true when need generate `new URL(...)`, otherwise false
|
|
31
42
|
* @property {Range=} workerConstructorRange range of the global `Worker` constructor, set only for the `new Worker()` global syntax that needs a node-target rewrite
|
|
43
|
+
* @property {ResourceHint=} resourceHint resource hint to inject for the worker chunk
|
|
32
44
|
*/
|
|
33
45
|
|
|
34
46
|
class WorkerDependency extends ModuleDependency {
|
|
@@ -120,24 +132,77 @@ WorkerDependency.Template = class WorkerDependencyTemplate extends (
|
|
|
120
132
|
chunkGraph.getBlockChunkGroup(block)
|
|
121
133
|
);
|
|
122
134
|
const chunk = entrypoint.getEntrypointChunk();
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
135
|
+
|
|
136
|
+
// For ESM module output emit the analyzable `new URL("./worker.<name>.js",
|
|
137
|
+
// import.meta.url)` form (literal specifier, no runtime helpers) so other bundlers
|
|
138
|
+
// and webpack itself can statically follow the worker. Resource-hint workers keep
|
|
139
|
+
// the runtime form because the hint needs the runtime chunk reference.
|
|
140
|
+
const analyzableSpecifier =
|
|
141
|
+
!dep.options.resourceHint && runtimeTemplate.supportsAnalyzableEsm()
|
|
142
|
+
? runtimeTemplate._getAnalyzableChunkSpecifier(
|
|
143
|
+
dep.options.publicPath,
|
|
144
|
+
chunk,
|
|
145
|
+
templateContext.module,
|
|
146
|
+
chunkGraph
|
|
147
|
+
)
|
|
148
|
+
: null;
|
|
149
|
+
|
|
150
|
+
if (analyzableSpecifier !== null) {
|
|
151
|
+
const urlArgs = `/* worker import */ ${analyzableSpecifier}, ${runtimeTemplate.outputOptions.importMetaName}.url`;
|
|
152
|
+
source.replace(
|
|
153
|
+
dep.range[0],
|
|
154
|
+
dep.range[1] - 1,
|
|
155
|
+
dep.options.needNewUrl ? `new URL(${urlArgs})` : urlArgs
|
|
156
|
+
);
|
|
157
|
+
} else {
|
|
158
|
+
// We use the workerPublicPath option if provided, else we fallback to the RuntimeGlobal publicPath
|
|
159
|
+
const workerImportBaseUrl = dep.options.publicPath
|
|
160
|
+
? `"${dep.options.publicPath}"`
|
|
161
|
+
: RuntimeGlobals.publicPath;
|
|
162
|
+
|
|
163
|
+
runtimeRequirements.add(RuntimeGlobals.publicPath);
|
|
164
|
+
runtimeRequirements.add(RuntimeGlobals.baseURI);
|
|
165
|
+
runtimeRequirements.add(RuntimeGlobals.getChunkScriptFilename);
|
|
166
|
+
|
|
167
|
+
const hrefExpr = `${workerImportBaseUrl} + ${
|
|
168
|
+
RuntimeGlobals.getChunkScriptFilename
|
|
169
|
+
}(${JSON.stringify(chunk.id)})`;
|
|
170
|
+
|
|
171
|
+
const hint = dep.options.resourceHint;
|
|
172
|
+
const rel =
|
|
173
|
+
hint && hint.preload
|
|
174
|
+
? "preload"
|
|
175
|
+
: hint && hint.prefetch
|
|
176
|
+
? "prefetch"
|
|
177
|
+
: null;
|
|
178
|
+
let wrappedHref;
|
|
179
|
+
if (rel && hint) {
|
|
180
|
+
const fn =
|
|
181
|
+
rel === "preload"
|
|
182
|
+
? RuntimeGlobals.preloadAsset
|
|
183
|
+
: RuntimeGlobals.prefetchAsset;
|
|
184
|
+
runtimeRequirements.add(fn);
|
|
185
|
+
const as = hint.as || "script";
|
|
186
|
+
const args = [
|
|
187
|
+
hrefExpr,
|
|
188
|
+
JSON.stringify(as),
|
|
189
|
+
hint.type ? JSON.stringify(hint.type) : "undefined",
|
|
190
|
+
hint.media ? JSON.stringify(hint.media) : "undefined",
|
|
191
|
+
hint.fetchPriority ? JSON.stringify(hint.fetchPriority) : "undefined"
|
|
192
|
+
];
|
|
193
|
+
wrappedHref = `${fn}(${args.join(", ")})`;
|
|
194
|
+
} else {
|
|
195
|
+
wrappedHref = hrefExpr;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const workerImportStr = `/* worker import */ ${wrappedHref}, ${RuntimeGlobals.baseURI}`;
|
|
199
|
+
|
|
200
|
+
source.replace(
|
|
201
|
+
dep.range[0],
|
|
202
|
+
dep.range[1] - 1,
|
|
203
|
+
dep.options.needNewUrl ? `new URL(${workerImportStr})` : workerImportStr
|
|
204
|
+
);
|
|
205
|
+
}
|
|
141
206
|
|
|
142
207
|
// `Worker` is global only on the web, so route node (universal or node-only) through `worker_threads`
|
|
143
208
|
const { platform } = runtimeTemplate.compilation.compiler;
|
|
@@ -146,6 +211,9 @@ WorkerDependency.Template = class WorkerDependencyTemplate extends (
|
|
|
146
211
|
ctorRange &&
|
|
147
212
|
(runtimeTemplate.isUniversalTarget() || (platform.node && !platform.web))
|
|
148
213
|
) {
|
|
214
|
+
// `__webpack_require__.wc` attaches to `__webpack_require__`; the analyzable
|
|
215
|
+
// branch adds no other requirement that would emit it, so require it here.
|
|
216
|
+
runtimeRequirements.add(RuntimeGlobals.require);
|
|
149
217
|
runtimeRequirements.add(RuntimeGlobals.worker);
|
|
150
218
|
source.replace(ctorRange[0], ctorRange[1] - 1, RuntimeGlobals.worker);
|
|
151
219
|
}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author sheo13666q
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const Dependency = require("../Dependency");
|
|
9
|
+
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
10
|
+
const Template = require("../Template");
|
|
11
|
+
const makeSerializable = require("../util/makeSerializable");
|
|
12
|
+
const ModuleDependency = require("./ModuleDependency");
|
|
13
|
+
|
|
14
|
+
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
15
|
+
/** @typedef {import("../AsyncDependenciesBlock")} AsyncDependenciesBlock */
|
|
16
|
+
/** @typedef {import("../Chunk")} Chunk */
|
|
17
|
+
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
|
18
|
+
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
|
19
|
+
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
20
|
+
/** @typedef {import("../Entrypoint")} Entrypoint */
|
|
21
|
+
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
22
|
+
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
23
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[WorkletDependencyOptions, Range]>} ObjectDeserializerContext */
|
|
24
|
+
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[WorkletDependencyOptions, Range]>} ObjectSerializerContext */
|
|
25
|
+
/** @typedef {import("../util/Hash")} Hash */
|
|
26
|
+
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {object} WorkletDependencyOptions
|
|
30
|
+
* @property {string=} publicPath public path for the worklet
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
// The wrapper param forwarded as the module argument to the original `addModule`.
|
|
34
|
+
const WORKLET_MODULE = "__webpack_worklet_module__";
|
|
35
|
+
|
|
36
|
+
class WorkletDependency extends ModuleDependency {
|
|
37
|
+
/**
|
|
38
|
+
* Creates an instance of WorkletDependency.
|
|
39
|
+
* @param {string} request request
|
|
40
|
+
* @param {Range} range range of the zero-width insertion point (before the call)
|
|
41
|
+
* @param {Range} callRange range of the call argument list `(<url>)`
|
|
42
|
+
* @param {WorkletDependencyOptions} workletDependencyOptions options
|
|
43
|
+
*/
|
|
44
|
+
constructor(request, range, callRange, workletDependencyOptions) {
|
|
45
|
+
super(request);
|
|
46
|
+
this.range = range;
|
|
47
|
+
/** @type {Range} */
|
|
48
|
+
this.callRange = callRange;
|
|
49
|
+
// If options are updated, don't forget to update the hash and serialization functions
|
|
50
|
+
/** @type {WorkletDependencyOptions} */
|
|
51
|
+
this.options = workletDependencyOptions;
|
|
52
|
+
/** Cache the hash */
|
|
53
|
+
/** @type {undefined | string} */
|
|
54
|
+
this._hashUpdate = undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns list of exports referenced by this dependency
|
|
59
|
+
* @param {ModuleGraph} moduleGraph module graph
|
|
60
|
+
* @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
|
61
|
+
* @returns {ReferencedExports} referenced exports
|
|
62
|
+
*/
|
|
63
|
+
getReferencedExports(moduleGraph, runtime) {
|
|
64
|
+
return Dependency.NO_EXPORTS_REFERENCED;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
get type() {
|
|
68
|
+
return "Worklet.addModule()";
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
get category() {
|
|
72
|
+
return "worker";
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Updates the hash with the data contributed by this instance.
|
|
77
|
+
* @param {Hash} hash hash to be updated
|
|
78
|
+
* @param {UpdateHashContext} context context
|
|
79
|
+
* @returns {void}
|
|
80
|
+
*/
|
|
81
|
+
updateHash(hash, context) {
|
|
82
|
+
if (this._hashUpdate === undefined) {
|
|
83
|
+
this._hashUpdate = JSON.stringify(this.options);
|
|
84
|
+
}
|
|
85
|
+
hash.update(this._hashUpdate);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Serializes this instance into the provided serializer context.
|
|
90
|
+
* @param {ObjectSerializerContext} context context
|
|
91
|
+
*/
|
|
92
|
+
serialize(context) {
|
|
93
|
+
context.write(this.options).write(this.callRange);
|
|
94
|
+
super.serialize(context);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Restores this instance from the provided deserializer context.
|
|
99
|
+
* @param {ObjectDeserializerContext} context context
|
|
100
|
+
*/
|
|
101
|
+
deserialize(context) {
|
|
102
|
+
this.options = context.read();
|
|
103
|
+
const rest = context.rest;
|
|
104
|
+
this.callRange = rest.read();
|
|
105
|
+
super.deserialize(rest.rest);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
WorkletDependency.Template = class WorkletDependencyTemplate extends (
|
|
110
|
+
ModuleDependency.Template
|
|
111
|
+
) {
|
|
112
|
+
/**
|
|
113
|
+
* Applies the plugin by registering its hooks on the compiler.
|
|
114
|
+
* @param {Dependency} dependency the dependency for which the template should be applied
|
|
115
|
+
* @param {ReplaceSource} source the current replace source which can be modified
|
|
116
|
+
* @param {DependencyTemplateContext} templateContext the context object
|
|
117
|
+
* @returns {void}
|
|
118
|
+
*/
|
|
119
|
+
apply(dependency, source, templateContext) {
|
|
120
|
+
const {
|
|
121
|
+
module,
|
|
122
|
+
chunkGraph,
|
|
123
|
+
moduleGraph,
|
|
124
|
+
runtimeRequirements,
|
|
125
|
+
runtimeTemplate
|
|
126
|
+
} = templateContext;
|
|
127
|
+
const dep = /** @type {WorkletDependency} */ (dependency);
|
|
128
|
+
const block = /** @type {AsyncDependenciesBlock} */ (
|
|
129
|
+
moduleGraph.getParentBlock(dependency)
|
|
130
|
+
);
|
|
131
|
+
const entrypoint = /** @type {Entrypoint} */ (
|
|
132
|
+
chunkGraph.getBlockChunkGroup(block)
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
const entryChunk = entrypoint.getEntrypointChunk();
|
|
136
|
+
const runtimeChunk = entrypoint.getRuntimeChunk();
|
|
137
|
+
const referencedChunks = entryChunk.getAllReferencedChunks();
|
|
138
|
+
const runtimeChunkId =
|
|
139
|
+
runtimeChunk && runtimeChunk.id !== null ? runtimeChunk.id : null;
|
|
140
|
+
|
|
141
|
+
// For ESM module output emit the analyzable `new URL("./worklet.<name>.js",
|
|
142
|
+
// import.meta.url)` form (literal specifier, no runtime helpers) so other bundlers
|
|
143
|
+
// and webpack itself can statically follow the worklet. The worklet chunk links its
|
|
144
|
+
// splits via native `import`, so only the entry chunk is referenced.
|
|
145
|
+
const analyzableSpecifier =
|
|
146
|
+
runtimeTemplate.supportsAnalyzableEsm() && entryChunk.id !== null
|
|
147
|
+
? runtimeTemplate._getAnalyzableChunkSpecifier(
|
|
148
|
+
dep.options.publicPath,
|
|
149
|
+
entryChunk,
|
|
150
|
+
module,
|
|
151
|
+
chunkGraph
|
|
152
|
+
)
|
|
153
|
+
: null;
|
|
154
|
+
if (analyzableSpecifier !== null) {
|
|
155
|
+
source.replace(
|
|
156
|
+
dep.callRange[0],
|
|
157
|
+
dep.callRange[1] - 1,
|
|
158
|
+
`(new URL(/* worklet import */ ${analyzableSpecifier}, ${runtimeTemplate.outputOptions.importMetaName}.url))`
|
|
159
|
+
);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const workletImportBaseUrl = dep.options.publicPath
|
|
164
|
+
? JSON.stringify(dep.options.publicPath)
|
|
165
|
+
: RuntimeGlobals.publicPath;
|
|
166
|
+
|
|
167
|
+
runtimeRequirements.add(RuntimeGlobals.publicPath);
|
|
168
|
+
runtimeRequirements.add(RuntimeGlobals.baseURI);
|
|
169
|
+
runtimeRequirements.add(RuntimeGlobals.getChunkScriptFilename);
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* @param {string | number} id chunk id
|
|
173
|
+
* @returns {string} `new URL(...)` expression for the chunk file
|
|
174
|
+
*/
|
|
175
|
+
const toUrl = (id) =>
|
|
176
|
+
`new URL(${workletImportBaseUrl} + ${
|
|
177
|
+
RuntimeGlobals.getChunkScriptFilename
|
|
178
|
+
}(${JSON.stringify(id)}), ${RuntimeGlobals.baseURI})`;
|
|
179
|
+
|
|
180
|
+
// Module output: the worklet chunk is an ES module that links its split
|
|
181
|
+
// chunks via native `import`, which `addModule` resolves — so add just the
|
|
182
|
+
// entry chunk, with no worker-scope shim and no chunk pre-loading.
|
|
183
|
+
if (runtimeTemplate.isModule() && entryChunk.id !== null) {
|
|
184
|
+
source.replace(
|
|
185
|
+
dep.callRange[0],
|
|
186
|
+
dep.callRange[1] - 1,
|
|
187
|
+
`(${toUrl(entryChunk.id)})`
|
|
188
|
+
);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Fast path: a self-contained worklet (a single chunk, no splits or async
|
|
193
|
+
// `import()`) needs no chunk-loading runtime and no worker-scope shim, so the
|
|
194
|
+
// chunk is `addModule`-d directly with no bootstrap.
|
|
195
|
+
if (referencedChunks.size === 1 && runtimeChunkId !== null) {
|
|
196
|
+
source.replace(
|
|
197
|
+
dep.callRange[0],
|
|
198
|
+
dep.callRange[1] - 1,
|
|
199
|
+
`(${toUrl(runtimeChunkId)})`
|
|
200
|
+
);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// A worklet can't load chunks at runtime, so every reachable chunk (initial
|
|
205
|
+
// splits and async `import()` targets alike) is pre-added via `addModule`
|
|
206
|
+
// from the calling scope. The runtime chunk is added last so it installs the
|
|
207
|
+
// chunks pushed before it and runs entry startup with every module present
|
|
208
|
+
// (see ImportScriptsChunkLoadingRuntimeModule).
|
|
209
|
+
/** @type {(string | number)[]} */
|
|
210
|
+
const restChunkIds = [];
|
|
211
|
+
for (const chunk of referencedChunks) {
|
|
212
|
+
if (chunk !== runtimeChunk && chunk.id !== null) {
|
|
213
|
+
restChunkIds.push(chunk.id);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
runtimeRequirements.add(RuntimeGlobals.getWorkletBootstrap);
|
|
218
|
+
|
|
219
|
+
const add = "__webpack_worklet_add__";
|
|
220
|
+
const boot = `${add}(${RuntimeGlobals.getWorkletBootstrap}())`;
|
|
221
|
+
// Non-runtime chunks have no ordering constraint, so add them concurrently.
|
|
222
|
+
const addOne = runtimeTemplate.returningFunction(`${add}(u)`, "u");
|
|
223
|
+
const parallel =
|
|
224
|
+
restChunkIds.length > 0
|
|
225
|
+
? `Promise.all([${restChunkIds.map(toUrl).join(", ")}].map(${addOne}))`
|
|
226
|
+
: undefined;
|
|
227
|
+
// The runtime chunk is added last: it runs entry startup with every module present.
|
|
228
|
+
const runtimeAdd =
|
|
229
|
+
runtimeChunkId !== null ? `${add}(${toUrl(runtimeChunkId)})` : undefined;
|
|
230
|
+
|
|
231
|
+
// Emit `async`/`await` only where the target supports async functions;
|
|
232
|
+
// otherwise fall back to an equivalent Promise chain (boot → rest → runtime).
|
|
233
|
+
let bootstrap;
|
|
234
|
+
if (runtimeTemplate.supportsAsyncFunction()) {
|
|
235
|
+
bootstrap = Template.asString([
|
|
236
|
+
`async function(${add}) {`,
|
|
237
|
+
Template.indent(
|
|
238
|
+
[
|
|
239
|
+
`await ${boot};`,
|
|
240
|
+
parallel ? `await ${parallel};` : "",
|
|
241
|
+
runtimeAdd ? `await ${runtimeAdd};` : ""
|
|
242
|
+
].filter(Boolean)
|
|
243
|
+
),
|
|
244
|
+
"}"
|
|
245
|
+
]);
|
|
246
|
+
} else {
|
|
247
|
+
let chain = boot;
|
|
248
|
+
if (parallel) {
|
|
249
|
+
chain += `.then(${runtimeTemplate.returningFunction(parallel)})`;
|
|
250
|
+
}
|
|
251
|
+
if (runtimeAdd) {
|
|
252
|
+
chain += `.then(${runtimeTemplate.returningFunction(runtimeAdd)})`;
|
|
253
|
+
}
|
|
254
|
+
bootstrap = `function(${add}) { return ${chain}; }`;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// The wrapper forwards to the original `addModule` (its callee stays in the
|
|
258
|
+
// source, so the receiver is preserved); a plain function keeps it valid on
|
|
259
|
+
// ES targets without arrow functions.
|
|
260
|
+
source.insert(
|
|
261
|
+
dep.range[0],
|
|
262
|
+
`(/* worklet bootstrap */ ${bootstrap})(function(${WORKLET_MODULE}) { return `
|
|
263
|
+
);
|
|
264
|
+
source.replace(
|
|
265
|
+
dep.callRange[0],
|
|
266
|
+
dep.callRange[1] - 1,
|
|
267
|
+
`(${WORKLET_MODULE}); })`
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
makeSerializable(
|
|
273
|
+
WorkletDependency,
|
|
274
|
+
"webpack/lib/dependencies/WorkletDependency"
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
module.exports = WorkletDependency;
|
|
278
|
+
module.exports.WORKLET_MODULE = WORKLET_MODULE;
|
|
@@ -93,6 +93,25 @@ class DelegatedModuleFactoryPlugin {
|
|
|
93
93
|
);
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
+
// Directory request: resolve to its index file, like the default resolver.
|
|
97
|
+
for (let i = 0; i < extensions.length; i++) {
|
|
98
|
+
const extension = extensions[i];
|
|
99
|
+
const requestPlusExt = `${innerRequest}/index${extension}`;
|
|
100
|
+
if (requestPlusExt in this.options.content) {
|
|
101
|
+
resolved = this.options.content[requestPlusExt];
|
|
102
|
+
return callback(
|
|
103
|
+
null,
|
|
104
|
+
new DelegatedModule(
|
|
105
|
+
this.options.source,
|
|
106
|
+
resolved,
|
|
107
|
+
/** @type {DelegatedModuleType} */
|
|
108
|
+
(this.options.type),
|
|
109
|
+
requestPlusExt,
|
|
110
|
+
`${request}/index${extension}`
|
|
111
|
+
)
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
96
115
|
}
|
|
97
116
|
return callback();
|
|
98
117
|
}
|
|
@@ -10,7 +10,7 @@ const WebpackError = require("./WebpackError");
|
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("../Module")} Module */
|
|
12
12
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
|
13
|
-
/** @typedef {"asyncWebAssembly" | "topLevelAwait" | "external promise" | "external script" | "external import" | "external module"} Feature */
|
|
13
|
+
/** @typedef {"asyncWebAssembly" | "topLevelAwait" | "external promise" | "external script" | "external import" | "external module" | "external amd-async"} Feature */
|
|
14
14
|
|
|
15
15
|
class EnvironmentNotSupportAsyncWarning extends WebpackError {
|
|
16
16
|
/**
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
3
|
+
Author Tobias Koppers @sokra
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const WebpackError = require("./WebpackError");
|
|
9
|
+
|
|
10
|
+
class LoaderLoadingError extends WebpackError {
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} message message
|
|
13
|
+
*/
|
|
14
|
+
constructor(message) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = "LoaderRunnerError";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = LoaderLoadingError;
|
|
@@ -41,19 +41,24 @@ class ModuleParseError extends WebpackError {
|
|
|
41
41
|
"\nYou need to enable one of the WebAssembly experiments via 'experiments.asyncWebAssembly: true' (based on async modules) or 'experiments.syncWebAssembly: true' (like webpack 4, deprecated).";
|
|
42
42
|
message +=
|
|
43
43
|
"\nFor files that transpile to WebAssembly, make sure to set the module type in the 'module.rules' section of the config (e. g. 'type: \"webassembly/async\"').";
|
|
44
|
-
} else if (!loaders) {
|
|
45
|
-
message +=
|
|
46
|
-
"\nYou may need an appropriate loader to handle this file type. " +
|
|
47
|
-
"See https://webpack.js.org/concepts/loaders";
|
|
48
|
-
} else if (loaders.length >= 1) {
|
|
49
|
-
message += `\nFile was processed with these loaders:${loaders
|
|
50
|
-
.map((loader) => `\n * ${loader}`)
|
|
51
|
-
.join("")}`;
|
|
52
|
-
message +=
|
|
53
|
-
"\nYou may need an additional loader to handle the result of these loaders.";
|
|
54
44
|
} else {
|
|
55
|
-
message +=
|
|
56
|
-
|
|
45
|
+
message += `\nFile was parsed as module type '${type}'.`;
|
|
46
|
+
// `loaders` is undefined when the serializer re-runs this constructor
|
|
47
|
+
// during cache deserialization — keep that branch so it never throws.
|
|
48
|
+
if (!loaders) {
|
|
49
|
+
message +=
|
|
50
|
+
"\nYou may need an appropriate loader to handle this file type. " +
|
|
51
|
+
"See https://webpack.js.org/concepts/loaders";
|
|
52
|
+
} else if (loaders.length >= 1) {
|
|
53
|
+
message += `\nFile was processed with these loaders:${loaders
|
|
54
|
+
.map((loader) => `\n * ${loader}`)
|
|
55
|
+
.join("")}`;
|
|
56
|
+
message +=
|
|
57
|
+
"\nYou may need an additional loader to handle the result of these loaders.";
|
|
58
|
+
} else {
|
|
59
|
+
message +=
|
|
60
|
+
"\nYou may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders";
|
|
61
|
+
}
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
if (
|
|
@@ -73,16 +78,28 @@ class ModuleParseError extends WebpackError {
|
|
|
73
78
|
message += "\n(Source code omitted for this binary file)";
|
|
74
79
|
} else {
|
|
75
80
|
const sourceLines = source.split(/\r?\n/);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
81
|
+
if (lineNumber >= 1 && lineNumber <= sourceLines.length) {
|
|
82
|
+
// babel-like code frame: numbered gutter, `>` on the error line
|
|
83
|
+
// and a `^` caret at the error column
|
|
84
|
+
const column =
|
|
85
|
+
typeof err.loc.column === "number" ? err.loc.column : undefined;
|
|
86
|
+
const start = Math.max(1, lineNumber - 1);
|
|
87
|
+
const end = Math.min(sourceLines.length, lineNumber + 1);
|
|
88
|
+
const width = `${end}`.length;
|
|
89
|
+
for (let n = start; n <= end; n++) {
|
|
90
|
+
const line = sourceLines[n - 1];
|
|
91
|
+
const gutter = `${n}`.padStart(width);
|
|
92
|
+
message +=
|
|
93
|
+
n === lineNumber
|
|
94
|
+
? `\n> ${gutter} | ${line}`
|
|
95
|
+
: `\n ${gutter} | ${line}`;
|
|
96
|
+
if (n === lineNumber && column !== undefined) {
|
|
97
|
+
// keep tabs so the caret stays aligned under tab-indented code
|
|
98
|
+
const align = line.slice(0, column).replace(/[^\t]/g, " ");
|
|
99
|
+
message += `\n ${" ".repeat(width)} | ${align}^`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
86
103
|
}
|
|
87
104
|
|
|
88
105
|
loc = { start: err.loc };
|
|
@@ -27,6 +27,8 @@ const { getUndoPath } = require("../util/identifier");
|
|
|
27
27
|
/** @typedef {import("../Compilation")} Compilation */
|
|
28
28
|
/** @typedef {import("../Compiler")} Compiler */
|
|
29
29
|
/** @typedef {import("../Entrypoint")} Entrypoint */
|
|
30
|
+
/** @typedef {import("../Module")} Module */
|
|
31
|
+
/** @typedef {import("../javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
|
|
30
32
|
|
|
31
33
|
/**
|
|
32
34
|
* Gets relative path.
|
|
@@ -78,7 +80,9 @@ const getRelativePath = (compilation, chunk, runtimeChunk) => {
|
|
|
78
80
|
* @returns {string} the import source
|
|
79
81
|
*/
|
|
80
82
|
function renderChunkImport(compilation, chunk, namedImport, runtimeChunk) {
|
|
81
|
-
return `import ${
|
|
83
|
+
return `import ${
|
|
84
|
+
namedImport ? `* as ${namedImport}` : `{ ${RuntimeGlobals.require} }`
|
|
85
|
+
} from ${JSON.stringify(
|
|
82
86
|
getRelativePath(compilation, chunk, runtimeChunk || chunk)
|
|
83
87
|
)};\n`;
|
|
84
88
|
}
|
|
@@ -182,10 +186,14 @@ class ModuleChunkFormatPlugin {
|
|
|
182
186
|
const hotUpdateChunk = chunk instanceof HotUpdateChunk ? chunk : null;
|
|
183
187
|
const source = new ConcatSource();
|
|
184
188
|
source.add(
|
|
185
|
-
`export const ${RuntimeGlobals.esmId} = ${JSON.stringify(
|
|
189
|
+
`export const ${RuntimeGlobals.esmId} = ${JSON.stringify(
|
|
190
|
+
chunk.id
|
|
191
|
+
)};\n`
|
|
186
192
|
);
|
|
187
193
|
source.add(
|
|
188
|
-
`export const ${RuntimeGlobals.esmIds} = ${JSON.stringify(
|
|
194
|
+
`export const ${RuntimeGlobals.esmIds} = ${JSON.stringify(
|
|
195
|
+
chunk.ids
|
|
196
|
+
)};\n`
|
|
189
197
|
);
|
|
190
198
|
source.add(`export const ${RuntimeGlobals.esmModules} = `);
|
|
191
199
|
source.add(modules);
|
|
@@ -202,6 +210,8 @@ class ModuleChunkFormatPlugin {
|
|
|
202
210
|
}
|
|
203
211
|
const { entries, runtimeChunk } = getChunkInfo(chunk, chunkGraph);
|
|
204
212
|
if (runtimeChunk) {
|
|
213
|
+
const { inlinedEntryModule, inlinedEntrySource } =
|
|
214
|
+
/** @type {ChunkRenderContext} */ (renderContext);
|
|
205
215
|
const entrySource = new ConcatSource();
|
|
206
216
|
entrySource.add(source);
|
|
207
217
|
entrySource.add(";\n\n// load runtime\n");
|
|
@@ -209,12 +219,21 @@ class ModuleChunkFormatPlugin {
|
|
|
209
219
|
renderChunkImport(compilation, runtimeChunk, "", chunk)
|
|
210
220
|
);
|
|
211
221
|
const startupSource = new ConcatSource();
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
222
|
+
// The `__webpack_exec__` helper is only needed for entries that
|
|
223
|
+
// are executed through the registry, not for inlined entries.
|
|
224
|
+
const needExec = entries.some(
|
|
225
|
+
([module]) =>
|
|
226
|
+
module !== inlinedEntryModule &&
|
|
227
|
+
chunkGraph.getModuleSourceTypes(module).has(JAVASCRIPT_TYPE)
|
|
217
228
|
);
|
|
229
|
+
if (needExec) {
|
|
230
|
+
startupSource.add(
|
|
231
|
+
`var __webpack_exec__ = ${runtimeTemplate.returningFunction(
|
|
232
|
+
`${RuntimeGlobals.require}(${RuntimeGlobals.entryModuleId} = moduleId)`,
|
|
233
|
+
"moduleId"
|
|
234
|
+
)}\n`
|
|
235
|
+
);
|
|
236
|
+
}
|
|
218
237
|
|
|
219
238
|
/** @type {Set<Chunk>} */
|
|
220
239
|
const loadedChunks = new Set();
|
|
@@ -248,18 +267,32 @@ class ModuleChunkFormatPlugin {
|
|
|
248
267
|
startupSource.add("\n");
|
|
249
268
|
startupSource.add(sourceWithDependentChunks);
|
|
250
269
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
270
|
+
if (module === inlinedEntryModule && inlinedEntrySource) {
|
|
271
|
+
// Inline the entry at the top level so its declarations stay
|
|
272
|
+
// live ESM bindings (exports appended by `renderStartup`).
|
|
273
|
+
startupSource.add(
|
|
274
|
+
`${runtimeTemplate.renderLet()} ${
|
|
275
|
+
RuntimeGlobals.exports
|
|
276
|
+
} = {};\n`
|
|
277
|
+
);
|
|
278
|
+
startupSource.add(inlinedEntrySource);
|
|
279
|
+
startupSource.add("\n");
|
|
280
|
+
} else {
|
|
281
|
+
startupSource.add(
|
|
282
|
+
`${
|
|
283
|
+
final ? `var ${RuntimeGlobals.exports} = ` : ""
|
|
284
|
+
}__webpack_exec__(${JSON.stringify(moduleId)});\n`
|
|
285
|
+
);
|
|
286
|
+
}
|
|
256
287
|
}
|
|
257
288
|
|
|
258
289
|
entrySource.add(
|
|
259
290
|
hooks.renderStartup.call(
|
|
260
291
|
startupSource,
|
|
261
292
|
entries[entries.length - 1][0],
|
|
262
|
-
|
|
293
|
+
inlinedEntryModule
|
|
294
|
+
? { ...renderContext, inlined: true, inlinedInIIFE: false }
|
|
295
|
+
: renderContext
|
|
263
296
|
)
|
|
264
297
|
);
|
|
265
298
|
return entrySource;
|