Updated the files.
This commit is contained in:
parent
1553e6b971
commit
753967d4f5
23418 changed files with 3784666 additions and 0 deletions
32
my-app/node_modules/webpack/lib/performance/AssetsOverSizeLimitWarning.js
generated
vendored
Executable file
32
my-app/node_modules/webpack/lib/performance/AssetsOverSizeLimitWarning.js
generated
vendored
Executable file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Sean Larkin @thelarkinn
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { formatSize } = require("../SizeFormatHelpers");
|
||||
const WebpackError = require("../WebpackError");
|
||||
|
||||
/** @typedef {import("./SizeLimitsPlugin").AssetDetails} AssetDetails */
|
||||
|
||||
module.exports = class AssetsOverSizeLimitWarning extends WebpackError {
|
||||
/**
|
||||
* @param {AssetDetails[]} assetsOverSizeLimit the assets
|
||||
* @param {number} assetLimit the size limit
|
||||
*/
|
||||
constructor(assetsOverSizeLimit, assetLimit) {
|
||||
const assetLists = assetsOverSizeLimit
|
||||
.map(asset => `\n ${asset.name} (${formatSize(asset.size)})`)
|
||||
.join("");
|
||||
|
||||
super(`asset size limit: The following asset(s) exceed the recommended size limit (${formatSize(
|
||||
assetLimit
|
||||
)}).
|
||||
This can impact web performance.
|
||||
Assets: ${assetLists}`);
|
||||
|
||||
this.name = "AssetsOverSizeLimitWarning";
|
||||
this.assets = assetsOverSizeLimit;
|
||||
}
|
||||
};
|
35
my-app/node_modules/webpack/lib/performance/EntrypointsOverSizeLimitWarning.js
generated
vendored
Executable file
35
my-app/node_modules/webpack/lib/performance/EntrypointsOverSizeLimitWarning.js
generated
vendored
Executable file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Sean Larkin @thelarkinn
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { formatSize } = require("../SizeFormatHelpers");
|
||||
const WebpackError = require("../WebpackError");
|
||||
|
||||
/** @typedef {import("./SizeLimitsPlugin").EntrypointDetails} EntrypointDetails */
|
||||
|
||||
module.exports = class EntrypointsOverSizeLimitWarning extends WebpackError {
|
||||
/**
|
||||
* @param {EntrypointDetails[]} entrypoints the entrypoints
|
||||
* @param {number} entrypointLimit the size limit
|
||||
*/
|
||||
constructor(entrypoints, entrypointLimit) {
|
||||
const entrypointList = entrypoints
|
||||
.map(
|
||||
entrypoint =>
|
||||
`\n ${entrypoint.name} (${formatSize(
|
||||
entrypoint.size
|
||||
)})\n${entrypoint.files.map(asset => ` ${asset}`).join("\n")}`
|
||||
)
|
||||
.join("");
|
||||
super(`entrypoint size limit: The following entrypoint(s) combined asset size exceeds the recommended limit (${formatSize(
|
||||
entrypointLimit
|
||||
)}). This can impact web performance.
|
||||
Entrypoints:${entrypointList}\n`);
|
||||
|
||||
this.name = "EntrypointsOverSizeLimitWarning";
|
||||
this.entrypoints = entrypoints;
|
||||
}
|
||||
};
|
20
my-app/node_modules/webpack/lib/performance/NoAsyncChunksWarning.js
generated
vendored
Executable file
20
my-app/node_modules/webpack/lib/performance/NoAsyncChunksWarning.js
generated
vendored
Executable file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Sean Larkin @thelarkinn
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const WebpackError = require("../WebpackError");
|
||||
|
||||
module.exports = class NoAsyncChunksWarning extends WebpackError {
|
||||
constructor() {
|
||||
super(
|
||||
"webpack performance recommendations: \n" +
|
||||
"You can limit the size of your bundles by using import() or require.ensure to lazy load some parts of your application.\n" +
|
||||
"For more info visit https://webpack.js.org/guides/code-splitting/"
|
||||
);
|
||||
|
||||
this.name = "NoAsyncChunksWarning";
|
||||
}
|
||||
};
|
168
my-app/node_modules/webpack/lib/performance/SizeLimitsPlugin.js
generated
vendored
Executable file
168
my-app/node_modules/webpack/lib/performance/SizeLimitsPlugin.js
generated
vendored
Executable file
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Sean Larkin @thelarkinn
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { find } = require("../util/SetHelpers");
|
||||
const AssetsOverSizeLimitWarning = require("./AssetsOverSizeLimitWarning");
|
||||
const EntrypointsOverSizeLimitWarning = require("./EntrypointsOverSizeLimitWarning");
|
||||
const NoAsyncChunksWarning = require("./NoAsyncChunksWarning");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").PerformanceOptions} PerformanceOptions */
|
||||
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {import("../Entrypoint")} Entrypoint */
|
||||
/** @typedef {import("../WebpackError")} WebpackError */
|
||||
|
||||
/**
|
||||
* @typedef {Object} AssetDetails
|
||||
* @property {string} name
|
||||
* @property {number} size
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} EntrypointDetails
|
||||
* @property {string} name
|
||||
* @property {number} size
|
||||
* @property {string[]} files
|
||||
*/
|
||||
|
||||
const isOverSizeLimitSet = new WeakSet();
|
||||
|
||||
const excludeSourceMap = (name, source, info) => !info.development;
|
||||
|
||||
module.exports = class SizeLimitsPlugin {
|
||||
/**
|
||||
* @param {PerformanceOptions} options the plugin options
|
||||
*/
|
||||
constructor(options) {
|
||||
this.hints = options.hints;
|
||||
this.maxAssetSize = options.maxAssetSize;
|
||||
this.maxEntrypointSize = options.maxEntrypointSize;
|
||||
this.assetFilter = options.assetFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ChunkGroup | Source} thing the resource to test
|
||||
* @returns {boolean} true if over the limit
|
||||
*/
|
||||
static isOverSizeLimit(thing) {
|
||||
return isOverSizeLimitSet.has(thing);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply the plugin
|
||||
* @param {Compiler} compiler the compiler instance
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(compiler) {
|
||||
const entrypointSizeLimit = this.maxEntrypointSize;
|
||||
const assetSizeLimit = this.maxAssetSize;
|
||||
const hints = this.hints;
|
||||
const assetFilter = this.assetFilter || excludeSourceMap;
|
||||
|
||||
compiler.hooks.afterEmit.tap("SizeLimitsPlugin", compilation => {
|
||||
/** @type {WebpackError[]} */
|
||||
const warnings = [];
|
||||
|
||||
/**
|
||||
* @param {Entrypoint} entrypoint an entrypoint
|
||||
* @returns {number} the size of the entrypoint
|
||||
*/
|
||||
const getEntrypointSize = entrypoint => {
|
||||
let size = 0;
|
||||
for (const file of entrypoint.getFiles()) {
|
||||
const asset = compilation.getAsset(file);
|
||||
if (
|
||||
asset &&
|
||||
assetFilter(asset.name, asset.source, asset.info) &&
|
||||
asset.source
|
||||
) {
|
||||
size += asset.info.size || asset.source.size();
|
||||
}
|
||||
}
|
||||
return size;
|
||||
};
|
||||
|
||||
/** @type {AssetDetails[]} */
|
||||
const assetsOverSizeLimit = [];
|
||||
for (const { name, source, info } of compilation.getAssets()) {
|
||||
if (!assetFilter(name, source, info) || !source) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const size = info.size || source.size();
|
||||
if (size > /** @type {number} */ (assetSizeLimit)) {
|
||||
assetsOverSizeLimit.push({
|
||||
name,
|
||||
size
|
||||
});
|
||||
isOverSizeLimitSet.add(source);
|
||||
}
|
||||
}
|
||||
|
||||
const fileFilter = name => {
|
||||
const asset = compilation.getAsset(name);
|
||||
return asset && assetFilter(asset.name, asset.source, asset.info);
|
||||
};
|
||||
|
||||
/** @type {EntrypointDetails[]} */
|
||||
const entrypointsOverLimit = [];
|
||||
for (const [name, entry] of compilation.entrypoints) {
|
||||
const size = getEntrypointSize(entry);
|
||||
|
||||
if (size > /** @type {number} */ (entrypointSizeLimit)) {
|
||||
entrypointsOverLimit.push({
|
||||
name: name,
|
||||
size: size,
|
||||
files: entry.getFiles().filter(fileFilter)
|
||||
});
|
||||
isOverSizeLimitSet.add(entry);
|
||||
}
|
||||
}
|
||||
|
||||
if (hints) {
|
||||
// 1. Individual Chunk: Size < 250kb
|
||||
// 2. Collective Initial Chunks [entrypoint] (Each Set?): Size < 250kb
|
||||
// 3. No Async Chunks
|
||||
// if !1, then 2, if !2 return
|
||||
if (assetsOverSizeLimit.length > 0) {
|
||||
warnings.push(
|
||||
new AssetsOverSizeLimitWarning(
|
||||
assetsOverSizeLimit,
|
||||
/** @type {number} */ (assetSizeLimit)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (entrypointsOverLimit.length > 0) {
|
||||
warnings.push(
|
||||
new EntrypointsOverSizeLimitWarning(
|
||||
entrypointsOverLimit,
|
||||
/** @type {number} */ (entrypointSizeLimit)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (warnings.length > 0) {
|
||||
const someAsyncChunk = find(
|
||||
compilation.chunks,
|
||||
chunk => !chunk.canBeInitial()
|
||||
);
|
||||
|
||||
if (!someAsyncChunk) {
|
||||
warnings.push(new NoAsyncChunksWarning());
|
||||
}
|
||||
|
||||
if (hints === "error") {
|
||||
compilation.errors.push(...warnings);
|
||||
} else {
|
||||
compilation.warnings.push(...warnings);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue