webpack 5.103.0 → 5.104.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/hot/dev-server.js +18 -3
- package/hot/emitter-event-target.js +7 -0
- package/hot/lazy-compilation-node.js +45 -29
- package/hot/lazy-compilation-universal.js +18 -0
- package/hot/lazy-compilation-web.js +15 -5
- package/hot/load-http.js +7 -0
- package/hot/only-dev-server.js +19 -4
- package/lib/APIPlugin.js +6 -0
- package/lib/Chunk.js +1 -1
- package/lib/ChunkGraph.js +9 -7
- package/lib/ChunkGroup.js +8 -5
- package/lib/CleanPlugin.js +6 -3
- package/lib/CodeGenerationResults.js +2 -1
- package/lib/CompatibilityPlugin.js +3 -0
- package/lib/Compilation.js +33 -19
- package/lib/Compiler.js +3 -3
- package/lib/ContextModule.js +6 -3
- package/lib/ContextModuleFactory.js +6 -4
- package/lib/DefinePlugin.js +34 -3
- package/lib/DelegatedModule.js +7 -4
- package/lib/DllModule.js +6 -3
- package/lib/DotenvPlugin.js +11 -6
- package/lib/ExportsInfo.js +5 -5
- package/lib/ExternalModule.js +8 -7
- package/lib/ExternalModuleFactoryPlugin.js +1 -1
- package/lib/FileSystemInfo.js +1 -1
- package/lib/Generator.js +10 -7
- package/lib/HookWebpackError.js +33 -4
- package/lib/HotModuleReplacementPlugin.js +22 -0
- package/lib/ManifestPlugin.js +1 -1
- package/lib/Module.js +24 -15
- package/lib/ModuleBuildError.js +1 -1
- package/lib/ModuleError.js +1 -1
- package/lib/ModuleFilenameHelpers.js +1 -1
- package/lib/ModuleGraph.js +27 -12
- package/lib/ModuleGraphConnection.js +2 -2
- package/lib/ModuleSourceTypeConstants.js +189 -0
- package/lib/ModuleTypeConstants.js +1 -4
- package/lib/ModuleWarning.js +1 -1
- package/lib/NodeStuffPlugin.js +52 -42
- package/lib/NormalModule.js +6 -4
- package/lib/NormalModuleFactory.js +7 -10
- package/lib/Parser.js +1 -1
- package/lib/RawModule.js +7 -4
- package/lib/RuntimeModule.js +1 -1
- package/lib/RuntimeTemplate.js +5 -1
- package/lib/SizeFormatHelpers.js +1 -1
- package/lib/SourceMapDevToolPlugin.js +6 -1
- package/lib/Template.js +17 -6
- package/lib/TemplatedPathPlugin.js +5 -6
- package/lib/WebpackError.js +0 -1
- package/lib/WebpackOptionsApply.js +37 -9
- package/lib/asset/AssetBytesGenerator.js +15 -11
- package/lib/asset/AssetGenerator.js +30 -24
- package/lib/asset/AssetSourceGenerator.js +15 -11
- package/lib/asset/RawDataUrlModule.js +6 -3
- package/lib/buildChunkGraph.js +4 -2
- package/lib/cache/PackFileCacheStrategy.js +6 -5
- package/lib/cli.js +2 -43
- package/lib/config/browserslistTargetHandler.js +19 -0
- package/lib/config/defaults.js +128 -43
- package/lib/config/normalization.js +2 -2
- package/lib/config/target.js +5 -0
- package/lib/container/ContainerEntryModule.js +6 -3
- package/lib/container/FallbackModule.js +6 -3
- package/lib/container/RemoteModule.js +1 -3
- package/lib/css/CssGenerator.js +26 -24
- package/lib/css/CssLoadingRuntimeModule.js +12 -4
- package/lib/css/CssModulesPlugin.js +29 -74
- package/lib/css/CssParser.js +828 -341
- package/lib/css/walkCssTokens.js +33 -13
- package/lib/dependencies/CachedConstDependency.js +24 -10
- package/lib/dependencies/CommonJsRequireContextDependency.js +1 -1
- package/lib/dependencies/ContextDependencyHelpers.js +2 -2
- package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +3 -1
- package/lib/dependencies/CssIcssExportDependency.js +242 -104
- package/lib/dependencies/CssIcssImportDependency.js +61 -4
- package/lib/dependencies/CssIcssSymbolDependency.js +2 -6
- package/lib/dependencies/CssImportDependency.js +2 -1
- package/lib/dependencies/CssUrlDependency.js +3 -2
- package/lib/dependencies/DynamicExports.js +7 -7
- package/lib/dependencies/ExternalModuleDependency.js +7 -4
- package/lib/dependencies/ExternalModuleInitFragment.js +2 -1
- package/lib/dependencies/ExternalModuleInitFragmentDependency.js +2 -1
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +3 -2
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +6 -4
- package/lib/dependencies/HarmonyExports.js +4 -4
- package/lib/dependencies/HarmonyImportDependency.js +8 -3
- package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
- package/lib/dependencies/ImportMetaPlugin.js +57 -0
- package/lib/dependencies/ImportParserPlugin.js +2 -2
- package/lib/dependencies/LocalModulesHelpers.js +3 -3
- package/lib/dependencies/WorkerPlugin.js +2 -2
- package/lib/dependencies/getFunctionExpression.js +1 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +5 -4
- package/lib/hmr/HotModuleReplacement.runtime.js +2 -1
- package/lib/hmr/LazyCompilationPlugin.js +4 -3
- package/lib/ids/IdHelpers.js +16 -7
- package/lib/javascript/ChunkHelpers.js +1 -1
- package/lib/javascript/JavascriptGenerator.js +4 -3
- package/lib/javascript/JavascriptModulesPlugin.js +57 -24
- package/lib/javascript/JavascriptParser.js +19 -6
- package/lib/json/JsonGenerator.js +5 -4
- package/lib/json/JsonParser.js +2 -1
- package/lib/library/AbstractLibraryPlugin.js +1 -1
- package/lib/library/AmdLibraryPlugin.js +4 -1
- package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
- package/lib/library/ModuleLibraryPlugin.js +41 -13
- package/lib/library/SystemLibraryPlugin.js +4 -1
- package/lib/library/UmdLibraryPlugin.js +1 -1
- package/lib/logging/Logger.js +5 -4
- package/lib/logging/createConsoleLogger.js +2 -2
- package/lib/optimize/ConcatenatedModule.js +47 -32
- package/lib/optimize/ModuleConcatenationPlugin.js +5 -4
- package/lib/optimize/SideEffectsFlagPlugin.js +3 -2
- package/lib/optimize/SplitChunksPlugin.js +60 -46
- package/lib/rules/RuleSetCompiler.js +1 -1
- package/lib/runtime/GetChunkFilenameRuntimeModule.js +3 -2
- package/lib/schemes/HttpUriPlugin.js +97 -10
- package/lib/serialization/AggregateErrorSerializer.js +1 -2
- package/lib/serialization/ObjectMiddleware.js +0 -2
- package/lib/serialization/SingleItemMiddleware.js +1 -1
- package/lib/sharing/ConsumeSharedModule.js +1 -1
- package/lib/sharing/ConsumeSharedPlugin.js +5 -3
- package/lib/sharing/ProvideSharedModule.js +1 -1
- package/lib/sharing/resolveMatchedConfigs.js +15 -9
- package/lib/sharing/utils.js +1 -1
- package/lib/stats/DefaultStatsFactoryPlugin.js +8 -5
- package/lib/stats/DefaultStatsPresetPlugin.js +1 -1
- package/lib/stats/DefaultStatsPrinterPlugin.js +1 -1
- package/lib/util/StringXor.js +1 -1
- package/lib/util/URLAbsoluteSpecifier.js +2 -2
- package/lib/util/binarySearchBounds.js +2 -2
- package/lib/util/comparators.js +53 -76
- package/lib/util/compileBooleanMatcher.js +78 -6
- package/lib/util/createHash.js +20 -199
- package/lib/util/deprecation.js +1 -1
- package/lib/util/deterministicGrouping.js +6 -3
- package/lib/util/fs.js +75 -75
- package/lib/util/hash/BatchedHash.js +10 -9
- package/lib/util/hash/BulkUpdateHash.js +138 -0
- package/lib/util/hash/DebugHash.js +75 -0
- package/lib/util/hash/hash-digest.js +216 -0
- package/lib/util/identifier.js +82 -17
- package/lib/util/internalSerializables.js +2 -6
- package/lib/util/runtime.js +3 -3
- package/lib/util/source.js +2 -2
- package/lib/wasm-async/AsyncWebAssemblyGenerator.js +3 -2
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +3 -2
- package/lib/wasm-sync/WebAssemblyGenerator.js +9 -6
- package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +3 -2
- package/lib/wasm-sync/WebAssemblyModulesPlugin.js +6 -2
- package/lib/webpack.js +1 -1
- package/package.json +30 -25
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +59 -82
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/types.d.ts +225 -158
- package/lib/ModuleSourceTypesConstants.js +0 -117
- package/lib/dependencies/CssIcssFromIdentifierDependency.js +0 -124
- package/lib/dependencies/CssIcssGlobalIdentifierDependency.js +0 -48
- package/lib/dependencies/CssIcssLocalIdentifierDependency.js +0 -61
- package/lib/dependencies/CssIcssSelfLocalIdentifierDependency.js +0 -190
- package/lib/util/jsonParseEvenBetterErrors.js +0 -10
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssAutoGeneratorOptions.check.js +0 -6
- package/schemas/plugins/css/CssAutoGeneratorOptions.json +0 -3
- package/schemas/plugins/css/CssAutoParserOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssAutoParserOptions.check.js +0 -6
- package/schemas/plugins/css/CssAutoParserOptions.json +0 -3
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssGlobalGeneratorOptions.check.js +0 -6
- package/schemas/plugins/css/CssGlobalGeneratorOptions.json +0 -3
- package/schemas/plugins/css/CssGlobalParserOptions.check.d.ts +0 -7
- package/schemas/plugins/css/CssGlobalParserOptions.check.js +0 -6
- package/schemas/plugins/css/CssGlobalParserOptions.json +0 -3
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
+
const { CSS_TYPE } = require("../ModuleSourceTypeConstants");
|
|
8
9
|
const makeSerializable = require("../util/makeSerializable");
|
|
9
10
|
const CssIcssExportDependency = require("./CssIcssExportDependency");
|
|
10
11
|
const NullDependency = require("./NullDependency");
|
|
@@ -42,10 +43,6 @@ class CssIcssSymbolDependency extends NullDependency {
|
|
|
42
43
|
return "css symbol identifier";
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
get category() {
|
|
46
|
-
return "self";
|
|
47
|
-
}
|
|
48
|
-
|
|
49
46
|
/**
|
|
50
47
|
* Update the hash
|
|
51
48
|
* @param {Hash} hash hash to be updated
|
|
@@ -106,7 +103,7 @@ CssIcssSymbolDependency.Template = class CssIcssSymbolDependencyTemplate extends
|
|
|
106
103
|
* @returns {void}
|
|
107
104
|
*/
|
|
108
105
|
apply(dependency, source, templateContext) {
|
|
109
|
-
if (templateContext.type ===
|
|
106
|
+
if (templateContext.type === CSS_TYPE) {
|
|
110
107
|
const dep = /** @type {CssIcssSymbolDependency} */ (dependency);
|
|
111
108
|
/** @type {string | undefined} */
|
|
112
109
|
const value = dep.isReference
|
|
@@ -117,7 +114,6 @@ CssIcssSymbolDependency.Template = class CssIcssSymbolDependencyTemplate extends
|
|
|
117
114
|
: dep.symbol;
|
|
118
115
|
|
|
119
116
|
if (!value) {
|
|
120
|
-
// TODO generate warning
|
|
121
117
|
return;
|
|
122
118
|
}
|
|
123
119
|
|
|
@@ -10,7 +10,7 @@ const ModuleDependency = require("./ModuleDependency");
|
|
|
10
10
|
|
|
11
11
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
12
12
|
/** @typedef {import("../Dependency")} Dependency */
|
|
13
|
-
/** @typedef {import("../DependencyTemplate").
|
|
13
|
+
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
|
|
14
14
|
/** @typedef {import("../css/CssParser").Range} Range */
|
|
15
15
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
16
16
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
@@ -105,6 +105,7 @@ CssImportDependency.Template = class CssImportDependencyTemplate extends (
|
|
|
105
105
|
* @returns {void}
|
|
106
106
|
*/
|
|
107
107
|
apply(dependency, source, templateContext) {
|
|
108
|
+
if (templateContext.type === "javascript") return;
|
|
108
109
|
const dep = /** @type {CssImportDependency} */ (dependency);
|
|
109
110
|
|
|
110
111
|
source.replace(dep.range[0], dep.range[1] - 1, "");
|
|
@@ -13,7 +13,7 @@ const ModuleDependency = require("./ModuleDependency");
|
|
|
13
13
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
14
14
|
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
|
15
15
|
/** @typedef {import("../Dependency")} Dependency */
|
|
16
|
-
/** @typedef {import("../DependencyTemplate").
|
|
16
|
+
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
|
|
17
17
|
/** @typedef {import("../Module")} Module */
|
|
18
18
|
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
|
19
19
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
@@ -118,8 +118,9 @@ CssUrlDependency.Template = class CssUrlDependencyTemplate extends (
|
|
|
118
118
|
apply(
|
|
119
119
|
dependency,
|
|
120
120
|
source,
|
|
121
|
-
{ moduleGraph, runtimeTemplate, codeGenerationResults }
|
|
121
|
+
{ type, moduleGraph, runtimeTemplate, codeGenerationResults }
|
|
122
122
|
) {
|
|
123
|
+
if (type === "javascript") return;
|
|
123
124
|
const dep = /** @type {CssUrlDependency} */ (dependency);
|
|
124
125
|
const module = /** @type {Module} */ (moduleGraph.getModule(dep));
|
|
125
126
|
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
9
|
-
/** @typedef {import("../
|
|
9
|
+
/** @typedef {import("../javascript/JavascriptParser").JavascriptParserState} JavascriptParserState */
|
|
10
10
|
|
|
11
|
-
/** @type {WeakMap<
|
|
11
|
+
/** @type {WeakMap<JavascriptParserState, boolean>} */
|
|
12
12
|
const parserStateExportsState = new WeakMap();
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @param {
|
|
15
|
+
* @param {JavascriptParserState} parserState parser state
|
|
16
16
|
* @returns {void}
|
|
17
17
|
*/
|
|
18
18
|
module.exports.bailout = (parserState) => {
|
|
@@ -26,7 +26,7 @@ module.exports.bailout = (parserState) => {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
* @param {
|
|
29
|
+
* @param {JavascriptParserState} parserState parser state
|
|
30
30
|
* @returns {void}
|
|
31
31
|
*/
|
|
32
32
|
module.exports.enable = (parserState) => {
|
|
@@ -41,7 +41,7 @@ module.exports.enable = (parserState) => {
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* @param {
|
|
44
|
+
* @param {JavascriptParserState} parserState parser state
|
|
45
45
|
* @returns {boolean} true, when enabled
|
|
46
46
|
*/
|
|
47
47
|
module.exports.isEnabled = (parserState) => {
|
|
@@ -50,7 +50,7 @@ module.exports.isEnabled = (parserState) => {
|
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
|
-
* @param {
|
|
53
|
+
* @param {JavascriptParserState} parserState parser state
|
|
54
54
|
* @returns {void}
|
|
55
55
|
*/
|
|
56
56
|
module.exports.setDynamic = (parserState) => {
|
|
@@ -61,7 +61,7 @@ module.exports.setDynamic = (parserState) => {
|
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* @param {
|
|
64
|
+
* @param {JavascriptParserState} parserState parser state
|
|
65
65
|
* @returns {void}
|
|
66
66
|
*/
|
|
67
67
|
module.exports.setFlagged = (parserState) => {
|
|
@@ -13,17 +13,19 @@ const ExternalModuleInitFragment = require("./ExternalModuleInitFragment");
|
|
|
13
13
|
/** @typedef {import("../Dependency")} Dependency */
|
|
14
14
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
15
15
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
16
|
+
/** @typedef {import("../dependencies/ExternalModuleInitFragment").ArrayImportSpecifiers} ArrayImportSpecifiers */
|
|
16
17
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
17
18
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
18
19
|
|
|
19
20
|
class ExternalModuleDependency extends CachedConstDependency {
|
|
20
21
|
/**
|
|
21
22
|
* @param {string} module module
|
|
22
|
-
* @param {
|
|
23
|
+
* @param {ArrayImportSpecifiers} importSpecifiers import specifiers
|
|
23
24
|
* @param {string | undefined} defaultImport default import
|
|
24
25
|
* @param {string} expression expression
|
|
25
|
-
* @param {Range} range range
|
|
26
|
+
* @param {Range | null} range range
|
|
26
27
|
* @param {string} identifier identifier
|
|
28
|
+
* @param {number=} place place where we inject the expression
|
|
27
29
|
*/
|
|
28
30
|
constructor(
|
|
29
31
|
module,
|
|
@@ -31,9 +33,10 @@ class ExternalModuleDependency extends CachedConstDependency {
|
|
|
31
33
|
defaultImport,
|
|
32
34
|
expression,
|
|
33
35
|
range,
|
|
34
|
-
identifier
|
|
36
|
+
identifier,
|
|
37
|
+
place = CachedConstDependency.PLACE_MODULE
|
|
35
38
|
) {
|
|
36
|
-
super(expression, range, identifier);
|
|
39
|
+
super(expression, range, identifier, place);
|
|
37
40
|
|
|
38
41
|
this.importedModule = module;
|
|
39
42
|
this.specifiers = importSpecifiers;
|
|
@@ -12,6 +12,7 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
12
12
|
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
|
13
13
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
14
14
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
15
|
+
/** @typedef {{ name: string, value?: string }[]} ArrayImportSpecifiers */
|
|
15
16
|
/** @typedef {Map<string, Set<string>>} ImportSpecifiers */
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -20,7 +21,7 @@ const makeSerializable = require("../util/makeSerializable");
|
|
|
20
21
|
class ExternalModuleInitFragment extends InitFragment {
|
|
21
22
|
/**
|
|
22
23
|
* @param {string} importedModule imported module
|
|
23
|
-
* @param {
|
|
24
|
+
* @param {ArrayImportSpecifiers | ImportSpecifiers} specifiers import specifiers
|
|
24
25
|
* @param {string=} defaultImport default import
|
|
25
26
|
*/
|
|
26
27
|
constructor(importedModule, specifiers, defaultImport) {
|
|
@@ -14,13 +14,14 @@ const NullDependency = require("./NullDependency");
|
|
|
14
14
|
/** @typedef {import("../Dependency")} Dependency */
|
|
15
15
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
16
16
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
17
|
+
/** @typedef {import("../dependencies/ExternalModuleInitFragment").ArrayImportSpecifiers} ArrayImportSpecifiers */
|
|
17
18
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|
18
19
|
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|
19
20
|
|
|
20
21
|
class ExternalModuleInitFragmentDependency extends NullDependency {
|
|
21
22
|
/**
|
|
22
23
|
* @param {string} module module
|
|
23
|
-
* @param {
|
|
24
|
+
* @param {ArrayImportSpecifiers} importSpecifiers import specifiers
|
|
24
25
|
* @param {string | undefined} defaultImport default import
|
|
25
26
|
*/
|
|
26
27
|
constructor(module, importSpecifiers, defaultImport) {
|
|
@@ -123,7 +123,7 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
|
123
123
|
})
|
|
124
124
|
.join(""),
|
|
125
125
|
node.type.endsWith("Declaration") &&
|
|
126
|
-
|
|
126
|
+
/** @type {FunctionDeclaration | ClassDeclaration} */ (node).id
|
|
127
127
|
? /** @type {FunctionDeclaration | ClassDeclaration} */
|
|
128
128
|
(node).id.name
|
|
129
129
|
: isFunctionDeclaration
|
|
@@ -224,7 +224,8 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
|
224
224
|
const dep = new HarmonyExportImportedSpecifierDependency(
|
|
225
225
|
/** @type {string} */
|
|
226
226
|
(source),
|
|
227
|
-
|
|
227
|
+
/** @type {number} */
|
|
228
|
+
(parser.state.lastHarmonyImportOrder),
|
|
228
229
|
id ? [id] : [],
|
|
229
230
|
name,
|
|
230
231
|
harmonyNamedExports,
|
|
@@ -60,7 +60,7 @@ const processExportInfo = require("./processExportInfo");
|
|
|
60
60
|
/** @typedef {import("./HarmonyImportDependency").ExportPresenceMode} ExportPresenceMode */
|
|
61
61
|
/** @typedef {import("../dependencies/ImportPhase").ImportPhaseType} ImportPhaseType */
|
|
62
62
|
|
|
63
|
-
/** @typedef {"missing"|"unused"|"empty-star"|"reexport-dynamic-default"|"reexport-named-default"|"reexport-namespace-object"|"reexport-fake-namespace-object"|"reexport-undefined"|"normal-reexport"|"dynamic-reexport"} ExportModeType */
|
|
63
|
+
/** @typedef {"missing" | "unused" | "empty-star" | "reexport-dynamic-default" | "reexport-named-default" | "reexport-namespace-object" | "reexport-fake-namespace-object" | "reexport-undefined" | "normal-reexport" | "dynamic-reexport"} ExportModeType */
|
|
64
64
|
|
|
65
65
|
const { ExportPresenceModes } = HarmonyImportDependency;
|
|
66
66
|
|
|
@@ -1251,9 +1251,11 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|
|
1251
1251
|
}
|
|
1252
1252
|
|
|
1253
1253
|
content += "__WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = ";
|
|
1254
|
-
content +=
|
|
1255
|
-
|
|
1256
|
-
|
|
1254
|
+
content +=
|
|
1255
|
+
runtimeTemplate.supportsArrowFunction() &&
|
|
1256
|
+
runtimeTemplate.supportsConst()
|
|
1257
|
+
? `() => ${importVar}[__WEBPACK_IMPORT_KEY__]`
|
|
1258
|
+
: `function(key) { return ${importVar}[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)`;
|
|
1257
1259
|
|
|
1258
1260
|
runtimeRequirements.add(RuntimeGlobals.exports);
|
|
1259
1261
|
runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
|
|
@@ -9,13 +9,13 @@ const RuntimeGlobals = require("../RuntimeGlobals");
|
|
|
9
9
|
|
|
10
10
|
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
|
11
11
|
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
|
12
|
-
/** @typedef {import("../
|
|
12
|
+
/** @typedef {import("../javascript/JavascriptParser").JavascriptParserState} JavascriptParserState */
|
|
13
13
|
|
|
14
|
-
/** @type {WeakMap<
|
|
14
|
+
/** @type {WeakMap<JavascriptParserState, boolean>} */
|
|
15
15
|
const parserStateExportsState = new WeakMap();
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
|
-
* @param {
|
|
18
|
+
* @param {JavascriptParserState} parserState parser state
|
|
19
19
|
* @param {boolean} isStrictHarmony strict harmony mode should be enabled
|
|
20
20
|
* @returns {void}
|
|
21
21
|
*/
|
|
@@ -37,7 +37,7 @@ module.exports.enable = (parserState, isStrictHarmony) => {
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
|
-
* @param {
|
|
40
|
+
* @param {JavascriptParserState} parserState parser state
|
|
41
41
|
* @returns {boolean} true, when enabled
|
|
42
42
|
*/
|
|
43
43
|
module.exports.isEnabled = (parserState) => {
|
|
@@ -12,7 +12,7 @@ const InitFragment = require("../InitFragment");
|
|
|
12
12
|
const Template = require("../Template");
|
|
13
13
|
const AwaitDependenciesInitFragment = require("../async-modules/AwaitDependenciesInitFragment");
|
|
14
14
|
const { filterRuntime, mergeRuntime } = require("../util/runtime");
|
|
15
|
-
const { ImportPhaseUtils } = require("./ImportPhase");
|
|
15
|
+
const { ImportPhase, ImportPhaseUtils } = require("./ImportPhase");
|
|
16
16
|
const ModuleDependency = require("./ModuleDependency");
|
|
17
17
|
|
|
18
18
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
@@ -62,10 +62,15 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
|
62
62
|
/**
|
|
63
63
|
* @param {string} request request string
|
|
64
64
|
* @param {number} sourceOrder source order
|
|
65
|
-
* @param {ImportPhaseType} phase import phase
|
|
65
|
+
* @param {ImportPhaseType=} phase import phase
|
|
66
66
|
* @param {ImportAttributes=} attributes import attributes
|
|
67
67
|
*/
|
|
68
|
-
constructor(
|
|
68
|
+
constructor(
|
|
69
|
+
request,
|
|
70
|
+
sourceOrder,
|
|
71
|
+
phase = ImportPhase.Evaluation,
|
|
72
|
+
attributes = undefined
|
|
73
|
+
) {
|
|
69
74
|
super(request, sourceOrder);
|
|
70
75
|
this.phase = phase;
|
|
71
76
|
this.attributes = attributes;
|
|
@@ -25,7 +25,7 @@ const ImportMetaContextDependency = require("./ImportMetaContextDependency");
|
|
|
25
25
|
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
|
26
26
|
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
|
27
27
|
|
|
28
|
-
/** @typedef {Pick<ContextModuleOptions,
|
|
28
|
+
/** @typedef {Pick<ContextModuleOptions, "mode" | "recursive" | "regExp" | "include" | "exclude" | "chunkName"> & { groupOptions: RawChunkGroupOptions, exports?: RawReferencedExports }} ImportMetaContextOptions */
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* @param {Property} prop property
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
const { pathToFileURL } = require("url");
|
|
9
9
|
const { SyncBailHook } = require("tapable");
|
|
10
10
|
const Compilation = require("../Compilation");
|
|
11
|
+
const DefinePlugin = require("../DefinePlugin");
|
|
11
12
|
const ModuleDependencyWarning = require("../ModuleDependencyWarning");
|
|
12
13
|
const {
|
|
13
14
|
JAVASCRIPT_MODULE_TYPE_AUTO,
|
|
@@ -43,6 +44,31 @@ const getCriticalDependencyWarning = memoize(() =>
|
|
|
43
44
|
|
|
44
45
|
const PLUGIN_NAME = "ImportMetaPlugin";
|
|
45
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Collect import.meta.env definitions from DefinePlugin and build JSON string
|
|
49
|
+
* @param {Compilation} compilation the compilation
|
|
50
|
+
* @returns {string} env object as JSON string
|
|
51
|
+
*/
|
|
52
|
+
const collectImportMetaEnvDefinitions = (compilation) => {
|
|
53
|
+
const definePluginHooks = DefinePlugin.getCompilationHooks(compilation);
|
|
54
|
+
const definitions = definePluginHooks.definitions.call({});
|
|
55
|
+
if (!definitions) {
|
|
56
|
+
return "{}";
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** @type {string[]} */
|
|
60
|
+
const pairs = [];
|
|
61
|
+
for (const key of Object.keys(definitions)) {
|
|
62
|
+
if (key.startsWith("import.meta.env.")) {
|
|
63
|
+
const envKey = key.slice("import.meta.env.".length);
|
|
64
|
+
const value = definitions[key];
|
|
65
|
+
pairs.push(`${JSON.stringify(envKey)}:${value}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return `{${pairs.join(",")}}`;
|
|
70
|
+
};
|
|
71
|
+
|
|
46
72
|
/**
|
|
47
73
|
* @typedef {object} ImportMetaPluginHooks
|
|
48
74
|
* @property {SyncBailHook<[DestructuringAssignmentProperty], string | void>} propertyInDestructuring
|
|
@@ -294,6 +320,37 @@ class ImportMetaPlugin {
|
|
|
294
320
|
.for("import.meta.main")
|
|
295
321
|
.tap(PLUGIN_NAME, evaluateToString("boolean"));
|
|
296
322
|
|
|
323
|
+
// import.meta.env
|
|
324
|
+
parser.hooks.typeof
|
|
325
|
+
.for("import.meta.env")
|
|
326
|
+
.tap(
|
|
327
|
+
PLUGIN_NAME,
|
|
328
|
+
toConstantDependency(parser, JSON.stringify("object"))
|
|
329
|
+
);
|
|
330
|
+
parser.hooks.expression
|
|
331
|
+
.for("import.meta.env")
|
|
332
|
+
.tap(PLUGIN_NAME, (expr) => {
|
|
333
|
+
const envCode = collectImportMetaEnvDefinitions(compilation);
|
|
334
|
+
const dep = new ConstDependency(
|
|
335
|
+
envCode,
|
|
336
|
+
/** @type {Range} */ (expr.range)
|
|
337
|
+
);
|
|
338
|
+
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
|
339
|
+
parser.state.module.addPresentationalDependency(dep);
|
|
340
|
+
return true;
|
|
341
|
+
});
|
|
342
|
+
parser.hooks.evaluateTypeof
|
|
343
|
+
.for("import.meta.env")
|
|
344
|
+
.tap(PLUGIN_NAME, evaluateToString("object"));
|
|
345
|
+
parser.hooks.evaluateIdentifier
|
|
346
|
+
.for("import.meta.env")
|
|
347
|
+
.tap(PLUGIN_NAME, (expr) =>
|
|
348
|
+
new BasicEvaluatedExpression()
|
|
349
|
+
.setTruthy()
|
|
350
|
+
.setSideEffects(false)
|
|
351
|
+
.setRange(/** @type {Range} */ (expr.range))
|
|
352
|
+
);
|
|
353
|
+
|
|
297
354
|
// Unknown properties
|
|
298
355
|
parser.hooks.unhandledExpressionMemberChain
|
|
299
356
|
.for("import.meta")
|
|
@@ -29,7 +29,7 @@ const ImportWeakDependency = require("./ImportWeakDependency");
|
|
|
29
29
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
|
30
30
|
/** @typedef {import("../javascript/JavascriptParser").ImportExpression} ImportExpression */
|
|
31
31
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
32
|
-
/** @typedef {import("../javascript/JavascriptParser").
|
|
32
|
+
/** @typedef {import("../javascript/JavascriptParser").JavascriptParserState} JavascriptParserState */
|
|
33
33
|
/** @typedef {import("../javascript/JavascriptParser").Members} Members */
|
|
34
34
|
/** @typedef {import("../javascript/JavascriptParser").MembersOptionals} MembersOptionals */
|
|
35
35
|
/** @typedef {import("../javascript/JavascriptParser").ArrowFunctionExpression} ArrowFunctionExpression */
|
|
@@ -41,7 +41,7 @@ const ImportWeakDependency = require("./ImportWeakDependency");
|
|
|
41
41
|
/** @typedef {{ references: RawReferencedExports, expression: ImportExpression }} ImportSettings */
|
|
42
42
|
/** @typedef {WeakMap<ImportExpression, RawReferencedExports>} State */
|
|
43
43
|
|
|
44
|
-
/** @type {WeakMap<
|
|
44
|
+
/** @type {WeakMap<JavascriptParserState, State>} */
|
|
45
45
|
const parserStateMap = new WeakMap();
|
|
46
46
|
const dynamicImportTag = Symbol("import()");
|
|
47
47
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const LocalModule = require("./LocalModule");
|
|
9
9
|
|
|
10
|
-
/** @typedef {import("../javascript/JavascriptParser").
|
|
10
|
+
/** @typedef {import("../javascript/JavascriptParser").JavascriptParserState} JavascriptParserState */
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @param {string} parent parent module
|
|
@@ -34,7 +34,7 @@ const lookup = (parent, mod) => {
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
/**
|
|
37
|
-
* @param {
|
|
37
|
+
* @param {JavascriptParserState} state parser state
|
|
38
38
|
* @param {string} name name
|
|
39
39
|
* @returns {LocalModule} local module
|
|
40
40
|
*/
|
|
@@ -48,7 +48,7 @@ module.exports.addLocalModule = (state, name) => {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
* @param {
|
|
51
|
+
* @param {JavascriptParserState} state parser state
|
|
52
52
|
* @param {string} name name
|
|
53
53
|
* @param {string=} namedModule named module
|
|
54
54
|
* @returns {LocalModule | null} local module or null
|
|
@@ -41,9 +41,9 @@ const WorkerDependency = require("./WorkerDependency");
|
|
|
41
41
|
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
|
42
42
|
/** @typedef {import("../Entrypoint").EntryOptions} EntryOptions */
|
|
43
43
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
44
|
-
/** @typedef {import("../Parser").ParserState} ParserState */
|
|
45
44
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
|
46
45
|
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
|
46
|
+
/** @typedef {import("../javascript/JavascriptParser").JavascriptParserState} JavascriptParserState */
|
|
47
47
|
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
|
48
48
|
/** @typedef {import("./HarmonyImportDependencyParserPlugin").HarmonySettings} HarmonySettings */
|
|
49
49
|
|
|
@@ -62,7 +62,7 @@ const DEFAULT_SYNTAX = [
|
|
|
62
62
|
"Worker from worker_threads"
|
|
63
63
|
];
|
|
64
64
|
|
|
65
|
-
/** @type {WeakMap<
|
|
65
|
+
/** @type {WeakMap<JavascriptParserState, number>} */
|
|
66
66
|
const workerIndexMap = new WeakMap();
|
|
67
67
|
|
|
68
68
|
const PLUGIN_NAME = "WorkerPlugin";
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* @param {Expression | SpreadElement} expr expressions
|
|
15
|
-
* @returns {{fn: FunctionExpression | ArrowFunctionExpression, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined } | undefined} function expression with additional information
|
|
15
|
+
* @returns {{ fn: FunctionExpression | ArrowFunctionExpression, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined } | undefined} function expression with additional information
|
|
16
16
|
*/
|
|
17
17
|
module.exports = (expr) => {
|
|
18
18
|
// <FunctionExpression>
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const { ConcatSource } = require("webpack-sources");
|
|
9
9
|
const { HotUpdateChunk, RuntimeGlobals } = require("..");
|
|
10
|
+
const { JAVASCRIPT_TYPE } = require("../ModuleSourceTypeConstants");
|
|
10
11
|
const Template = require("../Template");
|
|
11
12
|
const {
|
|
12
13
|
createChunkHashHandler,
|
|
@@ -110,10 +111,10 @@ class ModuleChunkFormatPlugin {
|
|
|
110
111
|
);
|
|
111
112
|
const hooks = getCompilationHooks(compilation);
|
|
112
113
|
/**
|
|
113
|
-
* @param {
|
|
114
|
+
* @param {Iterable<Chunk>} chunks the chunks to render
|
|
114
115
|
* @param {ChunkGraph} chunkGraph the chunk graph
|
|
115
116
|
* @param {Chunk=} runtimeChunk the runtime chunk
|
|
116
|
-
* @returns {Source|undefined} the source
|
|
117
|
+
* @returns {Source | undefined} the source
|
|
117
118
|
*/
|
|
118
119
|
const withDependentChunks = (chunks, chunkGraph, runtimeChunk) => {
|
|
119
120
|
if (/** @type {Set<Chunk>} */ (chunks).size > 0) {
|
|
@@ -153,7 +154,7 @@ class ModuleChunkFormatPlugin {
|
|
|
153
154
|
const entryDependentChunks =
|
|
154
155
|
chunkGraph.getChunkEntryDependentChunksIterable(chunk);
|
|
155
156
|
const sourceWithDependentChunks = withDependentChunks(
|
|
156
|
-
|
|
157
|
+
entryDependentChunks,
|
|
157
158
|
chunkGraph,
|
|
158
159
|
chunk
|
|
159
160
|
);
|
|
@@ -214,7 +215,7 @@ class ModuleChunkFormatPlugin {
|
|
|
214
215
|
const loadedChunks = new Set();
|
|
215
216
|
for (let i = 0; i < entries.length; i++) {
|
|
216
217
|
const [module, entrypoint] = entries[i];
|
|
217
|
-
if (!chunkGraph.getModuleSourceTypes(module).has(
|
|
218
|
+
if (!chunkGraph.getModuleSourceTypes(module).has(JAVASCRIPT_TYPE)) {
|
|
218
219
|
continue;
|
|
219
220
|
}
|
|
220
221
|
const final = i + 1 === entries.length;
|
|
@@ -10,7 +10,8 @@ const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
|
|
|
10
10
|
const Dependency = require("../Dependency");
|
|
11
11
|
const Module = require("../Module");
|
|
12
12
|
const ModuleFactory = require("../ModuleFactory");
|
|
13
|
-
const {
|
|
13
|
+
const { JAVASCRIPT_TYPES } = require("../ModuleSourceTypeConstants");
|
|
14
|
+
const { JAVASCRIPT_TYPE } = require("../ModuleSourceTypeConstants");
|
|
14
15
|
const {
|
|
15
16
|
WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY
|
|
16
17
|
} = require("../ModuleTypeConstants");
|
|
@@ -208,7 +209,7 @@ class LazyCompilationProxyModule extends Module {
|
|
|
208
209
|
* @returns {SourceTypes} types available (do not mutate)
|
|
209
210
|
*/
|
|
210
211
|
getSourceTypes() {
|
|
211
|
-
return
|
|
212
|
+
return JAVASCRIPT_TYPES;
|
|
212
213
|
}
|
|
213
214
|
|
|
214
215
|
/**
|
|
@@ -290,7 +291,7 @@ class LazyCompilationProxyModule extends Module {
|
|
|
290
291
|
keepActive
|
|
291
292
|
]);
|
|
292
293
|
}
|
|
293
|
-
sources.set(
|
|
294
|
+
sources.set(JAVASCRIPT_TYPE, new RawSource(source));
|
|
294
295
|
return {
|
|
295
296
|
sources,
|
|
296
297
|
runtimeRequirements
|
package/lib/ids/IdHelpers.js
CHANGED
|
@@ -222,17 +222,19 @@ const addToMapOfItems = (map, key, value) => {
|
|
|
222
222
|
array.push(value);
|
|
223
223
|
};
|
|
224
224
|
|
|
225
|
+
/** @typedef {Set<string>} UsedModuleIds */
|
|
226
|
+
|
|
225
227
|
/**
|
|
226
228
|
* @param {Compilation} compilation the compilation
|
|
227
229
|
* @param {((module: Module) => boolean)=} filter filter modules
|
|
228
|
-
* @returns {[
|
|
230
|
+
* @returns {[UsedModuleIds, Module[]]} used module ids as strings and modules without id matching the filter
|
|
229
231
|
*/
|
|
230
232
|
const getUsedModuleIdsAndModules = (compilation, filter) => {
|
|
231
233
|
const chunkGraph = compilation.chunkGraph;
|
|
232
234
|
|
|
233
235
|
const modules = [];
|
|
234
236
|
|
|
235
|
-
/** @type {
|
|
237
|
+
/** @type {UsedModuleIds} */
|
|
236
238
|
const usedIds = new Set();
|
|
237
239
|
if (compilation.usedModuleIds) {
|
|
238
240
|
for (const id of compilation.usedModuleIds) {
|
|
@@ -258,12 +260,14 @@ const getUsedModuleIdsAndModules = (compilation, filter) => {
|
|
|
258
260
|
return [usedIds, modules];
|
|
259
261
|
};
|
|
260
262
|
|
|
263
|
+
/** @typedef {Set<string>} UsedChunkIds */
|
|
264
|
+
|
|
261
265
|
/**
|
|
262
266
|
* @param {Compilation} compilation the compilation
|
|
263
|
-
* @returns {
|
|
267
|
+
* @returns {UsedChunkIds} used chunk ids as strings
|
|
264
268
|
*/
|
|
265
269
|
const getUsedChunkIds = (compilation) => {
|
|
266
|
-
/** @type {
|
|
270
|
+
/** @type {UsedChunkIds} */
|
|
267
271
|
const usedIds = new Set();
|
|
268
272
|
if (compilation.usedChunkIds) {
|
|
269
273
|
for (const id of compilation.usedChunkIds) {
|
|
@@ -299,7 +303,12 @@ const assignNames = (
|
|
|
299
303
|
usedIds,
|
|
300
304
|
assignName
|
|
301
305
|
) => {
|
|
302
|
-
/**
|
|
306
|
+
/**
|
|
307
|
+
* @template T
|
|
308
|
+
* @typedef {Map<string, T[]>} MapToItem
|
|
309
|
+
*/
|
|
310
|
+
|
|
311
|
+
/** @type {MapToItem<T>} */
|
|
303
312
|
const nameToItems = new Map();
|
|
304
313
|
|
|
305
314
|
for (const item of items) {
|
|
@@ -307,7 +316,7 @@ const assignNames = (
|
|
|
307
316
|
addToMapOfItems(nameToItems, name, item);
|
|
308
317
|
}
|
|
309
318
|
|
|
310
|
-
/** @type {
|
|
319
|
+
/** @type {MapToItem<T>} */
|
|
311
320
|
const nameToItems2 = new Map();
|
|
312
321
|
|
|
313
322
|
for (const [name, items] of nameToItems) {
|
|
@@ -402,7 +411,7 @@ const assignDeterministicIds = (
|
|
|
402
411
|
};
|
|
403
412
|
|
|
404
413
|
/**
|
|
405
|
-
* @param {
|
|
414
|
+
* @param {UsedModuleIds} usedIds used ids
|
|
406
415
|
* @param {Iterable<Module>} modules the modules
|
|
407
416
|
* @param {Compilation} compilation the compilation
|
|
408
417
|
* @returns {void}
|
|
@@ -19,7 +19,7 @@ const getAllChunks = (entrypoint, excludedChunk1, excludedChunk2) => {
|
|
|
19
19
|
/** @type {Set<Entrypoint>} */
|
|
20
20
|
const queue = new Set([entrypoint]);
|
|
21
21
|
/** @type {Set<Entrypoint>} */
|
|
22
|
-
const groups = new Set(
|
|
22
|
+
const groups = new Set();
|
|
23
23
|
for (const group of queue) {
|
|
24
24
|
if (group !== entrypoint) {
|
|
25
25
|
groups.add(group);
|
|
@@ -9,7 +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 {
|
|
12
|
+
const { JAVASCRIPT_TYPES } = require("../ModuleSourceTypeConstants");
|
|
13
13
|
const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency");
|
|
14
14
|
|
|
15
15
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
@@ -21,6 +21,7 @@ const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibi
|
|
|
21
21
|
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
|
22
22
|
/** @typedef {import("../Module")} Module */
|
|
23
23
|
/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
|
24
|
+
/** @typedef {import("../Module").SourceType} SourceType */
|
|
24
25
|
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
|
25
26
|
/** @typedef {import("../NormalModule")} NormalModule */
|
|
26
27
|
|
|
@@ -59,12 +60,12 @@ class JavascriptGenerator extends Generator {
|
|
|
59
60
|
* @returns {SourceTypes} available types (do not mutate)
|
|
60
61
|
*/
|
|
61
62
|
getTypes(module) {
|
|
62
|
-
return
|
|
63
|
+
return JAVASCRIPT_TYPES;
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
/**
|
|
66
67
|
* @param {NormalModule} module the module
|
|
67
|
-
* @param {
|
|
68
|
+
* @param {SourceType=} type source type
|
|
68
69
|
* @returns {number} estimate size of the module
|
|
69
70
|
*/
|
|
70
71
|
getSize(module, type) {
|