webpack/lib/Dependency.js

55 lines
1012 B
JavaScript

/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const compareLocations = require("./compareLocations");
const DependencyReference = require("./dependencies/DependencyReference");
/** @typedef {import("./Module")} Module */
class Dependency {
constructor() {
/** @type {Module|null} */
this.module = null;
this.weak = false;
this.optional = false;
this.loc = undefined;
}
getResourceIdentifier() {
return null;
}
// Returns the referenced module and export
getReference() {
if (!this.module) return null;
return new DependencyReference(this.module, true, this.weak);
}
// Returns the exported names
getExports() {
return null;
}
getWarnings() {
return null;
}
getErrors() {
return null;
}
updateHash(hash) {
hash.update((this.module && this.module.id) + "");
}
disconnect() {
this.module = null;
}
}
Dependency.compare = (a, b) => compareLocations(a.loc, b.loc);
module.exports = Dependency;