webpack 5.95.0 → 5.96.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.
- package/README.md +1 -1
- package/lib/AsyncDependenciesBlock.js +1 -1
- package/lib/BannerPlugin.js +2 -1
- package/lib/Chunk.js +30 -0
- package/lib/ChunkGraph.js +11 -6
- package/lib/ChunkGroup.js +2 -2
- package/lib/CleanPlugin.js +4 -5
- package/lib/CodeGenerationResults.js +6 -5
- package/lib/Compilation.js +71 -48
- package/lib/Compiler.js +7 -5
- package/lib/ConcatenationScope.js +7 -20
- package/lib/ContextModule.js +7 -8
- package/lib/CssModule.js +25 -21
- package/lib/DefinePlugin.js +14 -8
- package/lib/DelegatedModule.js +3 -3
- package/lib/DllModule.js +4 -4
- package/lib/DynamicEntryPlugin.js +29 -22
- package/lib/EvalDevToolModulePlugin.js +5 -2
- package/lib/EvalSourceMapDevToolPlugin.js +5 -2
- package/lib/ExternalModule.js +40 -7
- package/lib/ExternalModuleFactoryPlugin.js +33 -9
- package/lib/FileSystemInfo.js +12 -8
- package/lib/Generator.js +5 -4
- package/lib/HotModuleReplacementPlugin.js +8 -6
- package/lib/IgnorePlugin.js +19 -1
- package/lib/LoaderOptionsPlugin.js +3 -1
- package/lib/Module.js +9 -8
- package/lib/ModuleSourceTypesConstants.js +100 -0
- package/lib/NormalModule.js +27 -17
- package/lib/NormalModuleFactory.js +38 -22
- package/lib/OptionsApply.js +12 -1
- package/lib/ProgressPlugin.js +50 -10
- package/lib/RawModule.js +3 -4
- package/lib/RuntimeModule.js +3 -4
- package/lib/RuntimePlugin.js +11 -4
- package/lib/RuntimeTemplate.js +13 -42
- package/lib/SourceMapDevToolPlugin.js +10 -7
- package/lib/Watching.js +2 -2
- package/lib/WebpackOptionsApply.js +42 -21
- package/lib/asset/AssetGenerator.js +347 -194
- package/lib/asset/AssetModulesPlugin.js +2 -1
- package/lib/asset/AssetSourceGenerator.js +82 -27
- package/lib/asset/RawDataUrlModule.js +5 -4
- package/lib/buildChunkGraph.js +2 -2
- package/lib/cache/PackFileCacheStrategy.js +69 -31
- package/lib/cache/ResolverCachePlugin.js +248 -173
- package/lib/config/defaults.js +134 -126
- package/lib/container/ContainerEntryModule.js +3 -4
- package/lib/container/ContainerPlugin.js +8 -0
- package/lib/container/FallbackModule.js +2 -2
- package/lib/container/HoistContainerReferencesPlugin.js +250 -0
- package/lib/container/ModuleFederationPlugin.js +38 -1
- package/lib/container/RemoteModule.js +4 -2
- package/lib/container/RemoteRuntimeModule.js +4 -2
- package/lib/css/CssExportsGenerator.js +16 -12
- package/lib/css/CssGenerator.js +22 -16
- package/lib/css/CssLoadingRuntimeModule.js +7 -6
- package/lib/css/CssModulesPlugin.js +122 -77
- package/lib/css/CssParser.js +655 -526
- package/lib/css/walkCssTokens.js +1168 -338
- package/lib/debug/ProfilingPlugin.js +5 -0
- package/lib/dependencies/CommonJsExportsParserPlugin.js +5 -2
- package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -6
- package/lib/dependencies/CssExportDependency.js +3 -3
- package/lib/dependencies/CssLocalIdentifierDependency.js +26 -17
- package/lib/dependencies/CssUrlDependency.js +33 -3
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +3 -3
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +39 -14
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +15 -82
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +5 -2
- package/lib/dependencies/ImportParserPlugin.js +9 -7
- package/lib/dependencies/LoaderPlugin.js +19 -0
- package/lib/dependencies/SystemPlugin.js +2 -1
- package/lib/dependencies/URLPlugin.js +7 -1
- package/lib/dependencies/WorkerPlugin.js +1 -1
- package/lib/esm/ModuleChunkLoadingRuntimeModule.js +4 -2
- package/lib/hmr/HotModuleReplacement.runtime.js +1 -0
- package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +1 -0
- package/lib/hmr/LazyCompilationPlugin.js +16 -4
- package/lib/hmr/lazyCompilationBackend.js +1 -7
- package/lib/index.js +37 -7
- package/lib/javascript/EnableChunkLoadingPlugin.js +2 -2
- package/lib/javascript/JavascriptGenerator.js +8 -8
- package/lib/javascript/JavascriptModulesPlugin.js +126 -73
- package/lib/javascript/JavascriptParser.js +338 -117
- package/lib/json/JsonGenerator.js +5 -5
- package/lib/library/EnableLibraryPlugin.js +2 -2
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
- package/lib/library/UmdLibraryPlugin.js +16 -8
- package/lib/logging/Logger.js +11 -11
- package/lib/logging/createConsoleLogger.js +14 -14
- package/lib/logging/truncateArgs.js +1 -1
- package/lib/node/NodeWatchFileSystem.js +3 -1
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +20 -18
- package/lib/node/ReadFileCompileWasmPlugin.js +1 -2
- package/lib/node/nodeConsole.js +11 -8
- package/lib/optimize/AggressiveSplittingPlugin.js +21 -7
- package/lib/optimize/ConcatenatedModule.js +43 -145
- package/lib/optimize/FlagIncludedChunksPlugin.js +6 -0
- package/lib/optimize/InnerGraphPlugin.js +57 -16
- package/lib/optimize/LimitChunkCountPlugin.js +2 -4
- package/lib/optimize/ModuleConcatenationPlugin.js +4 -2
- package/lib/optimize/RealContentHashPlugin.js +1 -1
- package/lib/optimize/SideEffectsFlagPlugin.js +6 -3
- package/lib/rules/RuleSetCompiler.js +2 -2
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +2 -2
- package/lib/schemes/DataUriPlugin.js +1 -1
- package/lib/serialization/BinaryMiddleware.js +32 -19
- package/lib/serialization/ObjectMiddleware.js +23 -9
- package/lib/serialization/SerializerMiddleware.js +3 -2
- package/lib/serialization/types.js +2 -2
- package/lib/sharing/ConsumeSharedModule.js +2 -3
- package/lib/sharing/ConsumeSharedRuntimeModule.js +3 -1
- package/lib/sharing/ProvideSharedModule.js +2 -3
- package/lib/stats/DefaultStatsFactoryPlugin.js +22 -20
- package/lib/stats/StatsFactory.js +12 -12
- package/lib/stats/StatsPrinter.js +7 -7
- package/lib/util/AsyncQueue.js +17 -1
- package/lib/util/IterableHelpers.js +1 -1
- package/lib/util/SetHelpers.js +1 -1
- package/lib/util/cleverMerge.js +48 -24
- package/lib/util/concatenate.js +227 -0
- package/lib/util/create-schema-validation.js +22 -9
- package/lib/util/deprecation.js +86 -28
- package/lib/util/fs.js +9 -9
- package/lib/util/hash/wasm-hash.js +12 -1
- package/lib/util/magicComment.js +21 -0
- package/lib/util/makeSerializable.js +24 -1
- package/lib/util/memoize.js +2 -1
- package/lib/util/runtime.js +4 -1
- package/lib/util/semver.js +130 -23
- package/lib/wasm/EnableWasmLoadingPlugin.js +2 -2
- package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +5 -5
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -5
- package/lib/wasm-sync/WebAssemblyGenerator.js +8 -9
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +5 -5
- package/lib/web/FetchCompileAsyncWasmPlugin.js +1 -2
- package/lib/web/FetchCompileWasmPlugin.js +1 -2
- package/lib/web/JsonpChunkLoadingRuntimeModule.js +6 -6
- package/package.json +18 -19
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +8 -2
- package/types.d.ts +801 -259
- package/lib/util/mergeScope.js +0 -76
@@ -76,6 +76,12 @@ class LoaderPlugin {
|
|
76
76
|
)
|
77
77
|
);
|
78
78
|
}
|
79
|
+
const oldFactorizeQueueContext =
|
80
|
+
compilation.factorizeQueue.getContext();
|
81
|
+
compilation.factorizeQueue.setContext("load-module");
|
82
|
+
const oldAddModuleQueueContext =
|
83
|
+
compilation.addModuleQueue.getContext();
|
84
|
+
compilation.addModuleQueue.setContext("load-module");
|
79
85
|
compilation.buildQueue.increaseParallelism();
|
80
86
|
compilation.handleModuleCreation(
|
81
87
|
{
|
@@ -88,6 +94,8 @@ class LoaderPlugin {
|
|
88
94
|
recursive: false
|
89
95
|
},
|
90
96
|
err => {
|
97
|
+
compilation.factorizeQueue.setContext(oldFactorizeQueueContext);
|
98
|
+
compilation.addModuleQueue.setContext(oldAddModuleQueueContext);
|
91
99
|
compilation.buildQueue.decreaseParallelism();
|
92
100
|
if (err) {
|
93
101
|
return callback(err);
|
@@ -173,6 +181,13 @@ class LoaderPlugin {
|
|
173
181
|
)
|
174
182
|
);
|
175
183
|
}
|
184
|
+
|
185
|
+
const oldFactorizeQueueContext =
|
186
|
+
compilation.factorizeQueue.getContext();
|
187
|
+
compilation.factorizeQueue.setContext("import-module");
|
188
|
+
const oldAddModuleQueueContext =
|
189
|
+
compilation.addModuleQueue.getContext();
|
190
|
+
compilation.addModuleQueue.setContext("import-module");
|
176
191
|
compilation.buildQueue.increaseParallelism();
|
177
192
|
compilation.handleModuleCreation(
|
178
193
|
{
|
@@ -189,6 +204,8 @@ class LoaderPlugin {
|
|
189
204
|
checkCycle: true
|
190
205
|
},
|
191
206
|
err => {
|
207
|
+
compilation.factorizeQueue.setContext(oldFactorizeQueueContext);
|
208
|
+
compilation.addModuleQueue.setContext(oldAddModuleQueueContext);
|
192
209
|
compilation.buildQueue.decreaseParallelism();
|
193
210
|
if (err) {
|
194
211
|
return callback(err);
|
@@ -197,6 +214,7 @@ class LoaderPlugin {
|
|
197
214
|
if (!referencedModule) {
|
198
215
|
return callback(new Error("Cannot load the module"));
|
199
216
|
}
|
217
|
+
compilation.buildQueue.increaseParallelism();
|
200
218
|
compilation.executeModule(
|
201
219
|
referencedModule,
|
202
220
|
{
|
@@ -206,6 +224,7 @@ class LoaderPlugin {
|
|
206
224
|
}
|
207
225
|
},
|
208
226
|
(err, result) => {
|
227
|
+
compilation.buildQueue.decreaseParallelism();
|
209
228
|
if (err) return callback(err);
|
210
229
|
const {
|
211
230
|
fileDependencies,
|
@@ -19,6 +19,7 @@ const InnerGraph = require("../optimize/InnerGraph");
|
|
19
19
|
const ConstDependency = require("./ConstDependency");
|
20
20
|
const URLDependency = require("./URLDependency");
|
21
21
|
|
22
|
+
/** @typedef {import("estree").MemberExpression} MemberExpression */
|
22
23
|
/** @typedef {import("estree").NewExpression} NewExpressionNode */
|
23
24
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
24
25
|
/** @typedef {import("../Compiler")} Compiler */
|
@@ -50,6 +51,11 @@ class URLPlugin {
|
|
50
51
|
*/
|
51
52
|
const getUrl = module => pathToFileURL(module.resource);
|
52
53
|
|
54
|
+
/**
|
55
|
+
* @param {Parser} parser parser parser
|
56
|
+
* @param {MemberExpression} arg arg
|
57
|
+
* @returns {boolean} true when it is `meta.url`, otherwise false
|
58
|
+
*/
|
53
59
|
const isMetaUrl = (parser, arg) => {
|
54
60
|
const chain = parser.extractMemberExpressionChain(arg);
|
55
61
|
|
@@ -117,7 +123,7 @@ class URLPlugin {
|
|
117
123
|
parser.state.module.addWarning(
|
118
124
|
new CommentCompilationWarning(
|
119
125
|
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
|
120
|
-
comment.loc
|
126
|
+
/** @type {DependencyLocation} */ (comment.loc)
|
121
127
|
)
|
122
128
|
);
|
123
129
|
}
|
@@ -251,7 +251,7 @@ class WorkerPlugin {
|
|
251
251
|
parser.state.module.addWarning(
|
252
252
|
new CommentCompilationWarning(
|
253
253
|
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
|
254
|
-
comment.loc
|
254
|
+
/** @type {DependencyLocation} */ (comment.loc)
|
255
255
|
)
|
256
256
|
);
|
257
257
|
}
|
@@ -113,10 +113,12 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|
113
113
|
ModuleChunkLoadingRuntimeModule.getCompilationHooks(compilation);
|
114
114
|
const withPrefetch =
|
115
115
|
environment.document &&
|
116
|
-
this._runtimeRequirements.has(RuntimeGlobals.prefetchChunkHandlers)
|
116
|
+
this._runtimeRequirements.has(RuntimeGlobals.prefetchChunkHandlers) &&
|
117
|
+
chunk.hasChildByOrder(chunkGraph, "prefetch", true, chunkHasJs);
|
117
118
|
const withPreload =
|
118
119
|
environment.document &&
|
119
|
-
this._runtimeRequirements.has(RuntimeGlobals.preloadChunkHandlers)
|
120
|
+
this._runtimeRequirements.has(RuntimeGlobals.preloadChunkHandlers) &&
|
121
|
+
chunk.hasChildByOrder(chunkGraph, "preload", true, chunkHasJs);
|
120
122
|
const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);
|
121
123
|
const hasJsMatcher = compileBooleanMatcher(conditionMap);
|
122
124
|
const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);
|
@@ -10,6 +10,7 @@ const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
|
|
10
10
|
const Dependency = require("../Dependency");
|
11
11
|
const Module = require("../Module");
|
12
12
|
const ModuleFactory = require("../ModuleFactory");
|
13
|
+
const { JS_TYPES } = require("../ModuleSourceTypesConstants");
|
13
14
|
const {
|
14
15
|
WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY
|
15
16
|
} = require("../ModuleTypeConstants");
|
@@ -73,8 +74,6 @@ const checkTest = (test, module) => {
|
|
73
74
|
return false;
|
74
75
|
};
|
75
76
|
|
76
|
-
const TYPES = new Set(["javascript"]);
|
77
|
-
|
78
77
|
class LazyCompilationDependency extends Dependency {
|
79
78
|
/**
|
80
79
|
* @param {LazyCompilationProxyModule} proxyModule proxy module
|
@@ -207,7 +206,7 @@ class LazyCompilationProxyModule extends Module {
|
|
207
206
|
* @returns {SourceTypes} types available (do not mutate)
|
208
207
|
*/
|
209
208
|
getSourceTypes() {
|
210
|
-
return
|
209
|
+
return JS_TYPES;
|
211
210
|
}
|
212
211
|
|
213
212
|
/**
|
@@ -329,10 +328,23 @@ class LazyCompilationDependencyFactory extends ModuleFactory {
|
|
329
328
|
}
|
330
329
|
}
|
331
330
|
|
331
|
+
/**
|
332
|
+
* @callback BackendHandler
|
333
|
+
* @param {Compiler} compiler compiler
|
334
|
+
* @param {function(Error | null, BackendApi=): void} callback callback
|
335
|
+
* @returns {void}
|
336
|
+
*/
|
337
|
+
|
338
|
+
/**
|
339
|
+
* @callback PromiseBackendHandler
|
340
|
+
* @param {Compiler} compiler compiler
|
341
|
+
* @returns {Promise<BackendApi>} backend
|
342
|
+
*/
|
343
|
+
|
332
344
|
class LazyCompilationPlugin {
|
333
345
|
/**
|
334
346
|
* @param {object} options options
|
335
|
-
* @param {
|
347
|
+
* @param {BackendHandler | PromiseBackendHandler} options.backend the backend
|
336
348
|
* @param {boolean} options.entries true, when entries are lazy compiled
|
337
349
|
* @param {boolean} options.imports true, when import() modules are lazy compiled
|
338
350
|
* @param {RegExp | string | (function(Module): boolean) | undefined} options.test additional filter for lazy compiled entrypoint modules
|
@@ -16,13 +16,7 @@
|
|
16
16
|
/** @typedef {import("../Compiler")} Compiler */
|
17
17
|
/** @typedef {import("../Module")} Module */
|
18
18
|
/** @typedef {import("./LazyCompilationPlugin").BackendApi} BackendApi */
|
19
|
-
|
20
|
-
/**
|
21
|
-
* @callback BackendHandler
|
22
|
-
* @param {Compiler} compiler compiler
|
23
|
-
* @param {function(Error | null, BackendApi=): void} callback callback
|
24
|
-
* @returns {void}
|
25
|
-
*/
|
19
|
+
/** @typedef {import("./LazyCompilationPlugin").BackendHandler} BackendHandler */
|
26
20
|
|
27
21
|
/**
|
28
22
|
* @param {Omit<LazyCompilationDefaultBackendOptions, "client"> & { client: NonNullable<LazyCompilationDefaultBackendOptions["client"]>}} options additional options for the backend
|
package/lib/index.js
CHANGED
@@ -70,7 +70,13 @@ const memoize = require("./util/memoize");
|
|
70
70
|
*/
|
71
71
|
const lazyFunction = factory => {
|
72
72
|
const fac = memoize(factory);
|
73
|
-
const f = /** @type {any} */ (
|
73
|
+
const f = /** @type {any} */ (
|
74
|
+
/**
|
75
|
+
* @param {...any} args args
|
76
|
+
* @returns {T} result
|
77
|
+
*/
|
78
|
+
(...args) => fac()(...args)
|
79
|
+
);
|
74
80
|
return /** @type {T} */ (f);
|
75
81
|
};
|
76
82
|
|
@@ -113,15 +119,24 @@ module.exports = mergeExports(fn, {
|
|
113
119
|
get webpack() {
|
114
120
|
return require("./webpack");
|
115
121
|
},
|
122
|
+
/**
|
123
|
+
* @returns {function(Configuration | Configuration[]): void} validate fn
|
124
|
+
*/
|
116
125
|
get validate() {
|
117
126
|
const webpackOptionsSchemaCheck = require("../schemas/WebpackOptions.check.js");
|
118
|
-
const getRealValidate = memoize(
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
127
|
+
const getRealValidate = memoize(
|
128
|
+
/**
|
129
|
+
* @returns {function(Configuration | Configuration[]): void} validate fn
|
130
|
+
*/
|
131
|
+
() => {
|
132
|
+
const validateSchema = require("./validateSchema");
|
133
|
+
const webpackOptionsSchema = require("../schemas/WebpackOptions.json");
|
134
|
+
return options => validateSchema(webpackOptionsSchema, options);
|
135
|
+
}
|
136
|
+
);
|
123
137
|
return options => {
|
124
|
-
if (!webpackOptionsSchemaCheck(options))
|
138
|
+
if (!webpackOptionsSchemaCheck(/** @type {TODO} */ (options)))
|
139
|
+
getRealValidate()(options);
|
125
140
|
};
|
126
141
|
},
|
127
142
|
get validateSchema() {
|
@@ -475,6 +490,15 @@ module.exports = mergeExports(fn, {
|
|
475
490
|
},
|
476
491
|
get JsonpTemplatePlugin() {
|
477
492
|
return require("./web/JsonpTemplatePlugin");
|
493
|
+
},
|
494
|
+
get CssLoadingRuntimeModule() {
|
495
|
+
return require("./css/CssLoadingRuntimeModule");
|
496
|
+
}
|
497
|
+
},
|
498
|
+
|
499
|
+
esm: {
|
500
|
+
get ModuleChunkLoadingRuntimeModule() {
|
501
|
+
return require("./esm/ModuleChunkLoadingRuntimeModule");
|
478
502
|
}
|
479
503
|
},
|
480
504
|
|
@@ -517,6 +541,12 @@ module.exports = mergeExports(fn, {
|
|
517
541
|
}
|
518
542
|
},
|
519
543
|
|
544
|
+
css: {
|
545
|
+
get CssModulesPlugin() {
|
546
|
+
return require("./css/CssModulesPlugin");
|
547
|
+
}
|
548
|
+
},
|
549
|
+
|
520
550
|
library: {
|
521
551
|
get AbstractLibraryPlugin() {
|
522
552
|
return require("./library/AbstractLibraryPlugin");
|
@@ -51,8 +51,8 @@ class EnableChunkLoadingPlugin {
|
|
51
51
|
throw new Error(
|
52
52
|
`Chunk loading type "${type}" is not enabled. ` +
|
53
53
|
"EnableChunkLoadingPlugin need to be used to enable this type of chunk loading. " +
|
54
|
-
|
55
|
-
|
54
|
+
'This usually happens through the "output.enabledChunkLoadingTypes" option. ' +
|
55
|
+
'If you are using a function as entry which sets "chunkLoading", you need to add all potential chunk loading types to "output.enabledChunkLoadingTypes". ' +
|
56
56
|
`These types are enabled: ${Array.from(
|
57
57
|
getEnabledTypes(compiler)
|
58
58
|
).join(", ")}`
|
@@ -9,6 +9,7 @@ const util = require("util");
|
|
9
9
|
const { RawSource, ReplaceSource } = require("webpack-sources");
|
10
10
|
const Generator = require("../Generator");
|
11
11
|
const InitFragment = require("../InitFragment");
|
12
|
+
const { JS_TYPES } = require("../ModuleSourceTypesConstants");
|
12
13
|
const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency");
|
13
14
|
|
14
15
|
/** @typedef {import("webpack-sources").Source} Source */
|
@@ -20,6 +21,7 @@ const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibi
|
|
20
21
|
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
21
22
|
/** @typedef {import("../Module")} Module */
|
22
23
|
/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
24
|
+
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
23
25
|
/** @typedef {import("../NormalModule")} NormalModule */
|
24
26
|
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
25
27
|
|
@@ -40,15 +42,13 @@ const deprecatedGetInitFragments = util.deprecate(
|
|
40
42
|
"DEP_WEBPACK_JAVASCRIPT_GENERATOR_GET_INIT_FRAGMENTS"
|
41
43
|
);
|
42
44
|
|
43
|
-
const TYPES = new Set(["javascript"]);
|
44
|
-
|
45
45
|
class JavascriptGenerator extends Generator {
|
46
46
|
/**
|
47
47
|
* @param {NormalModule} module fresh module
|
48
|
-
* @returns {
|
48
|
+
* @returns {SourceTypes} available types (do not mutate)
|
49
49
|
*/
|
50
50
|
getTypes(module) {
|
51
|
-
return
|
51
|
+
return JS_TYPES;
|
52
52
|
}
|
53
53
|
|
54
54
|
/**
|
@@ -93,7 +93,7 @@ class JavascriptGenerator extends Generator {
|
|
93
93
|
/**
|
94
94
|
* @param {NormalModule} module module for which the code should be generated
|
95
95
|
* @param {GenerateContext} generateContext context for generate
|
96
|
-
* @returns {Source} generated code
|
96
|
+
* @returns {Source | null} generated code
|
97
97
|
*/
|
98
98
|
generate(module, generateContext) {
|
99
99
|
const originalSource = module.originalSource();
|
@@ -190,9 +190,9 @@ class JavascriptGenerator extends Generator {
|
|
190
190
|
* @returns {void}
|
191
191
|
*/
|
192
192
|
sourceDependency(module, dependency, initFragments, source, generateContext) {
|
193
|
-
const constructor =
|
194
|
-
|
195
|
-
|
193
|
+
const constructor =
|
194
|
+
/** @type {new (...args: EXPECTED_ANY[]) => Dependency} */
|
195
|
+
(dependency.constructor);
|
196
196
|
const template = generateContext.dependencyTemplates.get(constructor);
|
197
197
|
if (!template) {
|
198
198
|
throw new Error(
|