@depup/webpack 5.105.4-depup.37 → 5.106.0-depup.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/README.md +6 -3
- package/changes.json +50 -0
- package/lib/BannerPlugin.js +13 -13
- package/lib/Chunk.js +25 -0
- package/lib/ChunkGraph.js +8 -4
- package/lib/CleanPlugin.js +23 -20
- package/lib/CompatibilityPlugin.js +1 -1
- package/lib/Compilation.js +34 -11
- package/lib/Compiler.js +59 -1
- package/lib/CssModule.js +17 -2
- package/lib/Dependency.js +1 -1
- package/lib/DllPlugin.js +17 -17
- package/lib/DllReferencePlugin.js +20 -18
- package/lib/DotenvPlugin.js +29 -27
- package/lib/ExternalModule.js +39 -6
- package/lib/FileSystemInfo.js +3 -1
- package/lib/IgnorePlugin.js +12 -11
- package/lib/LoaderOptionsPlugin.js +17 -15
- package/lib/ManifestPlugin.js +27 -25
- package/lib/Module.js +69 -4
- package/lib/ModuleGraph.js +3 -0
- package/lib/ModuleParseError.js +1 -1
- package/lib/ModuleTypeConstants.js +1 -1
- package/lib/NormalModule.js +7 -3
- package/lib/NormalModuleFactory.js +20 -1
- package/lib/ProgressPlugin.js +39 -29
- package/lib/RuntimeGlobals.js +6 -0
- package/lib/RuntimeTemplate.js +1 -1
- package/lib/SourceMapDevToolPlugin.js +13 -11
- package/lib/TemplatedPathPlugin.js +4 -3
- package/lib/WatchIgnorePlugin.js +15 -13
- package/lib/WebpackOptionsApply.js +4 -4
- package/lib/asset/AssetModulesPlugin.js +50 -29
- package/lib/cli.js +3 -1
- package/lib/config/defaults.js +27 -13
- package/lib/config/normalization.js +3 -2
- package/lib/container/ContainerPlugin.js +46 -42
- package/lib/container/ContainerReferencePlugin.js +42 -26
- package/lib/container/FallbackModule.js +1 -1
- package/lib/container/ModuleFederationPlugin.js +17 -13
- package/lib/css/CssGenerator.js +306 -192
- package/lib/css/CssInjectStyleRuntimeModule.js +179 -0
- package/lib/css/CssLoadingRuntimeModule.js +1 -4
- package/lib/css/CssModulesPlugin.js +197 -98
- package/lib/css/CssParser.js +231 -134
- package/lib/css/walkCssTokens.js +115 -12
- package/lib/debug/ProfilingPlugin.js +16 -13
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +20 -15
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +4 -3
- package/lib/dependencies/CommonJsExportRequireDependency.js +4 -2
- package/lib/dependencies/CommonJsExportsDependency.js +1 -1
- package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -1
- package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
- package/lib/dependencies/CommonJsImportsParserPlugin.js +63 -2
- package/lib/dependencies/CommonJsRequireContextDependency.js +21 -0
- package/lib/dependencies/CommonJsRequireDependency.js +42 -1
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -1
- package/lib/dependencies/ContextElementDependency.js +1 -1
- package/lib/dependencies/CssIcssExportDependency.js +210 -87
- package/lib/dependencies/CssIcssImportDependency.js +13 -70
- package/lib/dependencies/CssIcssSymbolDependency.js +19 -30
- package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +13 -2
- package/lib/dependencies/HarmonyExportExpressionDependency.js +28 -2
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +13 -3
- package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
- package/lib/dependencies/HarmonyImportDependency.js +21 -8
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +4 -1
- package/lib/dependencies/HarmonyImportSideEffectDependency.js +2 -2
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +13 -2
- package/lib/dependencies/ImportContextDependency.js +1 -1
- package/lib/dependencies/ImportDependency.js +16 -2
- package/lib/dependencies/ImportMetaPlugin.js +39 -29
- package/lib/dependencies/ImportParserPlugin.js +4 -5
- package/lib/dependencies/ImportPhase.js +65 -22
- package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -1
- package/lib/esm/ModuleChunkFormatPlugin.js +1 -4
- package/lib/ids/HashedModuleIdsPlugin.js +21 -23
- package/lib/ids/OccurrenceChunkIdsPlugin.js +15 -11
- package/lib/ids/OccurrenceModuleIdsPlugin.js +15 -11
- package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -4
- package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -4
- package/lib/javascript/EnableChunkLoadingPlugin.js +1 -2
- package/lib/javascript/JavascriptModulesPlugin.js +38 -12
- package/lib/javascript/JavascriptParser.js +5 -3
- package/lib/json/JsonModulesPlugin.js +28 -21
- package/lib/library/AssignLibraryPlugin.js +1 -1
- package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
- package/lib/library/ModuleLibraryPlugin.js +35 -13
- package/lib/library/SystemLibraryPlugin.js +1 -1
- package/lib/node/ReadFileCompileAsyncWasmPlugin.js +22 -0
- package/lib/optimize/AggressiveSplittingPlugin.js +18 -31
- package/lib/optimize/ConcatenatedModule.js +4 -3
- package/lib/optimize/InnerGraphPlugin.js +11 -5
- package/lib/optimize/LimitChunkCountPlugin.js +22 -18
- package/lib/optimize/MergeDuplicateChunksPlugin.js +15 -12
- package/lib/optimize/MinChunkSizePlugin.js +20 -16
- package/lib/optimize/RemoveEmptyChunksPlugin.js +0 -1
- package/lib/rules/RuleSetCompiler.js +1 -0
- package/lib/schemes/HttpUriPlugin.js +20 -11
- package/lib/schemes/VirtualUrlPlugin.js +77 -30
- package/lib/serialization/FileMiddleware.js +7 -7
- package/lib/sharing/ConsumeSharedPlugin.js +32 -25
- package/lib/sharing/ProvideSharedPlugin.js +29 -25
- package/lib/util/{propertyName.js → property.js} +26 -1
- package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +148 -0
- package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +54 -0
- package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +105 -0
- package/lib/wasm-async/AsyncWebAssemblyParser.js +30 -6
- package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +26 -2
- package/lib/web/FetchCompileAsyncWasmPlugin.js +23 -0
- package/lib/web/JsonpTemplatePlugin.js +1 -0
- package/lib/webpack.js +34 -4
- package/package.json +45 -27
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +82 -22
- package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
- package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
- package/schemas/plugins/css/CssParserOptions.check.js +1 -1
- package/schemas/plugins/optimize/LimitChunkCountPlugin.json +1 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +1 -1
- package/schemas/plugins/schemes/VirtualUrlPlugin.json +8 -0
- package/types.d.ts +511 -114
- package/lib/util/create-schema-validation.js +0 -41
- package/lib/util/propertyAccess.js +0 -30
|
@@ -6,9 +6,7 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const WebpackError = require("../WebpackError");
|
|
9
|
-
const { cssExportConvention } = require("../util/conventions");
|
|
10
9
|
const makeSerializable = require("../util/makeSerializable");
|
|
11
|
-
const memoize = require("../util/memoize");
|
|
12
10
|
const CssImportDependency = require("./CssImportDependency");
|
|
13
11
|
|
|
14
12
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
@@ -26,10 +24,6 @@ const CssImportDependency = require("./CssImportDependency");
|
|
|
26
24
|
/** @typedef {import("./CssIcssExportDependency").ExportMode} ExportMode */
|
|
27
25
|
/** @typedef {import("./CssIcssExportDependency").ExportType} ExportType */
|
|
28
26
|
|
|
29
|
-
const getCssIcssExportDependency = memoize(() =>
|
|
30
|
-
require("./CssIcssExportDependency")
|
|
31
|
-
);
|
|
32
|
-
|
|
33
27
|
class CssIcssImportDependency extends CssImportDependency {
|
|
34
28
|
/**
|
|
35
29
|
* Example of dependency:
|
|
@@ -38,48 +32,19 @@ class CssIcssImportDependency extends CssImportDependency {
|
|
|
38
32
|
* @param {string} request request request path which needs resolving
|
|
39
33
|
* @param {Range} range the range of dependency
|
|
40
34
|
* @param {"local" | "global"} mode mode of the parsed CSS
|
|
41
|
-
* @param {string} name name
|
|
42
|
-
* @param {string
|
|
43
|
-
* @param {ExportMode=} exportMode export mode
|
|
44
|
-
* @param {ExportType=} exportType export type
|
|
35
|
+
* @param {string} importName import name (`name` from example)
|
|
36
|
+
* @param {string} localName local name (`value` from example)
|
|
45
37
|
*/
|
|
46
|
-
constructor(
|
|
47
|
-
request,
|
|
48
|
-
range,
|
|
49
|
-
mode,
|
|
50
|
-
name,
|
|
51
|
-
exportName = undefined,
|
|
52
|
-
exportMode = getCssIcssExportDependency().EXPORT_MODE.NONE,
|
|
53
|
-
exportType = getCssIcssExportDependency().EXPORT_TYPE.NORMAL
|
|
54
|
-
) {
|
|
38
|
+
constructor(request, range, mode, importName, localName) {
|
|
55
39
|
super(request, range, mode);
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
58
|
-
this.interpolate = true;
|
|
59
|
-
this.exportMode = exportMode;
|
|
60
|
-
this.exportType = exportType;
|
|
40
|
+
this.importName = importName;
|
|
41
|
+
this.localName = localName;
|
|
61
42
|
}
|
|
62
43
|
|
|
63
44
|
get type() {
|
|
64
45
|
return "css :import";
|
|
65
46
|
}
|
|
66
47
|
|
|
67
|
-
/**
|
|
68
|
-
* @returns {string | null} an identifier to merge equal requests
|
|
69
|
-
*/
|
|
70
|
-
getResourceIdentifier() {
|
|
71
|
-
return `${super.getResourceIdentifier()}|mode${this.mode}|name${this.name}`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @param {string} name export name
|
|
76
|
-
* @param {CssGeneratorExportsConvention} convention convention of the export name
|
|
77
|
-
* @returns {string[]} convention results
|
|
78
|
-
*/
|
|
79
|
-
getExportsConventionNames(name, convention) {
|
|
80
|
-
return cssExportConvention(name, convention);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
48
|
/**
|
|
84
49
|
* Returns list of exports referenced by this dependency
|
|
85
50
|
* @param {ModuleGraph} moduleGraph module graph
|
|
@@ -89,7 +54,7 @@ class CssIcssImportDependency extends CssImportDependency {
|
|
|
89
54
|
getReferencedExports(moduleGraph, runtime) {
|
|
90
55
|
return [
|
|
91
56
|
{
|
|
92
|
-
name: [this.
|
|
57
|
+
name: [this.importName],
|
|
93
58
|
canMangle: true
|
|
94
59
|
}
|
|
95
60
|
];
|
|
@@ -105,10 +70,10 @@ class CssIcssImportDependency extends CssImportDependency {
|
|
|
105
70
|
|
|
106
71
|
if (
|
|
107
72
|
module &&
|
|
108
|
-
!moduleGraph.getExportsInfo(module).isExportProvided(this.
|
|
73
|
+
!moduleGraph.getExportsInfo(module).isExportProvided(this.importName)
|
|
109
74
|
) {
|
|
110
75
|
const error = new WebpackError(
|
|
111
|
-
`Referenced name "${this.
|
|
76
|
+
`Referenced name "${this.importName}" in "${this.userRequest}" not found`
|
|
112
77
|
);
|
|
113
78
|
error.module = module;
|
|
114
79
|
|
|
@@ -123,11 +88,8 @@ class CssIcssImportDependency extends CssImportDependency {
|
|
|
123
88
|
*/
|
|
124
89
|
serialize(context) {
|
|
125
90
|
const { write } = context;
|
|
126
|
-
write(this.
|
|
127
|
-
write(this.
|
|
128
|
-
write(this.interpolate);
|
|
129
|
-
write(this.exportMode);
|
|
130
|
-
write(this.exportType);
|
|
91
|
+
write(this.importName);
|
|
92
|
+
write(this.localName);
|
|
131
93
|
super.serialize(context);
|
|
132
94
|
}
|
|
133
95
|
|
|
@@ -136,11 +98,8 @@ class CssIcssImportDependency extends CssImportDependency {
|
|
|
136
98
|
*/
|
|
137
99
|
deserialize(context) {
|
|
138
100
|
const { read } = context;
|
|
139
|
-
this.
|
|
140
|
-
this.
|
|
141
|
-
this.interpolate = read();
|
|
142
|
-
this.exportMode = read();
|
|
143
|
-
this.exportType = read();
|
|
101
|
+
this.importName = read();
|
|
102
|
+
this.localName = read();
|
|
144
103
|
super.deserialize(context);
|
|
145
104
|
}
|
|
146
105
|
}
|
|
@@ -155,23 +114,7 @@ CssIcssImportDependency.Template = class CssIcssImportDependencyTemplate extends
|
|
|
155
114
|
* @returns {void}
|
|
156
115
|
*/
|
|
157
116
|
apply(dependency, source, templateContext) {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
if (dep.value) {
|
|
161
|
-
const { moduleGraph } = templateContext;
|
|
162
|
-
const module =
|
|
163
|
-
/** @type {CssModule} */
|
|
164
|
-
(moduleGraph.getModule(dep));
|
|
165
|
-
const CssIcssExportDependency = getCssIcssExportDependency();
|
|
166
|
-
const template = new CssIcssExportDependency.Template();
|
|
167
|
-
const originalName = dep.name;
|
|
168
|
-
const originalExportName = dep.value;
|
|
169
|
-
dep.value = originalName;
|
|
170
|
-
dep.name = originalExportName;
|
|
171
|
-
template.apply(dep, source, { ...templateContext, module });
|
|
172
|
-
dep.name = originalName;
|
|
173
|
-
dep.value = originalExportName;
|
|
174
|
-
}
|
|
117
|
+
// Nothing
|
|
175
118
|
}
|
|
176
119
|
};
|
|
177
120
|
|
|
@@ -25,17 +25,17 @@ const NullDependency = require("./NullDependency");
|
|
|
25
25
|
|
|
26
26
|
class CssIcssSymbolDependency extends NullDependency {
|
|
27
27
|
/**
|
|
28
|
-
* @param {string}
|
|
29
|
-
* @param {string} symbol symbol
|
|
28
|
+
* @param {string} localName local name
|
|
30
29
|
* @param {Range} range range
|
|
31
|
-
* @param {
|
|
30
|
+
* @param {string=} value value when it was defined in this module
|
|
31
|
+
* @param {string=} importName import name when it was imported from other module
|
|
32
32
|
*/
|
|
33
|
-
constructor(
|
|
33
|
+
constructor(localName, range, value, importName) {
|
|
34
34
|
super();
|
|
35
|
-
this.
|
|
36
|
-
this.symbol = symbol;
|
|
35
|
+
this.localName = localName;
|
|
37
36
|
this.range = range;
|
|
38
|
-
this.
|
|
37
|
+
this.value = value;
|
|
38
|
+
this.importName = importName;
|
|
39
39
|
/** @type {undefined | string} */
|
|
40
40
|
this._hashUpdate = undefined;
|
|
41
41
|
}
|
|
@@ -52,31 +52,20 @@ class CssIcssSymbolDependency extends NullDependency {
|
|
|
52
52
|
*/
|
|
53
53
|
updateHash(hash, context) {
|
|
54
54
|
if (this._hashUpdate === undefined) {
|
|
55
|
-
this._hashUpdate = `${this.range}${this.
|
|
55
|
+
this._hashUpdate = `${this.range}${this.localName}${this.value || this.importName}`;
|
|
56
56
|
}
|
|
57
57
|
hash.update(this._hashUpdate);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
/**
|
|
61
|
-
* Returns list of exports referenced by this dependency
|
|
62
|
-
* @param {ModuleGraph} moduleGraph module graph
|
|
63
|
-
* @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
|
64
|
-
* @returns {ReferencedExports} referenced exports
|
|
65
|
-
*/
|
|
66
|
-
getReferencedExports(moduleGraph, runtime) {
|
|
67
|
-
return [[this.symbol]];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
60
|
/**
|
|
71
61
|
* @param {ObjectSerializerContext} context context
|
|
72
62
|
*/
|
|
73
63
|
serialize(context) {
|
|
74
64
|
const { write } = context;
|
|
75
|
-
write(this.
|
|
76
|
-
write(this.symbol);
|
|
77
|
-
write(this.value);
|
|
65
|
+
write(this.localName);
|
|
78
66
|
write(this.range);
|
|
79
|
-
write(this.
|
|
67
|
+
write(this.value);
|
|
68
|
+
write(this.importName);
|
|
80
69
|
super.serialize(context);
|
|
81
70
|
}
|
|
82
71
|
|
|
@@ -85,11 +74,10 @@ class CssIcssSymbolDependency extends NullDependency {
|
|
|
85
74
|
*/
|
|
86
75
|
deserialize(context) {
|
|
87
76
|
const { read } = context;
|
|
88
|
-
this.
|
|
89
|
-
this.symbol = read();
|
|
90
|
-
this.value = read();
|
|
77
|
+
this.localName = read();
|
|
91
78
|
this.range = read();
|
|
92
|
-
this.
|
|
79
|
+
this.value = read();
|
|
80
|
+
this.importName = read();
|
|
93
81
|
super.deserialize(context);
|
|
94
82
|
}
|
|
95
83
|
}
|
|
@@ -107,12 +95,13 @@ CssIcssSymbolDependency.Template = class CssIcssSymbolDependencyTemplate extends
|
|
|
107
95
|
if (templateContext.type === CSS_TYPE) {
|
|
108
96
|
const dep = /** @type {CssIcssSymbolDependency} */ (dependency);
|
|
109
97
|
/** @type {string | undefined} */
|
|
110
|
-
const value = dep.
|
|
111
|
-
? CssIcssExportDependency.Template.
|
|
112
|
-
dep.
|
|
98
|
+
const value = dep.importName
|
|
99
|
+
? CssIcssExportDependency.Template.resolve(
|
|
100
|
+
dep.localName,
|
|
101
|
+
dep.importName,
|
|
113
102
|
templateContext
|
|
114
103
|
)
|
|
115
|
-
: dep.
|
|
104
|
+
: dep.value;
|
|
116
105
|
|
|
117
106
|
if (!value) {
|
|
118
107
|
return;
|
|
@@ -21,6 +21,7 @@ const {
|
|
|
21
21
|
const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
|
|
22
22
|
const { ImportPhaseUtils, createGetImportPhase } = require("./ImportPhase");
|
|
23
23
|
|
|
24
|
+
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
|
24
25
|
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
|
25
26
|
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
|
26
27
|
/** @typedef {import("../javascript/JavascriptParser").ClassDeclaration} ClassDeclaration */
|
|
@@ -35,7 +36,7 @@ const PLUGIN_NAME = "HarmonyExportDependencyParserPlugin";
|
|
|
35
36
|
|
|
36
37
|
module.exports = class HarmonyExportDependencyParserPlugin {
|
|
37
38
|
/**
|
|
38
|
-
* @param {
|
|
39
|
+
* @param {JavascriptParserOptions} options options
|
|
39
40
|
*/
|
|
40
41
|
constructor(options) {
|
|
41
42
|
this.options = options;
|
|
@@ -51,7 +52,10 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
|
51
52
|
*/
|
|
52
53
|
apply(parser) {
|
|
53
54
|
const { exportPresenceMode } = this;
|
|
54
|
-
const getImportPhase = createGetImportPhase(
|
|
55
|
+
const getImportPhase = createGetImportPhase(
|
|
56
|
+
this.options.deferImport,
|
|
57
|
+
false
|
|
58
|
+
);
|
|
55
59
|
|
|
56
60
|
parser.hooks.export.tap(PLUGIN_NAME, (statement) => {
|
|
57
61
|
const dep = new HarmonyExportHeaderDependency(
|
|
@@ -137,6 +141,13 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|
|
137
141
|
}
|
|
138
142
|
: undefined
|
|
139
143
|
);
|
|
144
|
+
dep.isAnonymousDefault =
|
|
145
|
+
node.type === "ArrowFunctionExpression" ||
|
|
146
|
+
((node.type === "FunctionDeclaration" ||
|
|
147
|
+
node.type === "FunctionExpression" ||
|
|
148
|
+
node.type === "ClassDeclaration" ||
|
|
149
|
+
node.type === "ClassExpression") &&
|
|
150
|
+
!node.id);
|
|
140
151
|
dep.loc = Object.create(
|
|
141
152
|
/** @type {DependencyLocation} */ (statement.loc)
|
|
142
153
|
);
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
8
|
const ConcatenationScope = require("../ConcatenationScope");
|
|
9
|
+
const InitFragment = require("../InitFragment");
|
|
9
10
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
10
11
|
const makeSerializable = require("../util/makeSerializable");
|
|
11
|
-
const propertyAccess = require("../util/
|
|
12
|
+
const { propertyAccess } = require("../util/property");
|
|
12
13
|
const HarmonyExportInitFragment = require("./HarmonyExportInitFragment");
|
|
13
14
|
const NullDependency = require("./NullDependency");
|
|
14
15
|
|
|
@@ -36,6 +37,7 @@ class HarmonyExportExpressionDependency extends NullDependency {
|
|
|
36
37
|
this.rangeStatement = rangeStatement;
|
|
37
38
|
this.prefix = prefix;
|
|
38
39
|
this.declarationId = declarationId;
|
|
40
|
+
this.isAnonymousDefault = false;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
get type() {
|
|
@@ -74,6 +76,7 @@ class HarmonyExportExpressionDependency extends NullDependency {
|
|
|
74
76
|
write(this.rangeStatement);
|
|
75
77
|
write(this.prefix);
|
|
76
78
|
write(this.declarationId);
|
|
79
|
+
write(this.isAnonymousDefault);
|
|
77
80
|
super.serialize(context);
|
|
78
81
|
}
|
|
79
82
|
|
|
@@ -86,6 +89,7 @@ class HarmonyExportExpressionDependency extends NullDependency {
|
|
|
86
89
|
this.rangeStatement = read();
|
|
87
90
|
this.prefix = read();
|
|
88
91
|
this.declarationId = read();
|
|
92
|
+
this.isAnonymousDefault = read();
|
|
89
93
|
super.deserialize(context);
|
|
90
94
|
}
|
|
91
95
|
}
|
|
@@ -153,6 +157,18 @@ HarmonyExportExpressionDependency.Template = class HarmonyExportDependencyTempla
|
|
|
153
157
|
dep.range[0] - 1,
|
|
154
158
|
`/* harmony default export */ ${dep.prefix}`
|
|
155
159
|
);
|
|
160
|
+
|
|
161
|
+
if (typeof declarationId !== "string" && dep.isAnonymousDefault) {
|
|
162
|
+
// Fix .name for anonymous default export function declarations
|
|
163
|
+
// see test/test262-cases/test/language/module-code/instn-named-bndng-dflt-fun-anon.js cspell:disable-line
|
|
164
|
+
initFragments.push(
|
|
165
|
+
new InitFragment(
|
|
166
|
+
`Reflect.defineProperty(${name}, "name", { value: "default", configurable: true });\n`,
|
|
167
|
+
InitFragment.STAGE_HARMONY_EXPORTS,
|
|
168
|
+
2
|
|
169
|
+
)
|
|
170
|
+
);
|
|
171
|
+
}
|
|
156
172
|
} else {
|
|
157
173
|
/** @type {string} */
|
|
158
174
|
let content;
|
|
@@ -199,7 +215,17 @@ HarmonyExportExpressionDependency.Template = class HarmonyExportDependencyTempla
|
|
|
199
215
|
dep.range[0] - 1,
|
|
200
216
|
`${content}(${dep.prefix}`
|
|
201
217
|
);
|
|
202
|
-
|
|
218
|
+
if (dep.isAnonymousDefault) {
|
|
219
|
+
// Fix .name for anonymous default export expressions
|
|
220
|
+
// see test/test262-cases/test/language/module-code/eval-export-dflt-cls-anon.js cspell:disable-line
|
|
221
|
+
source.replace(
|
|
222
|
+
dep.range[1],
|
|
223
|
+
dep.rangeStatement[1] - 0.5,
|
|
224
|
+
`);\nReflect.getOwnPropertyDescriptor(${name}, "name").writable || Reflect.defineProperty(${name}, "name", { value: "default", configurable: true });`
|
|
225
|
+
);
|
|
226
|
+
} else {
|
|
227
|
+
source.replace(dep.range[1], dep.rangeStatement[1] - 0.5, ");");
|
|
228
|
+
}
|
|
203
229
|
return;
|
|
204
230
|
}
|
|
205
231
|
|
|
@@ -18,8 +18,7 @@ const {
|
|
|
18
18
|
const { countIterable } = require("../util/IterableHelpers");
|
|
19
19
|
const { combine, first } = require("../util/SetHelpers");
|
|
20
20
|
const makeSerializable = require("../util/makeSerializable");
|
|
21
|
-
const propertyAccess = require("../util/
|
|
22
|
-
const { propertyName } = require("../util/propertyName");
|
|
21
|
+
const { propertyAccess, propertyName } = require("../util/property");
|
|
23
22
|
const {
|
|
24
23
|
filterRuntime,
|
|
25
24
|
getRuntimeKey,
|
|
@@ -65,7 +64,9 @@ const processExportInfo = require("./processExportInfo");
|
|
|
65
64
|
|
|
66
65
|
const { ExportPresenceModes } = HarmonyImportDependency;
|
|
67
66
|
|
|
68
|
-
const idsSymbol =
|
|
67
|
+
const idsSymbol = /** @type {symbol} */ (
|
|
68
|
+
Symbol("HarmonyExportImportedSpecifierDependency.ids")
|
|
69
|
+
);
|
|
69
70
|
|
|
70
71
|
class NormalReexportItem {
|
|
71
72
|
/**
|
|
@@ -413,16 +414,25 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|
|
413
414
|
}
|
|
414
415
|
|
|
415
416
|
// TODO webpack 6 remove
|
|
417
|
+
/**
|
|
418
|
+
* @deprecated
|
|
419
|
+
*/
|
|
416
420
|
get id() {
|
|
417
421
|
throw new Error("id was renamed to ids and type changed to string[]");
|
|
418
422
|
}
|
|
419
423
|
|
|
420
424
|
// TODO webpack 6 remove
|
|
425
|
+
/**
|
|
426
|
+
* @deprecated
|
|
427
|
+
*/
|
|
421
428
|
getId() {
|
|
422
429
|
throw new Error("id was renamed to ids and type changed to string[]");
|
|
423
430
|
}
|
|
424
431
|
|
|
425
432
|
// TODO webpack 6 remove
|
|
433
|
+
/**
|
|
434
|
+
* @deprecated
|
|
435
|
+
*/
|
|
426
436
|
setId() {
|
|
427
437
|
throw new Error("id was renamed to ids and type changed to string[]");
|
|
428
438
|
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
const InitFragment = require("../InitFragment");
|
|
9
9
|
const RuntimeGlobals = require("../RuntimeGlobals");
|
|
10
10
|
const { first } = require("../util/SetHelpers");
|
|
11
|
-
const { propertyName } = require("../util/
|
|
11
|
+
const { propertyName } = require("../util/property");
|
|
12
12
|
|
|
13
13
|
/** @typedef {import("webpack-sources").Source} Source */
|
|
14
14
|
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
|
@@ -16,6 +16,7 @@ const { ImportPhase, ImportPhaseUtils } = require("./ImportPhase");
|
|
|
16
16
|
const ModuleDependency = require("./ModuleDependency");
|
|
17
17
|
|
|
18
18
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
19
|
+
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
|
19
20
|
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
|
20
21
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
21
22
|
/** @typedef {import("../ExportsInfo")} ExportsInfo */
|
|
@@ -57,7 +58,7 @@ const ExportPresenceModes = {
|
|
|
57
58
|
/**
|
|
58
59
|
* Resolve export presence mode from parser options with a specific key and shared fallbacks.
|
|
59
60
|
* @param {string | false | undefined} specificValue the type-specific option value (e.g. importExportsPresence or reexportExportsPresence)
|
|
60
|
-
* @param {
|
|
61
|
+
* @param {JavascriptParserOptions} options parser options
|
|
61
62
|
* @returns {ExportPresenceMode} resolved mode
|
|
62
63
|
*/
|
|
63
64
|
resolveFromOptions(specificValue, options) {
|
|
@@ -114,11 +115,12 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
|
114
115
|
*/
|
|
115
116
|
getResourceIdentifier() {
|
|
116
117
|
let str = super.getResourceIdentifier();
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
// We specifically use this check to avoid writing the default (`evaluation` or `0`) value and save memory
|
|
119
|
+
if (this.phase) {
|
|
120
|
+
str += `|phase${ImportPhaseUtils.stringify(this.phase)}`;
|
|
119
121
|
}
|
|
120
122
|
if (this.attributes) {
|
|
121
|
-
str += `|
|
|
123
|
+
str += `|attributes${JSON.stringify(this.attributes)}`;
|
|
122
124
|
}
|
|
123
125
|
return str;
|
|
124
126
|
}
|
|
@@ -156,9 +158,9 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
|
156
158
|
|
|
157
159
|
let importVar = importVarMap.get(importedModule);
|
|
158
160
|
if (importVar) return importVar;
|
|
159
|
-
importVar = `${Template.toIdentifier(
|
|
160
|
-
|
|
161
|
-
|
|
161
|
+
importVar = `${Template.toIdentifier(`${this.userRequest}`)}__WEBPACK_${
|
|
162
|
+
isDeferred ? "DEFERRED_" : ""
|
|
163
|
+
}IMPORTED_MODULE_${importVarMap.size}__`;
|
|
162
164
|
importVarMap.set(importedModule, importVar);
|
|
163
165
|
return importVar;
|
|
164
166
|
}
|
|
@@ -210,6 +212,11 @@ class HarmonyImportDependency extends ModuleDependency {
|
|
|
210
212
|
* @returns {WebpackError[] | undefined} errors
|
|
211
213
|
*/
|
|
212
214
|
getLinkingErrors(moduleGraph, ids, additionalMessage) {
|
|
215
|
+
// Source phase imports don't have exports to check
|
|
216
|
+
if (ImportPhaseUtils.isSource(this.phase)) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
213
220
|
const importedModule = moduleGraph.getModule(this);
|
|
214
221
|
// ignore errors for missing or failed modules
|
|
215
222
|
if (!importedModule || importedModule.getNumberOfErrors() > 0) {
|
|
@@ -374,7 +381,13 @@ HarmonyImportDependency.Template = class HarmonyImportDependencyTemplate extends
|
|
|
374
381
|
const moduleKey = referencedModule
|
|
375
382
|
? referencedModule.identifier()
|
|
376
383
|
: dep.request;
|
|
377
|
-
const key = `${
|
|
384
|
+
const key = `${
|
|
385
|
+
ImportPhaseUtils.isDefer(dep.phase)
|
|
386
|
+
? "deferred "
|
|
387
|
+
: ImportPhaseUtils.isSource(dep.phase)
|
|
388
|
+
? "source "
|
|
389
|
+
: ""
|
|
390
|
+
}harmony import ${moduleKey}`;
|
|
378
391
|
|
|
379
392
|
const runtimeCondition = dep.weak
|
|
380
393
|
? false
|
|
@@ -151,7 +151,10 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
|
|
151
151
|
* @returns {void}
|
|
152
152
|
*/
|
|
153
153
|
apply(parser) {
|
|
154
|
-
const getImportPhase = createGetImportPhase(
|
|
154
|
+
const getImportPhase = createGetImportPhase(
|
|
155
|
+
this.options.deferImport,
|
|
156
|
+
this.options.sourceImport
|
|
157
|
+
);
|
|
155
158
|
|
|
156
159
|
/**
|
|
157
160
|
* @param {MemberExpression} node member expression
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
"use strict";
|
|
7
7
|
|
|
8
|
+
const Module = require("../Module");
|
|
8
9
|
const { JAVASCRIPT_TYPE } = require("../ModuleSourceTypeConstants");
|
|
9
10
|
const makeSerializable = require("../util/makeSerializable");
|
|
10
11
|
const HarmonyImportDependency = require("./HarmonyImportDependency");
|
|
@@ -13,7 +14,6 @@ const HarmonyImportDependency = require("./HarmonyImportDependency");
|
|
|
13
14
|
/** @typedef {import("../Dependency")} Dependency */
|
|
14
15
|
/** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
|
|
15
16
|
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
|
16
|
-
/** @typedef {import("../Module")} Module */
|
|
17
17
|
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|
18
18
|
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
|
19
19
|
/** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */
|
|
@@ -76,7 +76,7 @@ HarmonyImportSideEffectDependency.Template = class HarmonyImportSideEffectDepend
|
|
|
76
76
|
|
|
77
77
|
const module = /** @type {Module} */ (moduleGraph.getModule(dependency));
|
|
78
78
|
|
|
79
|
-
if (module && !
|
|
79
|
+
if (module && !Module.getSourceBasicTypes(module).has(JAVASCRIPT_TYPE)) {
|
|
80
80
|
// no need to render import
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
@@ -13,7 +13,7 @@ const {
|
|
|
13
13
|
} = require("../optimize/InnerGraph");
|
|
14
14
|
const { getTrimmedIdsAndRange } = require("../util/chainedImports");
|
|
15
15
|
const makeSerializable = require("../util/makeSerializable");
|
|
16
|
-
const propertyAccess = require("../util/
|
|
16
|
+
const { propertyAccess } = require("../util/property");
|
|
17
17
|
const traverseDestructuringAssignmentProperties = require("../util/traverseDestructuringAssignmentProperties");
|
|
18
18
|
const HarmonyImportDependency = require("./HarmonyImportDependency");
|
|
19
19
|
const { ImportPhaseUtils } = require("./ImportPhase");
|
|
@@ -40,7 +40,9 @@ const { ImportPhaseUtils } = require("./ImportPhase");
|
|
|
40
40
|
/** @typedef {HarmonyImportDependency.Ids} Ids */
|
|
41
41
|
/** @typedef {import("./ImportPhase").ImportPhaseType} ImportPhaseType */
|
|
42
42
|
|
|
43
|
-
const idsSymbol =
|
|
43
|
+
const idsSymbol = /** @type {symbol} */ (
|
|
44
|
+
Symbol("HarmonyImportSpecifierDependency.ids")
|
|
45
|
+
);
|
|
44
46
|
|
|
45
47
|
const { ExportPresenceModes } = HarmonyImportDependency;
|
|
46
48
|
|
|
@@ -90,16 +92,25 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
// TODO webpack 6 remove
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated
|
|
97
|
+
*/
|
|
93
98
|
get id() {
|
|
94
99
|
throw new Error("id was renamed to ids and type changed to string[]");
|
|
95
100
|
}
|
|
96
101
|
|
|
97
102
|
// TODO webpack 6 remove
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated
|
|
105
|
+
*/
|
|
98
106
|
getId() {
|
|
99
107
|
throw new Error("id was renamed to ids and type changed to string[]");
|
|
100
108
|
}
|
|
101
109
|
|
|
102
110
|
// TODO webpack 6 remove
|
|
111
|
+
/**
|
|
112
|
+
* @deprecated
|
|
113
|
+
*/
|
|
103
114
|
setId() {
|
|
104
115
|
throw new Error("id was renamed to ids and type changed to string[]");
|
|
105
116
|
}
|
|
@@ -42,7 +42,7 @@ class ImportContextDependency extends ContextDependency {
|
|
|
42
42
|
let str = super.getResourceIdentifier();
|
|
43
43
|
|
|
44
44
|
if (this.options.attributes) {
|
|
45
|
-
str += `|
|
|
45
|
+
str += `|attributes${JSON.stringify(this.options.attributes)}`;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
return str;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const Dependency = require("../Dependency");
|
|
9
9
|
const makeSerializable = require("../util/makeSerializable");
|
|
10
|
+
const { ImportPhaseUtils } = require("./ImportPhase");
|
|
10
11
|
const ModuleDependency = require("./ModuleDependency");
|
|
11
12
|
|
|
12
13
|
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
|
@@ -53,8 +54,12 @@ class ImportDependency extends ModuleDependency {
|
|
|
53
54
|
*/
|
|
54
55
|
getResourceIdentifier() {
|
|
55
56
|
let str = super.getResourceIdentifier();
|
|
57
|
+
// We specifically use this check to avoid writing the default (`evaluation` or `0`) value and save memory
|
|
58
|
+
if (this.phase) {
|
|
59
|
+
str += `|phase${ImportPhaseUtils.stringify(this.phase)}`;
|
|
60
|
+
}
|
|
56
61
|
if (this.attributes) {
|
|
57
|
-
str += `|
|
|
62
|
+
str += `|attributes${JSON.stringify(this.attributes)}`;
|
|
58
63
|
}
|
|
59
64
|
return str;
|
|
60
65
|
}
|
|
@@ -140,7 +145,7 @@ ImportDependency.Template = class ImportDependencyTemplate extends (
|
|
|
140
145
|
const block = /** @type {AsyncDependenciesBlock} */ (
|
|
141
146
|
moduleGraph.getParentBlock(dep)
|
|
142
147
|
);
|
|
143
|
-
|
|
148
|
+
let content = runtimeTemplate.moduleNamespacePromise({
|
|
144
149
|
chunkGraph,
|
|
145
150
|
block,
|
|
146
151
|
module: /** @type {Module} */ (moduleGraph.getModule(dep)),
|
|
@@ -151,6 +156,15 @@ ImportDependency.Template = class ImportDependencyTemplate extends (
|
|
|
151
156
|
runtimeRequirements
|
|
152
157
|
});
|
|
153
158
|
|
|
159
|
+
// For source phase imports, unwrap the default export
|
|
160
|
+
// import.source() should return the source directly, not a namespace
|
|
161
|
+
if (ImportPhaseUtils.isSource(dep.phase)) {
|
|
162
|
+
content = `${content}.then(${runtimeTemplate.returningFunction(
|
|
163
|
+
'm["default"]',
|
|
164
|
+
"m"
|
|
165
|
+
)})`;
|
|
166
|
+
}
|
|
167
|
+
|
|
154
168
|
source.replace(dep.range[0], dep.range[1] - 1, content);
|
|
155
169
|
}
|
|
156
170
|
};
|