WXL
4 天以前 3bd962a6d7f61239c020e2dbbeb7341e5b842dd1
node_modules/webpack/lib/optimize/SideEffectsFlagPlugin.js
@@ -30,6 +30,7 @@
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/**
 * Defines the export in module type used by this module.
 * @typedef {object} ExportInModule
 * @property {Module} module the module
 * @property {string} exportName the name of the export
@@ -44,8 +45,9 @@
const globToRegexpCache = new WeakMap();
/**
 * Returns a regular expression.
 * @param {string} glob the pattern
 * @param {Map<string, RegExp>} cache the glob to RegExp cache
 * @param {CacheItem} cache the glob to RegExp cache
 * @returns {RegExp} a regular expression
 */
const globToRegexp = (glob, cache) => {
@@ -65,14 +67,16 @@
class SideEffectsFlagPlugin {
   /**
    * Creates an instance of SideEffectsFlagPlugin.
    * @param {boolean} analyseSource analyse source code for side effects
    */
   constructor(analyseSource = true) {
      /** @type {boolean} */
      this._analyseSource = analyseSource;
   }
   /**
    * Apply the plugin
    * Applies the plugin by registering its hooks on the compiler.
    * @param {Compiler} compiler the compiler instance
    * @returns {void}
    */
@@ -121,6 +125,7 @@
            });
            if (this._analyseSource) {
               /**
                * Processes the provided parser.
                * @param {JavascriptParser} parser the parser
                * @returns {void}
                */
@@ -277,9 +282,11 @@
                  logger.time("update dependencies");
                  /** @type {Set<Module>} */
                  const optimizedModules = new Set();
                  /**
                   * Optimize incoming connections.
                   * @param {Module} module module
                   */
                  const optimizeIncomingConnections = (module) => {
@@ -291,6 +298,7 @@
                           module
                        )) {
                           const dep = connection.dependency;
                           /** @type {boolean} */
                           let isReexport;
                           if (
                              (isReexport =
@@ -381,6 +389,7 @@
                  for (const module of modules) {
                     optimizeIncomingConnections(module);
                  }
                  moduleGraph.finishUpdateParent();
                  logger.timeEnd("update dependencies");
               }
            );
@@ -389,9 +398,10 @@
   }
   /**
    * Module has side effects.
    * @param {string} moduleName the module name
    * @param {SideEffectsFlagValue} flagValue the flag value
    * @param {Map<string, RegExp>} cache cache for glob to regexp
    * @param {CacheItem} cache cache for glob to regexp
    * @returns {boolean | undefined} true, when the module has side effects, undefined or false when not
    */
   static moduleHasSideEffects(moduleName, flagValue, cache) {