Skip to content

Commit 189a886

Browse files
committed
chore: Allow passing a typePrefix to ContextElementDependency
This is needed to tell different usages apart. The added information is used by the lazy compilation feature.
1 parent 487665c commit 189a886

File tree

5 files changed

+12
-2
lines changed

5 files changed

+12
-2
lines changed

lib/ContextModule.js

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const makeSerializable = require("./util/makeSerializable");
5454
* @property {RegExp=} include
5555
* @property {RegExp=} exclude
5656
* @property {RawChunkGroupOptions=} groupOptions
57+
* @property {string=} typePrefix
5758
* @property {string=} category
5859
* @property {string[][]=} referencedExports exports referenced from modules (won't be mangled)
5960
*/

lib/ContextModuleFactory.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
273273
include,
274274
exclude,
275275
referencedExports,
276-
category
276+
category,
277+
typePrefix
277278
} = options;
278279
if (!regExp || !resource) return callback(null, []);
279280

@@ -346,6 +347,7 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
346347
const dep = new ContextElementDependency(
347348
obj.request + resourceQuery + resourceFragment,
348349
obj.request,
350+
typePrefix,
349351
category,
350352
referencedExports
351353
);

lib/dependencies/ContextElementDependency.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ const ModuleDependency = require("./ModuleDependency");
1414
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
1515

1616
class ContextElementDependency extends ModuleDependency {
17-
constructor(request, userRequest, category, referencedExports) {
17+
constructor(request, userRequest, typePrefix, category, referencedExports) {
1818
super(request);
1919
this.referencedExports = referencedExports;
20+
this._typePrefix = typePrefix;
2021
this._category = category;
2122

2223
if (userRequest) {
@@ -25,6 +26,10 @@ class ContextElementDependency extends ModuleDependency {
2526
}
2627

2728
get type() {
29+
if (this._typePrefix) {
30+
return `${this._typePrefix} context element`;
31+
}
32+
2833
return "context element";
2934
}
3035

lib/dependencies/ImportParserPlugin.js

+1
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ class ImportParserPlugin {
248248
namespaceObject: parser.state.module.buildMeta.strictHarmonyModule
249249
? "strict"
250250
: true,
251+
typePrefix: "import()",
251252
category: "esm",
252253
referencedExports: exports
253254
},

lib/hmr/LazyCompilationPlugin.js

+1
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ class LazyCompilationPlugin {
351351
dep =>
352352
IGNORED_DEPENDENCY_TYPES.has(dep.type) ||
353353
(this.imports && dep.type === "import()") ||
354+
(this.imports && dep.type === "import() context element") ||
354355
(this.entries && dep.type === "entry")
355356
) &&
356357
!/webpack[/\\]hot[/\\]|webpack-dev-server[/\\]client/.test(

0 commit comments

Comments
 (0)