Skip to content

Commit

Permalink
fix discussions
Browse files Browse the repository at this point in the history
  • Loading branch information
vankop committed Apr 11, 2022
1 parent 0aabe2a commit cb53764
Showing 1 changed file with 3 additions and 26 deletions.
29 changes: 3 additions & 26 deletions lib/dependencies/ProvidedDependency.js
Expand Up @@ -21,8 +21,6 @@ const ModuleDependency = require("./ModuleDependency");
/** @typedef {import("../util/Hash")} Hash */
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */

const idsSymbol = Symbol("ProvidedDependency.ids");

/**
* @param {string[]|null} path the property path array
* @returns {string} the converted path
Expand Down Expand Up @@ -55,34 +53,14 @@ class ProvidedDependency extends ModuleDependency {
return "esm";
}

/**
* @param {ModuleGraph} moduleGraph the module graph
* @returns {string[]} the imported ids
*/
getIds(moduleGraph) {
const meta = moduleGraph.getMetaIfExisting(this);
if (meta === undefined) return this.ids;
const ids = meta[idsSymbol];
return ids !== undefined ? ids : this.ids;
}

/**
* @param {ModuleGraph} moduleGraph the module graph
* @param {string[]} ids the imported ids
* @returns {void}
*/
setIds(moduleGraph, ids) {
moduleGraph.getMeta(this)[idsSymbol] = ids;
}

/**
* Returns list of exports referenced by this dependency
* @param {ModuleGraph} moduleGraph module graph
* @param {RuntimeSpec} runtime the runtime for which the module is analysed
* @returns {(string[] | ReferencedExport)[]} referenced exports
*/
getReferencedExports(moduleGraph, runtime) {
let ids = this.getIds(moduleGraph);
let ids = this.ids;
if (ids.length === 0) return Dependency.EXPORTS_OBJECT_REFERENCED;
return [ids];
}
Expand All @@ -95,8 +73,7 @@ class ProvidedDependency extends ModuleDependency {
*/
updateHash(hash, context) {
if (this._hashUpdate === undefined) {
this._hashUpdate =
this.identifier + (this.ids ? this.ids.join(",") : "null");
this._hashUpdate = this.identifier + (this.ids ? this.ids.join(",") : "");
}
hash.update(this._hashUpdate);
}
Expand Down Expand Up @@ -143,7 +120,7 @@ class ProvidedDependencyTemplate extends ModuleDependency.Template {
const dep = /** @type {ProvidedDependency} */ (dependency);
const connection = moduleGraph.getConnection(dep);
const exportsInfo = moduleGraph.getExportsInfo(connection.module);
const usedName = exportsInfo.getUsedName(dep.getIds(moduleGraph), runtime);
const usedName = exportsInfo.getUsedName(dep.ids, runtime);
initFragments.push(
new InitFragment(
`/* provided dependency */ var ${
Expand Down

0 comments on commit cb53764

Please sign in to comment.