webpack 5.80.0 → 5.81.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.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/lib/AsyncDependenciesBlock.js +8 -0
- package/lib/CodeGenerationResults.js +2 -2
- package/lib/Compilation.js +2 -2
- package/lib/ContextModule.js +8 -0
- package/lib/CssModule.js +137 -0
- package/lib/DefinePlugin.js +81 -44
- package/lib/DelegatedModule.js +5 -0
- package/lib/DependenciesBlock.js +8 -0
- package/lib/Dependency.js +8 -0
- package/lib/DllModule.js +8 -0
- package/lib/ExportsInfo.js +3 -0
- package/lib/ExternalModule.js +8 -0
- package/lib/FileSystemInfo.js +8 -0
- package/lib/LoaderOptionsPlugin.js +12 -2
- package/lib/Module.js +8 -0
- package/lib/ModuleBuildError.js +9 -0
- package/lib/ModuleError.js +9 -0
- package/lib/ModuleFilenameHelpers.js +113 -4
- package/lib/ModuleParseError.js +9 -0
- package/lib/ModuleTypeConstants.js +21 -0
- package/lib/ModuleWarning.js +9 -0
- package/lib/NormalModule.js +8 -0
- package/lib/NormalModuleFactory.js +15 -3
- package/lib/RawModule.js +8 -0
- package/lib/WebpackError.js +8 -0
- package/lib/asset/RawDataUrlModule.js +8 -0
- package/lib/cache/ResolverCachePlugin.js +3 -0
- package/lib/config/normalization.js +1 -0
- package/lib/container/ContainerEntryModule.js +5 -0
- package/lib/container/ContainerExposedDependency.js +9 -0
- package/lib/container/FallbackDependency.js +6 -0
- package/lib/container/FallbackModule.js +5 -0
- package/lib/container/RemoteModule.js +5 -0
- package/lib/css/CssModulesPlugin.js +91 -50
- package/lib/css/CssParser.js +132 -73
- package/lib/css/walkCssTokens.js +27 -47
- package/lib/dependencies/AMDDefineDependency.js +8 -0
- package/lib/dependencies/AMDRequireArrayDependency.js +8 -0
- package/lib/dependencies/AMDRequireContextDependency.js +9 -0
- package/lib/dependencies/AMDRequireDependency.js +8 -0
- package/lib/dependencies/CachedConstDependency.js +8 -0
- package/lib/dependencies/CommonJsDependencyHelpers.js +9 -0
- package/lib/dependencies/CommonJsExportRequireDependency.js +8 -0
- package/lib/dependencies/CommonJsExportsDependency.js +8 -0
- package/lib/dependencies/CommonJsExportsParserPlugin.js +65 -3
- package/lib/dependencies/CommonJsFullRequireDependency.js +8 -0
- package/lib/dependencies/CommonJsRequireContextDependency.js +9 -0
- package/lib/dependencies/CommonJsSelfReferenceDependency.js +8 -0
- package/lib/dependencies/ConstDependency.js +8 -0
- package/lib/dependencies/ContextDependency.js +8 -0
- package/lib/dependencies/ContextElementDependency.js +8 -0
- package/lib/dependencies/CreateScriptUrlDependency.js +8 -0
- package/lib/dependencies/CssExportDependency.js +8 -0
- package/lib/dependencies/CssImportDependency.js +52 -1
- package/lib/dependencies/CssLocalIdentifierDependency.js +8 -0
- package/lib/dependencies/CssSelfLocalIdentifierDependency.js +8 -0
- package/lib/dependencies/CssUrlDependency.js +8 -0
- package/lib/dependencies/DllEntryDependency.js +9 -0
- package/lib/dependencies/ExportsInfoDependency.js +5 -0
- package/lib/dependencies/HarmonyAcceptDependency.js +8 -0
- package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +8 -0
- package/lib/dependencies/HarmonyExportExpressionDependency.js +8 -0
- package/lib/dependencies/HarmonyExportHeaderDependency.js +8 -0
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +14 -0
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +8 -0
- package/lib/dependencies/HarmonyImportDependency.js +8 -0
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +8 -0
- package/lib/dependencies/ImportContextDependency.js +9 -0
- package/lib/dependencies/ImportDependency.js +8 -0
- package/lib/dependencies/JsonExportsDependency.js +8 -0
- package/lib/dependencies/LocalModuleDependency.js +8 -0
- package/lib/dependencies/ModuleDecoratorDependency.js +8 -0
- package/lib/dependencies/ModuleDependency.js +8 -0
- package/lib/dependencies/ProvidedDependency.js +8 -0
- package/lib/dependencies/PureExpressionDependency.js +8 -0
- package/lib/dependencies/RequireEnsureDependency.js +8 -0
- package/lib/dependencies/RequireHeaderDependency.js +5 -0
- package/lib/dependencies/RequireResolveContextDependency.js +9 -0
- package/lib/dependencies/RequireResolveHeaderDependency.js +5 -0
- package/lib/dependencies/RuntimeRequirementsDependency.js +8 -0
- package/lib/dependencies/StaticExportsDependency.js +8 -0
- package/lib/dependencies/URLDependency.js +8 -0
- package/lib/dependencies/UnsupportedDependency.js +8 -0
- package/lib/dependencies/WebAssemblyExportImportedDependency.js +8 -0
- package/lib/dependencies/WebAssemblyImportDependency.js +8 -0
- package/lib/dependencies/WorkerDependency.js +8 -0
- package/lib/index.js +1 -0
- package/lib/javascript/JavascriptParser.js +1 -1
- package/lib/optimize/RealContentHashPlugin.js +6 -0
- package/lib/runtime/AutoPublicPathRuntimeModule.js +6 -1
- package/lib/serialization/ObjectMiddleware.js +2 -0
- package/lib/sharing/ConsumeSharedModule.js +8 -0
- package/lib/sharing/ConsumeSharedRuntimeModule.js +9 -3
- package/lib/sharing/ProvideSharedDependency.js +6 -0
- package/lib/sharing/ProvideSharedModule.js +5 -0
- package/lib/sharing/ShareRuntimeModule.js +7 -4
- package/lib/util/LazySet.js +10 -2
- package/lib/util/MapHelpers.js +19 -5
- package/lib/util/binarySearchBounds.js +49 -0
- package/lib/util/internalSerializables.js +1 -0
- package/lib/util/semver.js +1 -1
- package/package.json +4 -5
- package/schemas/WebpackOptions.check.js +1 -1
- package/schemas/WebpackOptions.json +8 -0
- package/types.d.ts +55 -22
@@ -15,6 +15,8 @@ const makeSerializable = require("./util/makeSerializable");
|
|
15
15
|
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
16
16
|
/** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
|
17
17
|
/** @typedef {import("./Module")} Module */
|
18
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
19
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
18
20
|
/** @typedef {import("./util/Hash")} Hash */
|
19
21
|
|
20
22
|
class AsyncDependenciesBlock extends DependenciesBlock {
|
@@ -71,6 +73,9 @@ class AsyncDependenciesBlock extends DependenciesBlock {
|
|
71
73
|
super.updateHash(hash, context);
|
72
74
|
}
|
73
75
|
|
76
|
+
/**
|
77
|
+
* @param {ObjectSerializerContext} context context
|
78
|
+
*/
|
74
79
|
serialize(context) {
|
75
80
|
const { write } = context;
|
76
81
|
write(this.groupOptions);
|
@@ -79,6 +84,9 @@ class AsyncDependenciesBlock extends DependenciesBlock {
|
|
79
84
|
super.serialize(context);
|
80
85
|
}
|
81
86
|
|
87
|
+
/**
|
88
|
+
* @param {ObjectDeserializerContext} context context
|
89
|
+
*/
|
82
90
|
deserialize(context) {
|
83
91
|
const { read } = context;
|
84
92
|
this.groupOptions = read();
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
-
const {
|
8
|
+
const { getOrInsert } = require("./util/MapHelpers");
|
9
9
|
const { first } = require("./util/SetHelpers");
|
10
10
|
const createHash = require("./util/createHash");
|
11
11
|
const { runtimeToString, RuntimeSpecMap } = require("./util/runtime");
|
@@ -147,7 +147,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|
147
147
|
* @returns {void}
|
148
148
|
*/
|
149
149
|
add(module, runtime, result) {
|
150
|
-
const map =
|
150
|
+
const map = getOrInsert(this.map, module, () => new RuntimeSpecMap());
|
151
151
|
map.set(runtime, result);
|
152
152
|
}
|
153
153
|
}
|
package/lib/Compilation.js
CHANGED
@@ -61,7 +61,7 @@ const StatsPrinter = require("./stats/StatsPrinter");
|
|
61
61
|
const { equals: arrayEquals } = require("./util/ArrayHelpers");
|
62
62
|
const AsyncQueue = require("./util/AsyncQueue");
|
63
63
|
const LazySet = require("./util/LazySet");
|
64
|
-
const {
|
64
|
+
const { getOrInsert } = require("./util/MapHelpers");
|
65
65
|
const WeakTupleMap = require("./util/WeakTupleMap");
|
66
66
|
const { cachedCleverMerge } = require("./util/cleverMerge");
|
67
67
|
const {
|
@@ -2618,7 +2618,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|
2618
2618
|
const logByLoadersSummary = (category, getDuration, getParallelism) => {
|
2619
2619
|
const map = new Map();
|
2620
2620
|
for (const [module, profile] of modulesWithProfiles) {
|
2621
|
-
const list =
|
2621
|
+
const list = getOrInsert(
|
2622
2622
|
map,
|
2623
2623
|
module.type + "!" + module.identifier().replace(/(!|^)[^!]*$/, ""),
|
2624
2624
|
() => []
|
package/lib/ContextModule.js
CHANGED
@@ -43,6 +43,8 @@ const makeSerializable = require("./util/makeSerializable");
|
|
43
43
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
44
44
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
45
45
|
/** @typedef {import("./dependencies/ContextElementDependency")} ContextElementDependency */
|
46
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
47
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
46
48
|
/** @template T @typedef {import("./util/LazySet")<T>} LazySet<T> */
|
47
49
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
48
50
|
|
@@ -1151,6 +1153,9 @@ module.exports = webpackEmptyAsyncContext;`;
|
|
1151
1153
|
return size;
|
1152
1154
|
}
|
1153
1155
|
|
1156
|
+
/**
|
1157
|
+
* @param {ObjectSerializerContext} context context
|
1158
|
+
*/
|
1154
1159
|
serialize(context) {
|
1155
1160
|
const { write } = context;
|
1156
1161
|
write(this._identifier);
|
@@ -1158,6 +1163,9 @@ module.exports = webpackEmptyAsyncContext;`;
|
|
1158
1163
|
super.serialize(context);
|
1159
1164
|
}
|
1160
1165
|
|
1166
|
+
/**
|
1167
|
+
* @param {ObjectDeserializerContext} context context
|
1168
|
+
*/
|
1161
1169
|
deserialize(context) {
|
1162
1170
|
const { read } = context;
|
1163
1171
|
this._identifier = read();
|
package/lib/CssModule.js
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Alexander Krasnoyarov @alexander-akait
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
const NormalModule = require("./NormalModule");
|
9
|
+
const makeSerializable = require("./util/makeSerializable");
|
10
|
+
|
11
|
+
/** @typedef {import("./Module")} Module */
|
12
|
+
/** @typedef {import("./NormalModule").NormalModuleCreateData} NormalModuleCreateData */
|
13
|
+
/** @typedef {import("./RequestShortener")} RequestShortener */
|
14
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
15
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
16
|
+
|
17
|
+
/** @typedef {NormalModuleCreateData & { cssLayer: string|undefined|null, supports: string|undefined|null, media: string|undefined|null }} CSSModuleCreateData */
|
18
|
+
|
19
|
+
class CssModule extends NormalModule {
|
20
|
+
/**
|
21
|
+
* @param {CSSModuleCreateData} options options object
|
22
|
+
*/
|
23
|
+
constructor(options) {
|
24
|
+
super(options);
|
25
|
+
|
26
|
+
// Avoid override `layer` for `Module` class, because it is a feature to run module in specific layer
|
27
|
+
this.cssLayer = options.cssLayer;
|
28
|
+
this.supports = options.supports;
|
29
|
+
this.media = options.media;
|
30
|
+
}
|
31
|
+
|
32
|
+
/**
|
33
|
+
* @returns {string} a unique identifier of the module
|
34
|
+
*/
|
35
|
+
identifier() {
|
36
|
+
let identifier = super.identifier();
|
37
|
+
|
38
|
+
if (this.cssLayer) {
|
39
|
+
identifier += `|${this.cssLayer}`;
|
40
|
+
}
|
41
|
+
|
42
|
+
if (this.supports) {
|
43
|
+
identifier += `|${this.supports}`;
|
44
|
+
}
|
45
|
+
|
46
|
+
if (this.media) {
|
47
|
+
identifier += `|${this.media}`;
|
48
|
+
}
|
49
|
+
|
50
|
+
return identifier;
|
51
|
+
}
|
52
|
+
|
53
|
+
/**
|
54
|
+
* @param {RequestShortener} requestShortener the request shortener
|
55
|
+
* @returns {string} a user readable identifier of the module
|
56
|
+
*/
|
57
|
+
readableIdentifier(requestShortener) {
|
58
|
+
const readableIdentifier = super.readableIdentifier(requestShortener);
|
59
|
+
|
60
|
+
return `css ${readableIdentifier}${
|
61
|
+
this.cssLayer ? ` (layer ${this.cssLayer || ""})` : ""
|
62
|
+
}${this.supports ? ` (supports ${this.supports || ""})` : ""}${
|
63
|
+
this.media ? ` (media ${this.media || ""})` : ""
|
64
|
+
}`;
|
65
|
+
}
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Assuming this module is in the cache. Update the (cached) module with
|
69
|
+
* the fresh module from the factory. Usually updates internal references
|
70
|
+
* and properties.
|
71
|
+
* @param {Module} module fresh module
|
72
|
+
* @returns {void}
|
73
|
+
*/
|
74
|
+
updateCacheModule(module) {
|
75
|
+
super.updateCacheModule(module);
|
76
|
+
const m = /** @type {CssModule} */ (module);
|
77
|
+
this.cssLayer = m.cssLayer;
|
78
|
+
this.supports = m.supports;
|
79
|
+
this.media = m.media;
|
80
|
+
}
|
81
|
+
|
82
|
+
/**
|
83
|
+
* @param {ObjectSerializerContext} context context
|
84
|
+
*/
|
85
|
+
serialize(context) {
|
86
|
+
const { write } = context;
|
87
|
+
write(this.cssLayer);
|
88
|
+
write(this.supports);
|
89
|
+
write(this.media);
|
90
|
+
super.serialize(context);
|
91
|
+
}
|
92
|
+
|
93
|
+
/**
|
94
|
+
* @param {ObjectDeserializerContext} context context
|
95
|
+
* @returns {CssModule} the deserialized object
|
96
|
+
*/
|
97
|
+
static deserialize(context) {
|
98
|
+
const obj = new CssModule({
|
99
|
+
// will be deserialized by Module
|
100
|
+
layer: null,
|
101
|
+
type: "",
|
102
|
+
// will be filled by updateCacheModule
|
103
|
+
resource: "",
|
104
|
+
context: "",
|
105
|
+
request: null,
|
106
|
+
userRequest: null,
|
107
|
+
rawRequest: null,
|
108
|
+
loaders: null,
|
109
|
+
matchResource: null,
|
110
|
+
parser: null,
|
111
|
+
parserOptions: null,
|
112
|
+
generator: null,
|
113
|
+
generatorOptions: null,
|
114
|
+
resolveOptions: null,
|
115
|
+
cssLayer: null,
|
116
|
+
supports: null,
|
117
|
+
media: null
|
118
|
+
});
|
119
|
+
obj.deserialize(context);
|
120
|
+
return obj;
|
121
|
+
}
|
122
|
+
|
123
|
+
/**
|
124
|
+
* @param {ObjectDeserializerContext} context context
|
125
|
+
*/
|
126
|
+
deserialize(context) {
|
127
|
+
const { read } = context;
|
128
|
+
this.cssLayer = read();
|
129
|
+
this.supports = read();
|
130
|
+
this.media = read();
|
131
|
+
super.deserialize(context);
|
132
|
+
}
|
133
|
+
}
|
134
|
+
|
135
|
+
makeSerializable(CssModule, "webpack/lib/CssModule");
|
136
|
+
|
137
|
+
module.exports = CssModule;
|
package/lib/DefinePlugin.js
CHANGED
@@ -26,6 +26,7 @@ const createHash = require("./util/createHash");
|
|
26
26
|
/** @typedef {import("./NormalModule")} NormalModule */
|
27
27
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
28
28
|
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
29
|
+
/** @typedef {import("./logging/Logger").Logger} Logger */
|
29
30
|
|
30
31
|
/** @typedef {null|undefined|RegExp|Function|string|number|boolean|bigint|undefined} CodeValuePrimitive */
|
31
32
|
/** @typedef {RecursiveArrayOrRecord<CodeValuePrimitive|RuntimeValue>} CodeValue */
|
@@ -117,6 +118,7 @@ class RuntimeValue {
|
|
117
118
|
* @param {Map<string, string | Set<string>>} valueCacheVersions valueCacheVersions
|
118
119
|
* @param {string} key the defined key
|
119
120
|
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
121
|
+
* @param {Logger} logger the logger object
|
120
122
|
* @param {boolean|undefined|null=} asiSafe asi safe (undefined: unknown, null: unneeded)
|
121
123
|
* @param {Set<string>|undefined=} objKeys used keys
|
122
124
|
* @returns {string} code converted to string that evaluates
|
@@ -127,6 +129,7 @@ const stringifyObj = (
|
|
127
129
|
valueCacheVersions,
|
128
130
|
key,
|
129
131
|
runtimeTemplate,
|
132
|
+
logger,
|
130
133
|
asiSafe,
|
131
134
|
objKeys
|
132
135
|
) => {
|
@@ -135,7 +138,15 @@ const stringifyObj = (
|
|
135
138
|
if (arr) {
|
136
139
|
code = `[${obj
|
137
140
|
.map(code =>
|
138
|
-
toCode(
|
141
|
+
toCode(
|
142
|
+
code,
|
143
|
+
parser,
|
144
|
+
valueCacheVersions,
|
145
|
+
key,
|
146
|
+
runtimeTemplate,
|
147
|
+
logger,
|
148
|
+
null
|
149
|
+
)
|
139
150
|
)
|
140
151
|
.join(",")}]`;
|
141
152
|
} else {
|
@@ -150,7 +161,15 @@ const stringifyObj = (
|
|
150
161
|
return (
|
151
162
|
JSON.stringify(key) +
|
152
163
|
":" +
|
153
|
-
toCode(
|
164
|
+
toCode(
|
165
|
+
code,
|
166
|
+
parser,
|
167
|
+
valueCacheVersions,
|
168
|
+
key,
|
169
|
+
runtimeTemplate,
|
170
|
+
logger,
|
171
|
+
null
|
172
|
+
)
|
154
173
|
);
|
155
174
|
})
|
156
175
|
.join(",")}}`;
|
@@ -175,6 +194,7 @@ const stringifyObj = (
|
|
175
194
|
* @param {Map<string, string | Set<string>>} valueCacheVersions valueCacheVersions
|
176
195
|
* @param {string} key the defined key
|
177
196
|
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
197
|
+
* @param {Logger} logger the logger object
|
178
198
|
* @param {boolean|undefined|null=} asiSafe asi safe (undefined: unknown, null: unneeded)
|
179
199
|
* @param {Set<string>|undefined=} objKeys used keys
|
180
200
|
* @returns {string} code converted to string that evaluates
|
@@ -185,51 +205,62 @@ const toCode = (
|
|
185
205
|
valueCacheVersions,
|
186
206
|
key,
|
187
207
|
runtimeTemplate,
|
208
|
+
logger,
|
188
209
|
asiSafe,
|
189
210
|
objKeys
|
190
211
|
) => {
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
212
|
+
const transformToCode = () => {
|
213
|
+
if (code === null) {
|
214
|
+
return "null";
|
215
|
+
}
|
216
|
+
if (code === undefined) {
|
217
|
+
return "undefined";
|
218
|
+
}
|
219
|
+
if (Object.is(code, -0)) {
|
220
|
+
return "-0";
|
221
|
+
}
|
222
|
+
if (code instanceof RuntimeValue) {
|
223
|
+
return toCode(
|
224
|
+
code.exec(parser, valueCacheVersions, key),
|
225
|
+
parser,
|
226
|
+
valueCacheVersions,
|
227
|
+
key,
|
228
|
+
runtimeTemplate,
|
229
|
+
logger,
|
230
|
+
asiSafe
|
231
|
+
);
|
232
|
+
}
|
233
|
+
if (code instanceof RegExp && code.toString) {
|
234
|
+
return code.toString();
|
235
|
+
}
|
236
|
+
if (typeof code === "function" && code.toString) {
|
237
|
+
return "(" + code.toString() + ")";
|
238
|
+
}
|
239
|
+
if (typeof code === "object") {
|
240
|
+
return stringifyObj(
|
241
|
+
code,
|
242
|
+
parser,
|
243
|
+
valueCacheVersions,
|
244
|
+
key,
|
245
|
+
runtimeTemplate,
|
246
|
+
logger,
|
247
|
+
asiSafe,
|
248
|
+
objKeys
|
249
|
+
);
|
250
|
+
}
|
251
|
+
if (typeof code === "bigint") {
|
252
|
+
return runtimeTemplate.supportsBigIntLiteral()
|
253
|
+
? `${code}n`
|
254
|
+
: `BigInt("${code}")`;
|
255
|
+
}
|
256
|
+
return code + "";
|
257
|
+
};
|
258
|
+
|
259
|
+
const strCode = transformToCode();
|
260
|
+
|
261
|
+
logger.log(`Replaced "${key}" with "${strCode}"`);
|
262
|
+
|
263
|
+
return strCode;
|
233
264
|
};
|
234
265
|
|
235
266
|
const toCacheVersion = code => {
|
@@ -300,6 +331,7 @@ class DefinePlugin {
|
|
300
331
|
compiler.hooks.compilation.tap(
|
301
332
|
PLUGIN_NAME,
|
302
333
|
(compilation, { normalModuleFactory }) => {
|
334
|
+
const logger = compilation.getLogger("webpack.DefinePlugin");
|
303
335
|
compilation.dependencyTemplates.set(
|
304
336
|
ConstDependency,
|
305
337
|
new ConstDependency.Template()
|
@@ -421,6 +453,7 @@ class DefinePlugin {
|
|
421
453
|
compilation.valueCacheVersions,
|
422
454
|
key,
|
423
455
|
runtimeTemplate,
|
456
|
+
logger,
|
424
457
|
null
|
425
458
|
)
|
426
459
|
);
|
@@ -436,6 +469,7 @@ class DefinePlugin {
|
|
436
469
|
compilation.valueCacheVersions,
|
437
470
|
originalKey,
|
438
471
|
runtimeTemplate,
|
472
|
+
logger,
|
439
473
|
!parser.isAsiPosition(expr.range[0]),
|
440
474
|
parser.destructuringAssignmentPropertiesFor(expr)
|
441
475
|
);
|
@@ -470,6 +504,7 @@ class DefinePlugin {
|
|
470
504
|
compilation.valueCacheVersions,
|
471
505
|
originalKey,
|
472
506
|
runtimeTemplate,
|
507
|
+
logger,
|
473
508
|
null
|
474
509
|
);
|
475
510
|
const typeofCode = isTypeof
|
@@ -488,6 +523,7 @@ class DefinePlugin {
|
|
488
523
|
compilation.valueCacheVersions,
|
489
524
|
originalKey,
|
490
525
|
runtimeTemplate,
|
526
|
+
logger,
|
491
527
|
null
|
492
528
|
);
|
493
529
|
const typeofCode = isTypeof
|
@@ -534,6 +570,7 @@ class DefinePlugin {
|
|
534
570
|
compilation.valueCacheVersions,
|
535
571
|
key,
|
536
572
|
runtimeTemplate,
|
573
|
+
logger,
|
537
574
|
!parser.isAsiPosition(expr.range[0]),
|
538
575
|
parser.destructuringAssignmentPropertiesFor(expr)
|
539
576
|
);
|
package/lib/DelegatedModule.js
CHANGED
@@ -30,6 +30,8 @@ const makeSerializable = require("./util/makeSerializable");
|
|
30
30
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
31
31
|
/** @typedef {import("./WebpackError")} WebpackError */
|
32
32
|
/** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
|
33
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
34
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
33
35
|
/** @typedef {import("./util/Hash")} Hash */
|
34
36
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
35
37
|
|
@@ -186,6 +188,9 @@ class DelegatedModule extends Module {
|
|
186
188
|
super.updateHash(hash, context);
|
187
189
|
}
|
188
190
|
|
191
|
+
/**
|
192
|
+
* @param {ObjectSerializerContext} context context
|
193
|
+
*/
|
189
194
|
serialize(context) {
|
190
195
|
const { write } = context;
|
191
196
|
// constructor
|
package/lib/DependenciesBlock.js
CHANGED
@@ -12,6 +12,8 @@ const makeSerializable = require("./util/makeSerializable");
|
|
12
12
|
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
13
13
|
/** @typedef {import("./Dependency")} Dependency */
|
14
14
|
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
15
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
16
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
15
17
|
/** @typedef {import("./util/Hash")} Hash */
|
16
18
|
|
17
19
|
/** @typedef {(d: Dependency) => boolean} DependencyFilterFunction */
|
@@ -88,11 +90,17 @@ class DependenciesBlock {
|
|
88
90
|
}
|
89
91
|
}
|
90
92
|
|
93
|
+
/**
|
94
|
+
* @param {ObjectSerializerContext} context context
|
95
|
+
*/
|
91
96
|
serialize({ write }) {
|
92
97
|
write(this.dependencies);
|
93
98
|
write(this.blocks);
|
94
99
|
}
|
95
100
|
|
101
|
+
/**
|
102
|
+
* @param {ObjectDeserializerContext} context context
|
103
|
+
*/
|
96
104
|
deserialize({ read }) {
|
97
105
|
this.dependencies = read();
|
98
106
|
this.blocks = read();
|
package/lib/Dependency.js
CHANGED
@@ -17,6 +17,8 @@ const memoize = require("./util/memoize");
|
|
17
17
|
/** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
|
18
18
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
19
19
|
/** @typedef {import("./WebpackError")} WebpackError */
|
20
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
21
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
20
22
|
/** @typedef {import("./util/Hash")} Hash */
|
21
23
|
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
22
24
|
|
@@ -292,6 +294,9 @@ class Dependency {
|
|
292
294
|
return getIgnoredModule();
|
293
295
|
}
|
294
296
|
|
297
|
+
/**
|
298
|
+
* @param {ObjectSerializerContext} context context
|
299
|
+
*/
|
295
300
|
serialize({ write }) {
|
296
301
|
write(this.weak);
|
297
302
|
write(this.optional);
|
@@ -303,6 +308,9 @@ class Dependency {
|
|
303
308
|
write(this._locN);
|
304
309
|
}
|
305
310
|
|
311
|
+
/**
|
312
|
+
* @param {ObjectDeserializerContext} context context
|
313
|
+
*/
|
306
314
|
deserialize({ read }) {
|
307
315
|
this.weak = read();
|
308
316
|
this.optional = read();
|
package/lib/DllModule.js
CHANGED
@@ -25,6 +25,8 @@ const makeSerializable = require("./util/makeSerializable");
|
|
25
25
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
26
26
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
27
27
|
/** @typedef {import("./WebpackError")} WebpackError */
|
28
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
29
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
28
30
|
/** @typedef {import("./util/Hash")} Hash */
|
29
31
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
30
32
|
|
@@ -122,11 +124,17 @@ class DllModule extends Module {
|
|
122
124
|
super.updateHash(hash, context);
|
123
125
|
}
|
124
126
|
|
127
|
+
/**
|
128
|
+
* @param {ObjectSerializerContext} context context
|
129
|
+
*/
|
125
130
|
serialize(context) {
|
126
131
|
context.write(this.name);
|
127
132
|
super.serialize(context);
|
128
133
|
}
|
129
134
|
|
135
|
+
/**
|
136
|
+
* @param {ObjectDeserializerContext} context context
|
137
|
+
*/
|
130
138
|
deserialize(context) {
|
131
139
|
this.name = context.read();
|
132
140
|
super.deserialize(context);
|
package/lib/ExportsInfo.js
CHANGED
package/lib/ExternalModule.js
CHANGED
@@ -39,6 +39,8 @@ const { register } = require("./util/serialization");
|
|
39
39
|
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
40
40
|
/** @typedef {import("./WebpackError")} WebpackError */
|
41
41
|
/** @typedef {import("./javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
|
42
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
43
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
42
44
|
/** @typedef {import("./util/Hash")} Hash */
|
43
45
|
/** @typedef {typeof import("./util/Hash")} HashConstructor */
|
44
46
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
@@ -733,6 +735,9 @@ class ExternalModule extends Module {
|
|
733
735
|
super.updateHash(hash, context);
|
734
736
|
}
|
735
737
|
|
738
|
+
/**
|
739
|
+
* @param {ObjectSerializerContext} context context
|
740
|
+
*/
|
736
741
|
serialize(context) {
|
737
742
|
const { write } = context;
|
738
743
|
|
@@ -743,6 +748,9 @@ class ExternalModule extends Module {
|
|
743
748
|
super.serialize(context);
|
744
749
|
}
|
745
750
|
|
751
|
+
/**
|
752
|
+
* @param {ObjectDeserializerContext} context context
|
753
|
+
*/
|
746
754
|
deserialize(context) {
|
747
755
|
const { read } = context;
|
748
756
|
|
package/lib/FileSystemInfo.js
CHANGED
@@ -18,6 +18,8 @@ const processAsyncTree = require("./util/processAsyncTree");
|
|
18
18
|
|
19
19
|
/** @typedef {import("./WebpackError")} WebpackError */
|
20
20
|
/** @typedef {import("./logging/Logger").Logger} Logger */
|
21
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
22
|
+
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
21
23
|
/** @typedef {typeof import("./util/Hash")} Hash */
|
22
24
|
/** @typedef {import("./util/fs").IStats} IStats */
|
23
25
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
@@ -378,6 +380,9 @@ class Snapshot {
|
|
378
380
|
this.children.add(child);
|
379
381
|
}
|
380
382
|
|
383
|
+
/**
|
384
|
+
* @param {ObjectSerializerContext} context context
|
385
|
+
*/
|
381
386
|
serialize({ write }) {
|
382
387
|
write(this._flags);
|
383
388
|
if (this.hasStartTime()) write(this.startTime);
|
@@ -395,6 +400,9 @@ class Snapshot {
|
|
395
400
|
if (this.hasChildren()) write(this.children);
|
396
401
|
}
|
397
402
|
|
403
|
+
/**
|
404
|
+
* @param {ObjectDeserializerContext} context context
|
405
|
+
*/
|
398
406
|
deserialize({ read }) {
|
399
407
|
this._flags = read();
|
400
408
|
if (this.hasStartTime()) this.startTime = read();
|
@@ -11,6 +11,7 @@ const createSchemaValidation = require("./util/create-schema-validation");
|
|
11
11
|
|
12
12
|
/** @typedef {import("../declarations/plugins/LoaderOptionsPlugin").LoaderOptionsPluginOptions} LoaderOptionsPluginOptions */
|
13
13
|
/** @typedef {import("./Compiler")} Compiler */
|
14
|
+
/** @typedef {import("./ModuleFilenameHelpers").MatchObject} MatchObject */
|
14
15
|
|
15
16
|
const validate = createSchemaValidation(
|
16
17
|
require("../schemas/plugins/LoaderOptionsPlugin.check.js"),
|
@@ -20,17 +21,26 @@ const validate = createSchemaValidation(
|
|
20
21
|
baseDataPath: "options"
|
21
22
|
}
|
22
23
|
);
|
24
|
+
|
23
25
|
class LoaderOptionsPlugin {
|
24
26
|
/**
|
25
|
-
* @param {LoaderOptionsPluginOptions} options options object
|
27
|
+
* @param {LoaderOptionsPluginOptions & MatchObject} options options object
|
26
28
|
*/
|
27
29
|
constructor(options = {}) {
|
28
30
|
validate(options);
|
31
|
+
// If no options are set then generate empty options object
|
29
32
|
if (typeof options !== "object") options = {};
|
30
33
|
if (!options.test) {
|
31
|
-
|
34
|
+
// This is mocking a RegExp object which always returns true
|
35
|
+
// TODO: Figure out how to do `as unknown as RegExp` for this line
|
36
|
+
// in JSDoc equivalent
|
37
|
+
/** @type {any} */
|
38
|
+
const defaultTrueMockRegExp = {
|
32
39
|
test: () => true
|
33
40
|
};
|
41
|
+
|
42
|
+
/** @type {RegExp} */
|
43
|
+
options.test = defaultTrueMockRegExp;
|
34
44
|
}
|
35
45
|
this.options = options;
|
36
46
|
}
|