| | |
| | | /** @typedef {boolean | typeof TRANSITIVE_ONLY | typeof CIRCULAR_CONNECTION} ConnectionState */ |
| | | |
| | | /** |
| | | * Adds connection states. |
| | | * @param {ConnectionState} a first |
| | | * @param {ConnectionState} b second |
| | | * @returns {ConnectionState} merged |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Intersect connection states. |
| | | * @param {ConnectionState} a first |
| | | * @param {ConnectionState} b second |
| | | * @returns {ConnectionState} intersected |
| | |
| | | |
| | | class ModuleGraphConnection { |
| | | /** |
| | | * @param {Module|null} originModule the referencing module |
| | | * @param {Dependency|null} dependency the referencing dependency |
| | | * Creates an instance of ModuleGraphConnection. |
| | | * @param {Module | null} originModule the referencing module |
| | | * @param {Dependency | null} dependency the referencing dependency |
| | | * @param {Module} module the referenced module |
| | | * @param {string=} explanation some extra detail |
| | | * @param {boolean=} weak the reference is weak |
| | | * @param {false | null | GetConditionFn | undefined} condition condition for the connection |
| | | * @param {false | null | GetConditionFn=} condition condition for the connection |
| | | */ |
| | | constructor( |
| | | originModule, |
| | |
| | | weak = false, |
| | | condition = undefined |
| | | ) { |
| | | /** @type {Module | null} */ |
| | | this.originModule = originModule; |
| | | /** @type {Module | null} */ |
| | | this.resolvedOriginModule = originModule; |
| | | /** @type {Dependency | null} */ |
| | | this.dependency = dependency; |
| | | /** @type {Module} */ |
| | | this.resolvedModule = module; |
| | | /** @type {Module} */ |
| | | this.module = module; |
| | | /** @type {boolean | undefined} */ |
| | | this.weak = weak; |
| | | /** @type {boolean} */ |
| | | this.conditional = Boolean(condition); |
| | | /** @type {boolean} */ |
| | | this._active = condition !== false; |
| | | /** @type {false | null | GetConditionFn | undefined} */ |
| | | this.condition = condition || undefined; |
| | | /** @type {Set<string> | undefined} */ |
| | | this.explanations = undefined; |
| | |
| | | } |
| | | |
| | | /** |
| | | * Adds the provided condition to the module graph connection. |
| | | * @param {GetConditionFn} condition condition for the connection |
| | | * @returns {void} |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Adds the provided explanation to the module graph connection. |
| | | * @param {string} explanation the explanation to add |
| | | * @returns {void} |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks whether this module graph connection is active. |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {boolean} true, if the connection is active |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks whether this module graph connection is target active. |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {boolean} true, if the connection is active |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns true: fully active, false: inactive, TRANSITIVE: direct module inactive, but transitive connection maybe active. |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {ConnectionState} true: fully active, false: inactive, TRANSITIVE: direct module inactive, but transitive connection maybe active |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates active using the provided value. |
| | | * @param {boolean} value active or not |
| | | * @returns {void} |
| | | */ |
| | | setActive(value) { |
| | | this.conditional = false; |
| | | this._active = value; |
| | | } |
| | | |
| | | // TODO webpack 5 remove |
| | | get active() { |
| | | throw new Error("Use getActiveState instead"); |
| | | } |
| | | |
| | | set active(value) { |
| | | throw new Error("Use setActive instead"); |
| | | } |
| | | } |
| | | |