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
|
@@ -0,0 +1,100 @@
|
|
|
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 { pathToFileURL } = require("url");
|
|
9
|
+
const LoaderLoadingError = require("../errors/LoaderLoadingError");
|
|
10
|
+
|
|
11
|
+
/** @typedef {import("./LoaderRunner").LoaderObject} LoaderObject */
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Lazily-compiled dynamic `import()`. Built on first use so this file still
|
|
15
|
+
* parses on Node versions without native `import()` (<13.2), then reused.
|
|
16
|
+
* @type {((url: URL) => Promise<EXPECTED_ANY>) | undefined}
|
|
17
|
+
*/
|
|
18
|
+
let importModule;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {LoaderObject} loader the loader to load into
|
|
22
|
+
* @param {EXPECTED_ANY} module the loaded module
|
|
23
|
+
* @param {(err?: Error) => void} callback callback
|
|
24
|
+
* @returns {void}
|
|
25
|
+
*/
|
|
26
|
+
function handleResult(loader, module, callback) {
|
|
27
|
+
if (typeof module !== "function" && typeof module !== "object") {
|
|
28
|
+
return callback(
|
|
29
|
+
new LoaderLoadingError(
|
|
30
|
+
`Module '${loader.path}' is not a loader (export function or es6 module)`
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
loader.normal = typeof module === "function" ? module : module.default;
|
|
36
|
+
loader.pitch = module.pitch;
|
|
37
|
+
loader.raw = module.raw;
|
|
38
|
+
|
|
39
|
+
if (
|
|
40
|
+
typeof loader.normal !== "function" &&
|
|
41
|
+
typeof loader.pitch !== "function"
|
|
42
|
+
) {
|
|
43
|
+
return callback(
|
|
44
|
+
new LoaderLoadingError(
|
|
45
|
+
`Module '${loader.path}' is not a loader (must have normal or pitch function)`
|
|
46
|
+
)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
callback();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @param {LoaderObject} loader the loader to load
|
|
54
|
+
* @param {(err?: Error) => void} callback callback
|
|
55
|
+
* @returns {void}
|
|
56
|
+
*/
|
|
57
|
+
function loadLoader(loader, callback) {
|
|
58
|
+
if (loader.type === "module") {
|
|
59
|
+
try {
|
|
60
|
+
if (importModule === undefined) {
|
|
61
|
+
// `eval` defers parsing `import()` to runtime, so this file stays
|
|
62
|
+
// loadable on Node versions that can't parse it (<13.2).
|
|
63
|
+
// eslint-disable-next-line no-eval
|
|
64
|
+
const dynamicImport = eval("(url) => import(url)");
|
|
65
|
+
importModule = /** @type {(url: URL) => Promise<EXPECTED_ANY>} */ (
|
|
66
|
+
dynamicImport
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
importModule(pathToFileURL(loader.path)).then(
|
|
71
|
+
(/** @type {EXPECTED_ANY} */ module) => {
|
|
72
|
+
handleResult(loader, module, callback);
|
|
73
|
+
},
|
|
74
|
+
callback
|
|
75
|
+
);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
callback(/** @type {Error} */ (err));
|
|
78
|
+
}
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let loadedModule;
|
|
83
|
+
try {
|
|
84
|
+
loadedModule = require(loader.path);
|
|
85
|
+
} catch (err) {
|
|
86
|
+
// node can choke on require when the FD limit is hit; defer to recover.
|
|
87
|
+
if (
|
|
88
|
+
err instanceof Error &&
|
|
89
|
+
/** @type {NodeJS.ErrnoException} */ (err).code === "EMFILE"
|
|
90
|
+
) {
|
|
91
|
+
setImmediate(loadLoader, loader, callback);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
return callback(/** @type {Error} */ (err));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return handleResult(loader, loadedModule, callback);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
module.exports = loadLoader;
|
|
@@ -8,12 +8,21 @@
|
|
|
8
8
|
const { WEBASSEMBLY_MODULE_TYPE_ASYNC } = require("../ModuleTypeConstants");
|
|
9
9
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
10
10
|
const Template = require("../Template");
|
|
11
|
+
const { getPresentKinds } = require("../TemplatedPathPlugin");
|
|
11
12
|
const AsyncWasmCompileRuntimeModule = require("../wasm-async/AsyncWasmCompileRuntimeModule");
|
|
12
13
|
const AsyncWasmLoadingRuntimeModule = require("../wasm-async/AsyncWasmLoadingRuntimeModule");
|
|
13
14
|
|
|
14
15
|
/** @typedef {import("../Chunk")} Chunk */
|
|
15
16
|
/** @typedef {import("../Compiler")} Compiler */
|
|
16
17
|
|
|
18
|
+
/**
|
|
19
|
+
* The wasm runtime inlines `[fullhash]` as a runtime `getFullHash()` call, so
|
|
20
|
+
* that runtime module must be requested (`[hash]` is the per-module hash here).
|
|
21
|
+
* @param {string} filename `output.webassemblyModuleFilename`
|
|
22
|
+
* @returns {boolean} whether it references the compilation `[fullhash]`
|
|
23
|
+
*/
|
|
24
|
+
const usesFullHash = (filename) => getPresentKinds(filename).has("fullhash");
|
|
25
|
+
|
|
17
26
|
/**
|
|
18
27
|
* Defines the read file compile async wasm plugin options type used by this module.
|
|
19
28
|
* @typedef {object} ReadFileCompileAsyncWasmPluginOptions
|
|
@@ -112,6 +121,11 @@ class ReadFileCompileAsyncWasmPlugin {
|
|
|
112
121
|
) {
|
|
113
122
|
return;
|
|
114
123
|
}
|
|
124
|
+
if (
|
|
125
|
+
usesFullHash(compilation.outputOptions.webassemblyModuleFilename)
|
|
126
|
+
) {
|
|
127
|
+
set.add(RuntimeGlobals.getFullHash);
|
|
128
|
+
}
|
|
115
129
|
compilation.addRuntimeModule(
|
|
116
130
|
chunk,
|
|
117
131
|
new AsyncWasmLoadingRuntimeModule({
|
|
@@ -133,6 +147,11 @@ class ReadFileCompileAsyncWasmPlugin {
|
|
|
133
147
|
) {
|
|
134
148
|
return;
|
|
135
149
|
}
|
|
150
|
+
if (
|
|
151
|
+
usesFullHash(compilation.outputOptions.webassemblyModuleFilename)
|
|
152
|
+
) {
|
|
153
|
+
set.add(RuntimeGlobals.getFullHash);
|
|
154
|
+
}
|
|
136
155
|
compilation.addRuntimeModule(
|
|
137
156
|
chunk,
|
|
138
157
|
new AsyncWasmCompileRuntimeModule({
|
|
@@ -8,11 +8,20 @@
|
|
|
8
8
|
const { WEBASSEMBLY_MODULE_TYPE_SYNC } = require("../ModuleTypeConstants");
|
|
9
9
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
10
10
|
const Template = require("../Template");
|
|
11
|
+
const { getPresentKinds } = require("../TemplatedPathPlugin");
|
|
11
12
|
const WasmChunkLoadingRuntimeModule = require("../wasm-sync/WasmChunkLoadingRuntimeModule");
|
|
12
13
|
|
|
13
14
|
/** @typedef {import("../Chunk")} Chunk */
|
|
14
15
|
/** @typedef {import("../Compiler")} Compiler */
|
|
15
16
|
|
|
17
|
+
/**
|
|
18
|
+
* The wasm runtime inlines `[fullhash]` as a runtime `getFullHash()` call, so
|
|
19
|
+
* that runtime module must be requested (`[hash]` is the per-module hash here).
|
|
20
|
+
* @param {string} filename `output.webassemblyModuleFilename`
|
|
21
|
+
* @returns {boolean} whether it references the compilation `[fullhash]`
|
|
22
|
+
*/
|
|
23
|
+
const usesFullHash = (filename) => getPresentKinds(filename).has("fullhash");
|
|
24
|
+
|
|
16
25
|
/**
|
|
17
26
|
* Defines the read file compile wasm plugin options type used by this module.
|
|
18
27
|
* @typedef {object} ReadFileCompileWasmPluginOptions
|
|
@@ -113,6 +122,11 @@ class ReadFileCompileWasmPlugin {
|
|
|
113
122
|
return;
|
|
114
123
|
}
|
|
115
124
|
set.add(RuntimeGlobals.moduleCache);
|
|
125
|
+
if (
|
|
126
|
+
usesFullHash(compilation.outputOptions.webassemblyModuleFilename)
|
|
127
|
+
) {
|
|
128
|
+
set.add(RuntimeGlobals.getFullHash);
|
|
129
|
+
}
|
|
116
130
|
compilation.addRuntimeModule(
|
|
117
131
|
chunk,
|
|
118
132
|
new WasmChunkLoadingRuntimeModule({
|
|
@@ -26,8 +26,11 @@ const RuntimeGlobals = require("../RuntimeGlobals");
|
|
|
26
26
|
const Template = require("../Template");
|
|
27
27
|
const { DEFAULTS } = require("../config/defaults");
|
|
28
28
|
const { ImportPhaseUtils } = require("../dependencies/ImportPhase");
|
|
29
|
+
const { isCommonJsWrapped } = require("../javascript/JavascriptGenerator");
|
|
29
30
|
const JavascriptParser = require("../javascript/JavascriptParser");
|
|
30
31
|
const {
|
|
32
|
+
getDeferredCycleModuleIds,
|
|
33
|
+
getDeferredCycleModules,
|
|
31
34
|
getMakeDeferredNamespaceModeFromExportsType,
|
|
32
35
|
getOptimizedDeferredModule
|
|
33
36
|
} = require("../runtime/MakeDeferredNamespaceObjectRuntime");
|
|
@@ -82,6 +85,7 @@ const { InlinedUsedName } = require("./InlineExports");
|
|
|
82
85
|
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
|
|
83
86
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
84
87
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
88
|
+
/** @typedef {import("../NormalModule")} NormalModule */
|
|
85
89
|
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
|
86
90
|
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
87
91
|
/** @typedef {import("../RequestShortener")} RequestShortener */
|
|
@@ -153,6 +157,7 @@ if (!ReferencerClass.prototype.PropertyDefinition) {
|
|
|
153
157
|
* @property {"concatenated"} type
|
|
154
158
|
* @property {Module} module
|
|
155
159
|
* @property {number} index
|
|
160
|
+
* @property {boolean=} cjsWrapped a "weird" CommonJS module executed via the CJS wrapper runtime helper with real module/exports objects
|
|
156
161
|
* @property {Program | undefined} ast
|
|
157
162
|
* @property {Source | undefined} internalSource
|
|
158
163
|
* @property {ReplaceSource | undefined} source
|
|
@@ -354,6 +359,9 @@ const getFinalBinding = (
|
|
|
354
359
|
if (exportName.length === 0) {
|
|
355
360
|
switch (exportsType) {
|
|
356
361
|
case "default-only":
|
|
362
|
+
// a concatenated CommonJS module has no runtime exports object;
|
|
363
|
+
// its fake namespace is built over the generated namespace object
|
|
364
|
+
if (info.type === "concatenated") neededNamespaceObjects.add(info);
|
|
357
365
|
if (deferred) info.deferredNamespaceObjectUsed = true;
|
|
358
366
|
else info.interopNamespaceObject2Used = true;
|
|
359
367
|
return {
|
|
@@ -367,6 +375,7 @@ const getFinalBinding = (
|
|
|
367
375
|
exportName
|
|
368
376
|
};
|
|
369
377
|
case "default-with-named":
|
|
378
|
+
if (info.type === "concatenated") neededNamespaceObjects.add(info);
|
|
370
379
|
if (deferred) info.deferredNamespaceObjectUsed = true;
|
|
371
380
|
else info.interopNamespaceObjectUsed = true;
|
|
372
381
|
return {
|
|
@@ -657,7 +666,9 @@ const getFinalBinding = (
|
|
|
657
666
|
alreadyVisited
|
|
658
667
|
);
|
|
659
668
|
}
|
|
660
|
-
|
|
669
|
+
// A wrapped module resolves every export through its live exports
|
|
670
|
+
// alias (namespaceObjectName), same as namespaceExportSymbol modules.
|
|
671
|
+
if (info.namespaceExportSymbol || info.cjsWrapped) {
|
|
661
672
|
const usedName = /** @type {ExportName} */ (
|
|
662
673
|
exportsInfo.getUsedName(exportName, runtime)
|
|
663
674
|
);
|
|
@@ -985,8 +996,19 @@ class ConcatenatedModule extends Module {
|
|
|
985
996
|
|
|
986
997
|
for (const m of this._modules) {
|
|
987
998
|
// populate cacheable
|
|
988
|
-
|
|
999
|
+
const { cacheable, notCacheableReasons } = /** @type {BuildInfo} */ (
|
|
1000
|
+
m.buildInfo
|
|
1001
|
+
);
|
|
1002
|
+
if (!cacheable) {
|
|
989
1003
|
this.buildInfo.cacheable = false;
|
|
1004
|
+
if (notCacheableReasons) {
|
|
1005
|
+
const reasons =
|
|
1006
|
+
this.buildInfo.notCacheableReasons ||
|
|
1007
|
+
(this.buildInfo.notCacheableReasons = []);
|
|
1008
|
+
for (const reason of notCacheableReasons) {
|
|
1009
|
+
if (!reasons.includes(reason)) reasons.push(reason);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
990
1012
|
}
|
|
991
1013
|
|
|
992
1014
|
// populate dependencies
|
|
@@ -1517,7 +1539,7 @@ class ConcatenatedModule extends Module {
|
|
|
1517
1539
|
|
|
1518
1540
|
// get all global names
|
|
1519
1541
|
for (const info of modulesWithInfo) {
|
|
1520
|
-
if (info.type === "concatenated") {
|
|
1542
|
+
if (info.type === "concatenated" && !info.cjsWrapped) {
|
|
1521
1543
|
// ignore symbols from moduleScope
|
|
1522
1544
|
if (info.moduleScope) {
|
|
1523
1545
|
ignoredScopes.add(info.moduleScope);
|
|
@@ -1707,6 +1729,23 @@ class ConcatenatedModule extends Module {
|
|
|
1707
1729
|
);
|
|
1708
1730
|
switch (info.type) {
|
|
1709
1731
|
case "concatenated": {
|
|
1732
|
+
if (info.cjsWrapped) {
|
|
1733
|
+
// Wrapped modules expose one shared-scope name: the final
|
|
1734
|
+
// exports object used as the namespace.
|
|
1735
|
+
const namespaceObjectName = findNewName(
|
|
1736
|
+
"namespaceObject",
|
|
1737
|
+
allUsedNames,
|
|
1738
|
+
namespaceObjectUsedNames,
|
|
1739
|
+
info.module.readableIdentifier(requestShortener)
|
|
1740
|
+
);
|
|
1741
|
+
allUsedNames.add(namespaceObjectName);
|
|
1742
|
+
topLevelDeclarations.add(namespaceObjectName);
|
|
1743
|
+
info.namespaceObjectName = namespaceObjectName;
|
|
1744
|
+
// Route every binding to the live exports alias and skip the
|
|
1745
|
+
// materialized namespace object generated for other modules.
|
|
1746
|
+
info.namespaceExportSymbol = namespaceObjectName;
|
|
1747
|
+
break;
|
|
1748
|
+
}
|
|
1710
1749
|
const variables = /** @type {Scope} */ (info.moduleScope).variables;
|
|
1711
1750
|
for (const variable of variables) {
|
|
1712
1751
|
const name = variable.name;
|
|
@@ -1843,7 +1882,7 @@ class ConcatenatedModule extends Module {
|
|
|
1843
1882
|
|
|
1844
1883
|
// Find and replace references to modules
|
|
1845
1884
|
for (const info of moduleToInfoMap.values()) {
|
|
1846
|
-
if (info.type === "concatenated") {
|
|
1885
|
+
if (info.type === "concatenated" && !info.cjsWrapped) {
|
|
1847
1886
|
const globalScope = /** @type {Scope} */ (info.globalScope);
|
|
1848
1887
|
// group references by name
|
|
1849
1888
|
/** @type {Map<string, Reference[]>} */
|
|
@@ -2081,7 +2120,9 @@ class ConcatenatedModule extends Module {
|
|
|
2081
2120
|
if (!usedName) continue;
|
|
2082
2121
|
if (usedName instanceof InlinedUsedName) {
|
|
2083
2122
|
nsObj.push(
|
|
2084
|
-
`\n ${propertyName(
|
|
2123
|
+
`\n ${propertyName(
|
|
2124
|
+
exportInfo.name
|
|
2125
|
+
)}: ${runtimeTemplate.returningFunction(
|
|
2085
2126
|
usedName.render(
|
|
2086
2127
|
Template.toNormalComment(
|
|
2087
2128
|
`inlined export ${propertyAccess([exportInfo.name])}`
|
|
@@ -2094,7 +2135,9 @@ class ConcatenatedModule extends Module {
|
|
|
2094
2135
|
// import variable; concatenated ones resolve to an internal binding.
|
|
2095
2136
|
const finalName =
|
|
2096
2137
|
info.type === "external"
|
|
2097
|
-
? `${/** @type {string} */ (info.name)}${propertyAccess([
|
|
2138
|
+
? `${/** @type {string} */ (info.name)}${propertyAccess([
|
|
2139
|
+
usedName
|
|
2140
|
+
])}`
|
|
2098
2141
|
: getFinalName(
|
|
2099
2142
|
moduleGraph,
|
|
2100
2143
|
info,
|
|
@@ -2112,9 +2155,9 @@ class ConcatenatedModule extends Module {
|
|
|
2112
2155
|
true
|
|
2113
2156
|
);
|
|
2114
2157
|
nsObj.push(
|
|
2115
|
-
`\n ${propertyName(
|
|
2116
|
-
|
|
2117
|
-
)}`
|
|
2158
|
+
`\n ${propertyName(
|
|
2159
|
+
exportInfo.name
|
|
2160
|
+
)}: ${runtimeTemplate.returningFunction(finalName)}`
|
|
2118
2161
|
);
|
|
2119
2162
|
}
|
|
2120
2163
|
}
|
|
@@ -2131,7 +2174,9 @@ class ConcatenatedModule extends Module {
|
|
|
2131
2174
|
escapeNamespaceObjectSources.set(
|
|
2132
2175
|
info,
|
|
2133
2176
|
`
|
|
2134
|
-
// NAMESPACE OBJECT (decoupled): ${info.module.readableIdentifier(
|
|
2177
|
+
// NAMESPACE OBJECT (decoupled): ${info.module.readableIdentifier(
|
|
2178
|
+
requestShortener
|
|
2179
|
+
)}
|
|
2135
2180
|
var ${name} = {};
|
|
2136
2181
|
${RuntimeGlobals.makeNamespaceObject}(${name});
|
|
2137
2182
|
${defineGetters}`
|
|
@@ -2154,7 +2199,9 @@ ${defineGetters}`
|
|
|
2154
2199
|
// TODO: Replace with the inlined value directly at the call site
|
|
2155
2200
|
if (usedName instanceof InlinedUsedName) {
|
|
2156
2201
|
nsObj.push(
|
|
2157
|
-
`\n ${propertyName(
|
|
2202
|
+
`\n ${propertyName(
|
|
2203
|
+
exportInfo.name
|
|
2204
|
+
)}: ${runtimeTemplate.returningFunction(
|
|
2158
2205
|
usedName.render(
|
|
2159
2206
|
Template.toNormalComment(
|
|
2160
2207
|
`inlined export ${propertyAccess([exportInfo.name])}`
|
|
@@ -2180,9 +2227,9 @@ ${defineGetters}`
|
|
|
2180
2227
|
true
|
|
2181
2228
|
);
|
|
2182
2229
|
nsObj.push(
|
|
2183
|
-
`\n ${propertyName(
|
|
2184
|
-
|
|
2185
|
-
)}`
|
|
2230
|
+
`\n ${propertyName(
|
|
2231
|
+
usedName
|
|
2232
|
+
)}: ${runtimeTemplate.returningFunction(finalName)}`
|
|
2186
2233
|
);
|
|
2187
2234
|
}
|
|
2188
2235
|
}
|
|
@@ -2232,6 +2279,16 @@ ${defineGetters}`
|
|
|
2232
2279
|
),
|
|
2233
2280
|
// an async module will opt-out of the concat module optimization.
|
|
2234
2281
|
[],
|
|
2282
|
+
// A closure member absorbed into this concatenation shares this
|
|
2283
|
+
// module's runtime id (and thus its `evaluating` flag); resolve it
|
|
2284
|
+
// to that id instead of the member's now-absent standalone id.
|
|
2285
|
+
getDeferredCycleModuleIds(
|
|
2286
|
+
getDeferredCycleModules(moduleGraph, info.module),
|
|
2287
|
+
(mod) =>
|
|
2288
|
+
moduleToInfoMap.has(mod)
|
|
2289
|
+
? chunkGraph.getModuleId(this)
|
|
2290
|
+
: chunkGraph.getModuleId(mod)
|
|
2291
|
+
),
|
|
2235
2292
|
runtimeRequirements
|
|
2236
2293
|
);
|
|
2237
2294
|
runtimeRequirements.add(RuntimeGlobals.require);
|
|
@@ -2269,7 +2326,18 @@ ${defineGetters}`
|
|
|
2269
2326
|
result.add(
|
|
2270
2327
|
`\n;// ${info.module.readableIdentifier(requestShortener)}\n`
|
|
2271
2328
|
);
|
|
2272
|
-
|
|
2329
|
+
if (info.cjsWrapped) {
|
|
2330
|
+
// Real CommonJS semantics via the runtime helper: it calls the
|
|
2331
|
+
// body with this = exports and returns the final module.exports.
|
|
2332
|
+
runtimeRequirements.add(RuntimeGlobals.commonJsWrap);
|
|
2333
|
+
result.add(
|
|
2334
|
+
`var ${info.namespaceObjectName} = /*#__PURE__*/${RuntimeGlobals.commonJsWrap}(function(${info.module.moduleArgument}, ${info.module.exportsArgument}) {\n`
|
|
2335
|
+
);
|
|
2336
|
+
result.add(/** @type {ReplaceSource} */ (info.source));
|
|
2337
|
+
result.add("\n});\n");
|
|
2338
|
+
} else {
|
|
2339
|
+
result.add(/** @type {ReplaceSource} */ (info.source));
|
|
2340
|
+
}
|
|
2273
2341
|
if (info.chunkInitFragments) {
|
|
2274
2342
|
for (const f of info.chunkInitFragments) chunkInitFragments.push(f);
|
|
2275
2343
|
}
|
|
@@ -2403,6 +2471,33 @@ ${defineGetters}`
|
|
|
2403
2471
|
if (info.type === "concatenated") {
|
|
2404
2472
|
const m = info.module;
|
|
2405
2473
|
try {
|
|
2474
|
+
if (info.cjsWrapped) {
|
|
2475
|
+
// A wrapped module renders its normal module source (real
|
|
2476
|
+
// module/exports objects, own module ids) inside an IIFE, so it
|
|
2477
|
+
// needs no concatenation scope, reference rewriting, or scope
|
|
2478
|
+
// analysis — the wrapper isolates its top-level declarations.
|
|
2479
|
+
const codeGenResult = m.codeGeneration({
|
|
2480
|
+
dependencyTemplates,
|
|
2481
|
+
runtimeTemplate,
|
|
2482
|
+
moduleGraph,
|
|
2483
|
+
chunkGraph,
|
|
2484
|
+
runtime,
|
|
2485
|
+
runtimes,
|
|
2486
|
+
codeGenerationResults,
|
|
2487
|
+
sourceTypes: JAVASCRIPT_TYPES
|
|
2488
|
+
});
|
|
2489
|
+
const source =
|
|
2490
|
+
/** @type {Source} */
|
|
2491
|
+
(codeGenResult.sources.get(JAVASCRIPT_TYPE));
|
|
2492
|
+
const data = codeGenResult.data;
|
|
2493
|
+
info.runtimeRequirements =
|
|
2494
|
+
/** @type {ReadOnlyRuntimeRequirements} */
|
|
2495
|
+
(codeGenResult.runtimeRequirements);
|
|
2496
|
+
info.internalSource = source;
|
|
2497
|
+
info.source = new ReplaceSource(source);
|
|
2498
|
+
info.chunkInitFragments = data && data.get("chunkInitFragments");
|
|
2499
|
+
return;
|
|
2500
|
+
}
|
|
2406
2501
|
// Create a concatenation scope to track and capture information
|
|
2407
2502
|
const concatenationScope = new ConcatenationScope(
|
|
2408
2503
|
modulesMap,
|
|
@@ -2434,11 +2529,17 @@ ${defineGetters}`
|
|
|
2434
2529
|
let ast;
|
|
2435
2530
|
|
|
2436
2531
|
try {
|
|
2532
|
+
const { experiments } = this.compilation.options;
|
|
2533
|
+
|
|
2437
2534
|
({ ast } = JavascriptParser._parse(
|
|
2438
2535
|
code,
|
|
2439
2536
|
{
|
|
2440
2537
|
sourceType: "module",
|
|
2441
|
-
ranges: true
|
|
2538
|
+
ranges: true,
|
|
2539
|
+
// generated code contains phase imports when the experiments are on
|
|
2540
|
+
importPhases: Boolean(
|
|
2541
|
+
experiments.deferImport || experiments.sourceImport
|
|
2542
|
+
)
|
|
2442
2543
|
},
|
|
2443
2544
|
JavascriptParser._getModuleParseFunction(this.compilation, m)
|
|
2444
2545
|
));
|
|
@@ -2511,6 +2612,9 @@ ${defineGetters}`
|
|
|
2511
2612
|
type: "concatenated",
|
|
2512
2613
|
module: info.module,
|
|
2513
2614
|
index,
|
|
2615
|
+
cjsWrapped: isCommonJsWrapped(
|
|
2616
|
+
/** @type {NormalModule} */ (info.module)
|
|
2617
|
+
),
|
|
2514
2618
|
ast: undefined,
|
|
2515
2619
|
chunkInitFragments: undefined,
|
|
2516
2620
|
internalSource: undefined,
|
|
@@ -76,6 +76,12 @@ class FlagIncludedChunksPlugin {
|
|
|
76
76
|
chunkModulesHash.set(chunk, hash);
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
// Chunks that received an included id and need their `ids` re-sorted
|
|
80
|
+
// once, after all pushes — instead of re-sorting on every push
|
|
81
|
+
// inside the nested loop below (https://github.com/webpack/webpack/issues/18837).
|
|
82
|
+
/** @type {Set<Chunk>} */
|
|
83
|
+
const chunksWithIncludedIds = new Set();
|
|
84
|
+
|
|
79
85
|
for (const chunkA of chunks) {
|
|
80
86
|
const chunkAHash =
|
|
81
87
|
/** @type {number} */
|
|
@@ -125,11 +131,15 @@ class FlagIncludedChunksPlugin {
|
|
|
125
131
|
|
|
126
132
|
/** @type {ChunkId[]} */
|
|
127
133
|
(chunkB.ids).push(/** @type {ChunkId} */ (chunkA.id));
|
|
128
|
-
|
|
129
|
-
/** @type {ChunkId[]} */
|
|
130
|
-
(chunkB.ids).sort(compareIds);
|
|
134
|
+
chunksWithIncludedIds.add(chunkB);
|
|
131
135
|
}
|
|
132
136
|
}
|
|
137
|
+
|
|
138
|
+
// Sort each affected chunk's ids once (https://github.com/webpack/webpack/issues/18837).
|
|
139
|
+
for (const chunk of chunksWithIncludedIds) {
|
|
140
|
+
/** @type {ChunkId[]} */
|
|
141
|
+
(chunk.ids).sort(compareIds);
|
|
142
|
+
}
|
|
133
143
|
});
|
|
134
144
|
});
|
|
135
145
|
}
|
|
@@ -80,6 +80,9 @@ class InnerGraphPlugin {
|
|
|
80
80
|
* @param {Expression} sup sup
|
|
81
81
|
*/
|
|
82
82
|
const onUsageSuper = (sup) => {
|
|
83
|
+
// the callback fires after parsing, when the parser can no
|
|
84
|
+
// longer map offsets — take the location now
|
|
85
|
+
const loc = parser.getLocation(sup);
|
|
83
86
|
innerGraph.onUsage(parser.state, (usedByExports, module) => {
|
|
84
87
|
switch (usedByExports) {
|
|
85
88
|
case undefined:
|
|
@@ -90,7 +93,7 @@ class InnerGraphPlugin {
|
|
|
90
93
|
/** @type {Range} */
|
|
91
94
|
(sup.range)
|
|
92
95
|
);
|
|
93
|
-
dep.loc =
|
|
96
|
+
dep.loc = loc;
|
|
94
97
|
dep.usedByExports = usedByExports;
|
|
95
98
|
addPureDependency(module, dep);
|
|
96
99
|
break;
|
|
@@ -205,30 +208,36 @@ class InnerGraphPlugin {
|
|
|
205
208
|
|
|
206
209
|
// The following hooks are used during prewalking:
|
|
207
210
|
|
|
208
|
-
parser.hooks.
|
|
209
|
-
|
|
211
|
+
parser.hooks.preStatementByType
|
|
212
|
+
.for("FunctionDeclaration")
|
|
213
|
+
.tap(PLUGIN_NAME, (statement) => {
|
|
214
|
+
if (!innerGraph.isEnabled(parser.state)) return;
|
|
210
215
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
216
|
+
if (
|
|
217
|
+
parser.scope.topLevelScope === true &&
|
|
218
|
+
statement.type === "FunctionDeclaration"
|
|
219
|
+
) {
|
|
220
|
+
const name = statement.id ? statement.id.name : "*default*";
|
|
221
|
+
const symbol = /** @type {TopLevelSymbol} */ (
|
|
222
|
+
innerGraph.tagTopLevelSymbol(
|
|
223
|
+
parser,
|
|
224
|
+
name,
|
|
225
|
+
parser.isPure(
|
|
226
|
+
statement,
|
|
227
|
+
/** @type {Range} */ (statement.range)[0]
|
|
228
|
+
)
|
|
223
229
|
)
|
|
224
|
-
)
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
+
);
|
|
231
|
+
statementWithTopLevelSymbol.set(statement, symbol);
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
});
|
|
230
235
|
|
|
231
|
-
|
|
236
|
+
/**
|
|
237
|
+
* @param {import("estree").Statement | import("estree").ModuleDeclaration | import("estree").MaybeNamedFunctionDeclaration | import("estree").MaybeNamedClassDeclaration} statement statement
|
|
238
|
+
* @returns {boolean | void} true when handled
|
|
239
|
+
*/
|
|
240
|
+
const blockPreStatementHandler = (statement) => {
|
|
232
241
|
if (!innerGraph.isEnabled(parser.state)) return;
|
|
233
242
|
|
|
234
243
|
if (parser.scope.topLevelScope === true) {
|
|
@@ -288,7 +297,13 @@ class InnerGraphPlugin {
|
|
|
288
297
|
}
|
|
289
298
|
}
|
|
290
299
|
}
|
|
291
|
-
}
|
|
300
|
+
};
|
|
301
|
+
parser.hooks.blockPreStatementByType
|
|
302
|
+
.for("ClassDeclaration")
|
|
303
|
+
.tap(PLUGIN_NAME, blockPreStatementHandler);
|
|
304
|
+
parser.hooks.blockPreStatementByType
|
|
305
|
+
.for("ExportDefaultDeclaration")
|
|
306
|
+
.tap(PLUGIN_NAME, blockPreStatementHandler);
|
|
292
307
|
|
|
293
308
|
parser.hooks.preDeclarator.tap(PLUGIN_NAME, (decl, statement) => {
|
|
294
309
|
if (!innerGraph.isEnabled(parser.state)) return;
|
|
@@ -363,6 +378,9 @@ class InnerGraphPlugin {
|
|
|
363
378
|
innerGraph.setTopLevelSymbol(parser.state, symbol);
|
|
364
379
|
const purePart = statementPurePart.get(statement);
|
|
365
380
|
if (purePart) {
|
|
381
|
+
// the callback fires after parsing, when the parser can no
|
|
382
|
+
// longer map offsets — take the location now
|
|
383
|
+
const loc = parser.getLocation(statement);
|
|
366
384
|
innerGraph.onUsage(parser.state, (usedByExports, module) => {
|
|
367
385
|
switch (usedByExports) {
|
|
368
386
|
case undefined:
|
|
@@ -372,9 +390,7 @@ class InnerGraphPlugin {
|
|
|
372
390
|
const dep = new PureExpressionDependency(
|
|
373
391
|
/** @type {Range} */ (purePart.range)
|
|
374
392
|
);
|
|
375
|
-
dep.loc =
|
|
376
|
-
/** @type {DependencyLocation} */
|
|
377
|
-
(statement.loc);
|
|
393
|
+
dep.loc = loc;
|
|
378
394
|
dep.usedByExports = usedByExports;
|
|
379
395
|
addPureDependency(module, dep);
|
|
380
396
|
break;
|
|
@@ -439,6 +455,9 @@ class InnerGraphPlugin {
|
|
|
439
455
|
) {
|
|
440
456
|
innerGraph.setTopLevelSymbol(parser.state, symbol);
|
|
441
457
|
if (element.type !== "MethodDefinition" && element.static) {
|
|
458
|
+
// the callback fires after parsing, when the parser can
|
|
459
|
+
// no longer map offsets — take the location now
|
|
460
|
+
const loc = parser.getLocation(expression);
|
|
442
461
|
innerGraph.onUsage(
|
|
443
462
|
parser.state,
|
|
444
463
|
(usedByExports, module) => {
|
|
@@ -450,9 +469,7 @@ class InnerGraphPlugin {
|
|
|
450
469
|
const dep = new PureExpressionDependency(
|
|
451
470
|
/** @type {Range} */ (expression.range)
|
|
452
471
|
);
|
|
453
|
-
dep.loc =
|
|
454
|
-
/** @type {DependencyLocation} */
|
|
455
|
-
(expression.loc);
|
|
472
|
+
dep.loc = loc;
|
|
456
473
|
dep.usedByExports = usedByExports;
|
|
457
474
|
addPureDependency(module, dep);
|
|
458
475
|
break;
|
|
@@ -484,6 +501,9 @@ class InnerGraphPlugin {
|
|
|
484
501
|
onUsageSuper(decl.init.superClass);
|
|
485
502
|
}
|
|
486
503
|
} else {
|
|
504
|
+
// the callback fires after parsing, when the parser can no
|
|
505
|
+
// longer map offsets — take the location now
|
|
506
|
+
const loc = parser.getLocation(decl);
|
|
487
507
|
innerGraph.onUsage(parser.state, (usedByExports, module) => {
|
|
488
508
|
switch (usedByExports) {
|
|
489
509
|
case undefined:
|
|
@@ -496,7 +516,7 @@ class InnerGraphPlugin {
|
|
|
496
516
|
(decl.init).range
|
|
497
517
|
)
|
|
498
518
|
);
|
|
499
|
-
dep.loc =
|
|
519
|
+
dep.loc = loc;
|
|
500
520
|
dep.usedByExports = usedByExports;
|
|
501
521
|
addPureDependency(module, dep);
|
|
502
522
|
break;
|