WXL
3 天以前 9bce51f651aad297ef9eb6df832bfdaf1de05d84
node_modules/webpack/lib/optimize/InnerGraph.js
@@ -22,6 +22,7 @@
/** @typedef {(value: boolean | Set<string> | undefined) => void} UsageCallback */
/**
 * Defines the state object type used by this module.
 * @typedef {object} StateObject
 * @property {InnerGraph} innerGraph
 * @property {TopLevelSymbol=} currentTopLevelSymbol
@@ -32,9 +33,11 @@
class TopLevelSymbol {
   /**
    * Creates an instance of TopLevelSymbol.
    * @param {string} name name of the variable
    */
   constructor(name) {
      /** @type {string} */
      this.name = name;
   }
}
@@ -46,6 +49,7 @@
const topLevelSymbolTag = Symbol("top level symbol");
/**
 * Returns state.
 * @param {ParserState} parserState parser state
 * @returns {State | undefined} state
 */
@@ -54,6 +58,7 @@
}
/**
 * Processes the provided state.
 * @param {ParserState} state parser state
 * @param {TopLevelSymbol | null} symbol the symbol, or null for all symbols
 * @param {Usage} usage usage data
@@ -78,6 +83,7 @@
/** @typedef {string | TopLevelSymbol | true} Usage */
/**
 * Processes the provided parser.
 * @param {JavascriptParser} parser the parser
 * @param {string} name name of variable
 * @param {Usage} usage usage data
@@ -94,6 +100,7 @@
};
/**
 * Processes the provided parser state.
 * @param {ParserState} parserState parser state
 * @returns {void}
 */
@@ -102,6 +109,7 @@
};
/**
 * Processes the provided parser state.
 * @param {ParserState} parserState parser state
 * @returns {void}
 */
@@ -120,6 +128,7 @@
/** @typedef {Set<string> | boolean} UsedByExports */
/**
 * Usage callback map.
 * @param {Dependency} dependency the dependency
 * @param {UsedByExports | undefined} usedByExports usedByExports info
 * @param {ModuleGraph} moduleGraph moduleGraph
@@ -149,6 +158,7 @@
};
/**
 * Returns usage data.
 * @param {ParserState} state parser state
 * @returns {TopLevelSymbol | void} usage data
 */
@@ -161,6 +171,7 @@
};
/**
 * Processes the provided state.
 * @param {ParserState} state parser state
 * @returns {void}
 */
@@ -259,6 +270,7 @@
};
/**
 * Returns false, when unused. Otherwise true.
 * @param {Dependency} dependency the dependency
 * @param {UsedByExports | undefined} usedByExports usedByExports info
 * @param {ModuleGraph} moduleGraph moduleGraph
@@ -289,6 +301,7 @@
};
/**
 * Returns true, when enabled.
 * @param {ParserState} parserState parser state
 * @returns {boolean} true, when enabled
 */
@@ -298,6 +311,7 @@
};
/**
 * Processes the provided state.
 * @param {ParserState} state parser state
 * @param {UsageCallback} onUsageCallback on usage callback
 */
@@ -310,6 +324,7 @@
         let callbacks = usageCallbackMap.get(currentTopLevelSymbol);
         if (callbacks === undefined) {
            /** @type {Set<UsageCallback>} */
            callbacks = new Set();
            usageCallbackMap.set(currentTopLevelSymbol, callbacks);
         }
@@ -324,6 +339,7 @@
};
/**
 * Processes the provided state.
 * @param {ParserState} state parser state
 * @param {TopLevelSymbol | undefined} symbol the symbol
 */
@@ -336,6 +352,7 @@
};
/**
 * Returns symbol.
 * @param {JavascriptParser} parser parser
 * @param {string} name name of variable
 * @returns {TopLevelSymbol | undefined} symbol
@@ -353,14 +370,14 @@
      return existingTag;
   }
   const fn = new TopLevelSymbol(name);
   const symbol = new TopLevelSymbol(name);
   parser.tagVariable(
      name,
      topLevelSymbolTag,
      fn,
      symbol,
      JavascriptParser.VariableInfoFlags.Normal
   );
   return fn;
   return symbol;
};
module.exports.topLevelSymbolTag = topLevelSymbolTag;