move Module.issuer into Module.getIssuer(moduleGraph)
This commit is contained in:
parent
e7757a53c4
commit
d35e42a14d
|
@ -807,7 +807,7 @@ class Compilation {
|
|||
dependentModule.profile = currentProfile;
|
||||
}
|
||||
|
||||
dependentModule.issuer = module;
|
||||
dependentModule.setIssuer(this.moduleGraph, module);
|
||||
} else {
|
||||
if (this.profile) {
|
||||
if (module.profile) {
|
||||
|
|
|
@ -45,6 +45,7 @@ const SortableSet = require("./util/SortableSet");
|
|||
const EMPTY_RESOLVE_OPTIONS = {};
|
||||
const optimizationBailoutSymbol = Symbol("optimization bailout");
|
||||
const usedExportsSymbol = Symbol("used exports");
|
||||
const issuerSymbol = Symbol("issuer");
|
||||
|
||||
let debugId = 1000;
|
||||
|
||||
|
@ -120,8 +121,6 @@ class Module extends DependenciesBlock {
|
|||
this.index2 = null;
|
||||
/** @type {number} */
|
||||
this.depth = null;
|
||||
/** @type {Module} */
|
||||
this.issuer = null;
|
||||
/** @type {undefined | object} */
|
||||
this.profile = undefined;
|
||||
/** @type {boolean} */
|
||||
|
@ -149,6 +148,25 @@ class Module extends DependenciesBlock {
|
|||
return (this.buildInfo && this.buildInfo.moduleArgument) || "module";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ModuleGraph} moduleGraph the module graph
|
||||
* @returns {Module | null} the issuer module
|
||||
*/
|
||||
getIssuer(moduleGraph) {
|
||||
const meta = moduleGraph.getMeta(this);
|
||||
return meta[issuerSymbol];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ModuleGraph} moduleGraph the module graph
|
||||
* @param {Module | null} issuer the issuer module
|
||||
* @returns {void}
|
||||
*/
|
||||
setIssuer(moduleGraph, issuer) {
|
||||
const meta = moduleGraph.getMeta(this);
|
||||
meta[issuerSymbol] = issuer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ModuleGraph} moduleGraph the module graph
|
||||
* @returns {(string | OptimizationBailoutFunction)[]} optimization bailouts
|
||||
|
@ -199,7 +217,6 @@ class Module extends DependenciesBlock {
|
|||
this.index = null;
|
||||
this.index2 = null;
|
||||
this.depth = null;
|
||||
this.issuer = null;
|
||||
this.profile = undefined;
|
||||
this.prefetched = false;
|
||||
this.built = false;
|
||||
|
|
|
@ -27,7 +27,6 @@ class ModuleDependencyError extends WebpackError {
|
|||
this.module = module;
|
||||
this.loc = loc;
|
||||
this.error = err;
|
||||
this.origin = module.issuer;
|
||||
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ module.exports = class ModuleDependencyWarning extends WebpackError {
|
|||
this.module = module;
|
||||
this.loc = loc;
|
||||
this.error = err;
|
||||
this.origin = module.issuer;
|
||||
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
|
|
28
lib/Stats.js
28
lib/Stats.js
|
@ -317,9 +317,10 @@ class Stats {
|
|||
if (showErrorDetails && e.missing) {
|
||||
text += e.missing.map(item => `\n[${item}]`).join("");
|
||||
}
|
||||
if (showModuleTrace && e.origin) {
|
||||
const origin = e.origin || (e.module && e.module.getIssuer(moduleGraph));
|
||||
if (showModuleTrace && origin) {
|
||||
text += `\n @ ${this.formatFilePath(
|
||||
e.origin.readableIdentifier(requestShortener)
|
||||
origin.readableIdentifier(requestShortener)
|
||||
)}`;
|
||||
if (typeof e.originLoc === "object") {
|
||||
const locInfo = formatLocation(e.originLoc);
|
||||
|
@ -334,10 +335,10 @@ class Stats {
|
|||
text += ` ${locInfo}`;
|
||||
}
|
||||
}
|
||||
let current = e.origin;
|
||||
while (current.issuer) {
|
||||
current = current.issuer;
|
||||
let current = origin.getIssuer(moduleGraph);
|
||||
while (current) {
|
||||
text += `\n @ ${current.readableIdentifier(requestShortener)}`;
|
||||
current = current.getIssuer(moduleGraph);
|
||||
}
|
||||
}
|
||||
return text;
|
||||
|
@ -493,9 +494,11 @@ class Stats {
|
|||
|
||||
const fnModule = module => {
|
||||
const path = [];
|
||||
let current = module;
|
||||
while (current.issuer) {
|
||||
path.push((current = current.issuer));
|
||||
const issuer = module.getIssuer(moduleGraph);
|
||||
let current = issuer;
|
||||
while (current) {
|
||||
path.push(current);
|
||||
current = current.getIssuer(moduleGraph);
|
||||
}
|
||||
path.reverse();
|
||||
const obj = {
|
||||
|
@ -510,12 +513,11 @@ class Stats {
|
|||
optional: module.isOptional(moduleGraph),
|
||||
prefetched: module.prefetched,
|
||||
chunks: Array.from(module.chunksIterable, chunk => chunk.id),
|
||||
issuer: module.issuer && module.issuer.identifier(),
|
||||
issuerId: module.issuer && module.issuer.id,
|
||||
issuerName:
|
||||
module.issuer && module.issuer.readableIdentifier(requestShortener),
|
||||
issuer: issuer && issuer.identifier(),
|
||||
issuerId: issuer && issuer.id,
|
||||
issuerName: issuer && issuer.readableIdentifier(requestShortener),
|
||||
issuerPath:
|
||||
module.issuer &&
|
||||
issuer &&
|
||||
path.map(module => ({
|
||||
id: module.id,
|
||||
identifier: module.identifier(),
|
||||
|
|
Loading…
Reference in New Issue