| | |
| | | /** @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 |
| | |
| | | /** @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 |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Apply the plugin |
| | | * Applies the plugin by registering its hooks on the compiler. |
| | | * @param {Compiler} compiler the compiler instance |
| | | * @returns {void} |
| | | */ |
| | |
| | | const warnings = []; |
| | | |
| | | /** |
| | | * Gets entrypoint size. |
| | | * @param {Entrypoint} entrypoint an entrypoint |
| | | * @returns {number} the size of the entrypoint |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns result. |
| | | * @param {Asset["name"]} name the name |
| | | * @returns {boolean | undefined} result |
| | | */ |