WXL
4 天以前 9bce51f651aad297ef9eb6df832bfdaf1de05d84
node_modules/webpack/lib/performance/SizeLimitsPlugin.js
@@ -19,12 +19,14 @@
/** @typedef {import("../WebpackError")} WebpackError */
/**
 * Defines the asset details type used by this module.
 * @typedef {object} AssetDetails
 * @property {string} name
 * @property {number} size
 */
/**
 * Defines the entrypoint details type used by this module.
 * @typedef {object} EntrypointDetails
 * @property {string} name
 * @property {number} size
@@ -34,28 +36,31 @@
/** @type {WeakSet<Entrypoint | ChunkGroup | Source>} */
const isOverSizeLimitSet = new WeakSet();
/**
 * @param {Asset["name"]} name the name
 * @param {Asset["source"]} source the source
 * @param {Asset["info"]} info the info
 * @returns {boolean} result
 */
/** @typedef {(name: Asset["name"], source: Asset["source"], assetInfo: Asset["info"]) => boolean} AssetFilter */
/** @type {AssetFilter} */
const excludeSourceMap = (name, source, info) => !info.development;
const PLUGIN_NAME = "SizeLimitsPlugin";
module.exports = class SizeLimitsPlugin {
   /**
    * Creates an instance of SizeLimitsPlugin.
    * @param {PerformanceOptions} options the plugin options
    */
   constructor(options) {
      /** @type {PerformanceOptions["hints"]} */
      this.hints = options.hints;
      /** @type {number | undefined} */
      this.maxAssetSize = options.maxAssetSize;
      /** @type {number | undefined} */
      this.maxEntrypointSize = options.maxEntrypointSize;
      /** @type {AssetFilter | undefined} */
      this.assetFilter = options.assetFilter;
   }
   /**
    * Checks whether this size limits plugin is over size limit.
    * @param {Entrypoint | ChunkGroup | Source} thing the resource to test
    * @returns {boolean} true if over the limit
    */
@@ -64,7 +69,7 @@
   }
   /**
    * Apply the plugin
    * Applies the plugin by registering its hooks on the compiler.
    * @param {Compiler} compiler the compiler instance
    * @returns {void}
    */
@@ -79,6 +84,7 @@
         const warnings = [];
         /**
          * Gets entrypoint size.
          * @param {Entrypoint} entrypoint an entrypoint
          * @returns {number} the size of the entrypoint
          */
@@ -115,6 +121,7 @@
         }
         /**
          * Returns result.
          * @param {Asset["name"]} name the name
          * @returns {boolean | undefined} result
          */