mirror of https://github.com/webpack/webpack.git
Merge pull request #16882 from snitin315/limit-identifier-length
fix: limit module readable identifier length in stats
This commit is contained in:
commit
96c5d21a2f
|
|
@ -10,6 +10,7 @@
|
||||||
/** @typedef {import("./StatsPrinter").StatsPrinterContext} StatsPrinterContext */
|
/** @typedef {import("./StatsPrinter").StatsPrinterContext} StatsPrinterContext */
|
||||||
|
|
||||||
const DATA_URI_CONTENT_LENGTH = 16;
|
const DATA_URI_CONTENT_LENGTH = 16;
|
||||||
|
const MAX_MODULE_IDENTIFIER_LENGTH = 80;
|
||||||
|
|
||||||
const plural = (n, singular, plural) => (n === 1 ? singular : plural);
|
const plural = (n, singular, plural) => (n === 1 ? singular : plural);
|
||||||
|
|
||||||
|
|
@ -42,6 +43,19 @@ const getResourceName = resource => {
|
||||||
|
|
||||||
const getModuleName = name => {
|
const getModuleName = name => {
|
||||||
const [, prefix, resource] = /^(.*!)?([^!]*)$/.exec(name);
|
const [, prefix, resource] = /^(.*!)?([^!]*)$/.exec(name);
|
||||||
|
|
||||||
|
if (resource.length > MAX_MODULE_IDENTIFIER_LENGTH) {
|
||||||
|
const truncatedResource = `${resource.slice(
|
||||||
|
0,
|
||||||
|
Math.min(
|
||||||
|
resource.length - /* '...(truncated)'.length */ 14,
|
||||||
|
MAX_MODULE_IDENTIFIER_LENGTH
|
||||||
|
)
|
||||||
|
)}...(truncated)`;
|
||||||
|
|
||||||
|
return [prefix, getResourceName(truncatedResource)];
|
||||||
|
}
|
||||||
|
|
||||||
return [prefix, getResourceName(resource)];
|
return [prefix, getResourceName(resource)];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1193,7 +1193,7 @@ built modules 724 bytes [built]
|
||||||
./templates/baz.js 38 bytes [optional] [built] [code generated]
|
./templates/baz.js 38 bytes [optional] [built] [code generated]
|
||||||
./templates/foo.js 38 bytes [optional] [built] [code generated]
|
./templates/foo.js 38 bytes [optional] [built] [code generated]
|
||||||
./entry.js 450 bytes [built] [code generated]
|
./entry.js 450 bytes [built] [code generated]
|
||||||
./templates/ lazy ^\\\\.\\\\/.*$ include: \\\\.js$ exclude: \\\\.noimport\\\\.js$ namespace object 160 bytes [optional] [built] [code generated]
|
./templates/ lazy ^\\\\.\\\\/.*$ include: \\\\.js$ exclude: \\\\.noimport\\\\.js$ na...(truncated) 160 bytes [optional] [built] [code generated]
|
||||||
webpack x.x.x compiled successfully in X ms"
|
webpack x.x.x compiled successfully in X ms"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
@ -1433,6 +1433,13 @@ asset <CLR=32,BOLD>main.js</CLR> 84 bytes <CLR=32,BOLD>[emitted]</CLR> (name: ma
|
||||||
webpack x.x.x compiled <CLR=32,BOLD>successfully</CLR> in X ms"
|
webpack x.x.x compiled <CLR=32,BOLD>successfully</CLR> in X ms"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`StatsTestCases should print correct stats for max-external-module-readable-identifier 1`] = `
|
||||||
|
"asset main.js 1.45 KiB [emitted] (name: main)
|
||||||
|
./index.js 17 bytes [built] [code generated]
|
||||||
|
external \\"very-very-very-very-long-external-module-readable-identifier-it-should...(truncated) 42 bytes [built] [code generated]
|
||||||
|
webpack x.x.x compiled successfully in X ms"
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`StatsTestCases should print correct stats for max-modules 1`] = `
|
exports[`StatsTestCases should print correct stats for max-modules 1`] = `
|
||||||
"asset main.js 5.47 KiB [emitted] (name: main)
|
"asset main.js 5.47 KiB [emitted] (name: main)
|
||||||
./index.js 181 bytes [built] [code generated]
|
./index.js 181 bytes [built] [code generated]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
require("test");
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
/** @type {import("../../../types").Configuration} */
|
||||||
|
module.exports = {
|
||||||
|
mode: "production",
|
||||||
|
entry: "./index",
|
||||||
|
externals: {
|
||||||
|
test: "commonjs very-very-very-very-long-external-module-readable-identifier-it-should-be-truncated"
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in New Issue