webpack/lib/ModuleGraphConnection.js

47 lines
1.2 KiB
JavaScript
Raw Normal View History

/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
/** @typedef {import("./Dependency")} Dependency */
/** @typedef {import("./Module")} Module */
class ModuleGraphConnection {
/**
* @param {Module=} originModule the referencing module
* @param {Dependency=} dependency the referencing dependency
* @param {Module} module the referenced module
* @param {string=} explanation some extra detail
* @param {boolean=} weak the reference is weak
*/
constructor(originModule, dependency, module, explanation, weak = false) {
this.originModule = originModule;
this.resolvedOriginModule = originModule;
this.dependency = dependency;
this.resolvedModule = module;
this.module = module;
this.weak = weak;
2018-11-07 21:03:25 +08:00
/** @type {Set<string>} */
this.explanations = new Set();
2018-11-07 21:03:25 +08:00
if (explanation) {
this.explanations.add(explanation);
}
}
2018-11-07 21:03:25 +08:00
/**
* @param {string} explanation the explanation to add
* @returns {void}
*/
addExplanation(explanation) {
this.explanations.add(explanation);
}
get explanation() {
return Array.from(this.explanations).join(" ");
}
}
module.exports = ModuleGraphConnection;