123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371 |
- "use strict";
- const RawModule = require("./RawModule");
- const memoize = require("./util/memoize");
- const TRANSITIVE = Symbol("transitive");
- const getIgnoredModule = memoize(() => {
- return new RawModule("/* (ignored) */", `ignored`, `(ignored)`);
- });
- class Dependency {
- constructor() {
-
- this._parentModule = undefined;
-
- this._parentDependenciesBlock = undefined;
-
- this._parentDependenciesBlockIndex = -1;
-
-
- this.weak = false;
-
-
- this.optional = false;
- this._locSL = 0;
- this._locSC = 0;
- this._locEL = 0;
- this._locEC = 0;
- this._locI = undefined;
- this._locN = undefined;
- this._loc = undefined;
- }
-
- get type() {
- return "unknown";
- }
-
- get category() {
- return "unknown";
- }
-
- get loc() {
- if (this._loc !== undefined) return this._loc;
-
- const loc = {};
- if (this._locSL > 0) {
- loc.start = { line: this._locSL, column: this._locSC };
- }
- if (this._locEL > 0) {
- loc.end = { line: this._locEL, column: this._locEC };
- }
- if (this._locN !== undefined) {
- loc.name = this._locN;
- }
- if (this._locI !== undefined) {
- loc.index = this._locI;
- }
- return (this._loc = loc);
- }
- set loc(loc) {
- if ("start" in loc && typeof loc.start === "object") {
- this._locSL = loc.start.line || 0;
- this._locSC = loc.start.column || 0;
- } else {
- this._locSL = 0;
- this._locSC = 0;
- }
- if ("end" in loc && typeof loc.end === "object") {
- this._locEL = loc.end.line || 0;
- this._locEC = loc.end.column || 0;
- } else {
- this._locEL = 0;
- this._locEC = 0;
- }
- if ("index" in loc) {
- this._locI = loc.index;
- } else {
- this._locI = undefined;
- }
- if ("name" in loc) {
- this._locN = loc.name;
- } else {
- this._locN = undefined;
- }
- this._loc = loc;
- }
-
- setLoc(startLine, startColumn, endLine, endColumn) {
- this._locSL = startLine;
- this._locSC = startColumn;
- this._locEL = endLine;
- this._locEC = endColumn;
- this._locI = undefined;
- this._locN = undefined;
- this._loc = undefined;
- }
-
- getContext() {
- return undefined;
- }
-
- getResourceIdentifier() {
- return null;
- }
-
- couldAffectReferencingModule() {
- return TRANSITIVE;
- }
-
- getReference(moduleGraph) {
- throw new Error(
- "Dependency.getReference was removed in favor of Dependency.getReferencedExports, ModuleGraph.getModule and ModuleGraph.getConnection().active"
- );
- }
-
- getReferencedExports(moduleGraph, runtime) {
- return Dependency.EXPORTS_OBJECT_REFERENCED;
- }
-
- getCondition(moduleGraph) {
- return null;
- }
-
- getExports(moduleGraph) {
- return undefined;
- }
-
- getWarnings(moduleGraph) {
- return null;
- }
-
- getErrors(moduleGraph) {
- return null;
- }
-
- updateHash(hash, context) {}
-
- getNumberOfIdOccurrences() {
- return 1;
- }
-
- getModuleEvaluationSideEffectsState(moduleGraph) {
- return true;
- }
-
- createIgnoredModule(context) {
- return getIgnoredModule();
- }
-
- serialize({ write }) {
- write(this.weak);
- write(this.optional);
- write(this._locSL);
- write(this._locSC);
- write(this._locEL);
- write(this._locEC);
- write(this._locI);
- write(this._locN);
- }
-
- deserialize({ read }) {
- this.weak = read();
- this.optional = read();
- this._locSL = read();
- this._locSC = read();
- this._locEL = read();
- this._locEC = read();
- this._locI = read();
- this._locN = read();
- }
- }
- Dependency.NO_EXPORTS_REFERENCED = [];
- Dependency.EXPORTS_OBJECT_REFERENCED = [[]];
- Object.defineProperty(Dependency.prototype, "module", {
-
- get() {
- throw new Error(
- "module property was removed from Dependency (use compilation.moduleGraph.getModule(dependency) instead)"
- );
- },
-
- set() {
- throw new Error(
- "module property was removed from Dependency (use compilation.moduleGraph.updateModule(dependency, module) instead)"
- );
- }
- });
- Object.defineProperty(Dependency.prototype, "disconnect", {
- get() {
- throw new Error(
- "disconnect was removed from Dependency (Dependency no longer carries graph specific information)"
- );
- }
- });
- Dependency.TRANSITIVE = TRANSITIVE;
- module.exports = Dependency;
|