@node-cli/bundlesize 4.5.1 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -215,16 +215,75 @@ export default {
215
215
 
216
216
  #### Simple report with custom columns
217
217
 
218
+ The `columns` option allows you to customize the report table columns. Each column is defined as an object with a key (column identifier) and value (column header text displayed in the table).
219
+
220
+ **Available column keys:**
221
+
222
+ | Key | Description | Default Header |
223
+ | -------- | ---------------------------------------------------- | -------------- |
224
+ | `status` | Shows ✅ if within limit, 🚫 if limit exceeded | "Status" |
225
+ | `file` | Displays the file name or alias | "File" |
226
+ | `size` | Shows the gzipped size with diff from previous stats | "Size (Gzip)" |
227
+ | `limits` | Displays the configured size limit | "Limits" |
228
+
229
+ **Default columns:**
230
+
231
+ ```js
232
+ columns: [
233
+ { status: "Status" },
234
+ { file: "File" },
235
+ { size: "Size (Gzip)" },
236
+ { limits: "Limits" }
237
+ ];
238
+ ```
239
+
240
+ **Customizing column headers:**
241
+
242
+ You can change the header text while keeping the same column:
243
+
244
+ ```js
245
+ export default {
246
+ report: {
247
+ columns: [
248
+ { status: "✓/✗" },
249
+ { file: "Bundle" },
250
+ { size: "Gzip Size" },
251
+ { limits: "Max" }
252
+ ],
253
+ previous: "stats/previous.json",
254
+ current: "stats/current.json"
255
+ }
256
+ };
257
+ ```
258
+
259
+ **Removing columns:**
260
+
261
+ You can remove columns by omitting them from the array:
262
+
263
+ ```js
264
+ export default {
265
+ report: {
266
+ columns: [{ file: "File" }, { size: "Size (Gzip)" }],
267
+ previous: "stats/previous.json",
268
+ current: "stats/current.json"
269
+ }
270
+ };
271
+ ```
272
+
273
+ **Reordering columns:**
274
+
275
+ You can change the column order by rearranging the array:
276
+
218
277
  ```js
219
278
  export default {
220
279
  report: {
221
280
  columns: [
222
- { status: "Status" },
223
281
  { file: "File" },
224
- { size: "Size" },
225
- { limits: "Limits" }
282
+ { status: "Status" },
283
+ { limits: "Limits" },
284
+ { size: "Size (Gzip)" }
226
285
  ],
227
- prev: "stats/previous.json",
286
+ previous: "stats/previous.json",
228
287
  current: "stats/current.json"
229
288
  }
230
289
  };
package/dist/config.js CHANGED
@@ -12,8 +12,8 @@
12
12
  * ]
13
13
  * });
14
14
  * ```
15
- */ export function defineConfig(config) {
15
+ */ /* v8 ignore start */ export function defineConfig(config) {
16
16
  return config;
17
- }
17
+ } /* v8 ignore stop */
18
18
 
19
19
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/config.ts"],"sourcesContent":["import type { FooterProperties } from \"./utilities.js\";\n\n/**\n * Configuration for a single file size entry.\n */\nexport interface SizeEntry {\n\t/**\n\t * Path to the file to check. Supports glob patterns.\n\t * Special placeholders:\n\t * - `<hash>`: matches content hashes (e.g., `bundle-<hash>.js`)\n\t * - `<semver>`: matches semantic versions (e.g., `lib-<semver>.js`)\n\t */\n\tpath: string;\n\t/**\n\t * Maximum allowed size for the file (gzipped).\n\t * Format: number followed by unit (B, kB, KB, MB, GB, TB, PB)\n\t * @example \"10 kB\", \"1.5 MB\", \"500 B\"\n\t */\n\tlimit: string;\n\t/**\n\t * Optional alias for the file in reports.\n\t * Useful for giving meaningful names to files with hash patterns.\n\t */\n\talias?: string;\n}\n\n/**\n * Configuration for a header entry (group separator in reports).\n */\nexport interface HeaderEntry {\n\t/**\n\t * Header text to display as a group separator in reports.\n\t */\n\theader: string;\n}\n\n/**\n * Column definition for the report table.\n */\nexport interface ColumnDefinition {\n\t[key: string]: string;\n}\n\n/**\n * Configuration for generating comparison reports.\n */\nexport interface ReportConfiguration {\n\t/**\n\t * Path to the current stats JSON file (relative to config file).\n\t */\n\tcurrent: string;\n\t/**\n\t * Path to the previous stats JSON file for comparison (relative to config file).\n\t */\n\tprevious: string;\n\t/**\n\t * Custom header text for the report.\n\t * @default \"## Bundle Size\"\n\t */\n\theader?: string;\n\t/**\n\t * Custom footer function for the report.\n\t * Receives an object with limitReached, overallDiff, and totalGzipSize.\n\t */\n\tfooter?: (args: FooterProperties) => string;\n\t/**\n\t * Column definitions for the report table.\n\t * @default [{ status: \"Status\" }, { file: \"File\" }, { size: \"Size (Gzip)\" }, { limits: \"Limits\" }]\n\t */\n\tcolumns?: ColumnDefinition[];\n\t/**\n\t * Minimum gzip size change in bytes to consider as a change.\n\t * Changes below this threshold are treated as no change.\n\t * @default 0\n\t */\n\tthreshold?: number;\n}\n\n/**\n * Bundlesize configuration object.\n */\nexport interface BundlesizeConfig {\n\t/**\n\t * Array of file size entries to check.\n\t * Each entry can be either a SizeEntry (file to check) or HeaderEntry (group separator).\n\t */\n\tsizes?: (SizeEntry | HeaderEntry)[];\n\t/**\n\t * Configuration for generating comparison reports.\n\t */\n\treport?: ReportConfiguration;\n}\n\n/**\n * Helper function to define bundlesize configuration with full type support.\n * Provides IntelliSense and type checking for configuration files.\n *\n * @example\n * ```js\n * import { defineConfig } from \"@node-cli/bundlesize\";\n *\n * export default defineConfig({\n * sizes: [\n * { path: \"dist/bundle.js\", limit: \"10 kB\" }\n * ]\n * });\n * ```\n */\nexport function defineConfig(config: BundlesizeConfig): BundlesizeConfig {\n\treturn config;\n}\n"],"names":["defineConfig","config"],"mappings":"AA6FA;;;;;;;;;;;;;;CAcC,GACD,OAAO,SAASA,aAAaC,MAAwB;IACpD,OAAOA;AACR"}
1
+ {"version":3,"sources":["../src/config.ts"],"sourcesContent":["import type { FooterProperties } from \"./utilities.js\";\n\n/**\n * Configuration for a single file size entry.\n */\nexport interface SizeEntry {\n\t/**\n\t * Path to the file to check. Supports glob patterns.\n\t * Special placeholders:\n\t * - `<hash>`: matches content hashes (e.g., `bundle-<hash>.js`)\n\t * - `<semver>`: matches semantic versions (e.g., `lib-<semver>.js`)\n\t */\n\tpath: string;\n\t/**\n\t * Maximum allowed size for the file (gzipped).\n\t * Format: number followed by unit (B, kB, KB, MB, GB, TB, PB)\n\t * @example \"10 kB\", \"1.5 MB\", \"500 B\"\n\t */\n\tlimit: string;\n\t/**\n\t * Optional alias for the file in reports.\n\t * Useful for giving meaningful names to files with hash patterns.\n\t */\n\talias?: string;\n}\n\n/**\n * Configuration for a header entry (group separator in reports).\n */\nexport interface HeaderEntry {\n\t/**\n\t * Header text to display as a group separator in reports.\n\t */\n\theader: string;\n}\n\n/**\n * Column definition for the report table.\n */\nexport interface ColumnDefinition {\n\t[key: string]: string;\n}\n\n/**\n * Configuration for generating comparison reports.\n */\nexport interface ReportConfiguration {\n\t/**\n\t * Path to the current stats JSON file (relative to config file).\n\t */\n\tcurrent: string;\n\t/**\n\t * Path to the previous stats JSON file for comparison (relative to config file).\n\t */\n\tprevious: string;\n\t/**\n\t * Custom header text for the report.\n\t * @default \"## Bundle Size\"\n\t */\n\theader?: string;\n\t/**\n\t * Custom footer function for the report.\n\t * Receives an object with limitReached, overallDiff, and totalGzipSize.\n\t */\n\tfooter?: (args: FooterProperties) => string;\n\t/**\n\t * Column definitions for the report table.\n\t * @default [{ status: \"Status\" }, { file: \"File\" }, { size: \"Size (Gzip)\" }, { limits: \"Limits\" }]\n\t */\n\tcolumns?: ColumnDefinition[];\n\t/**\n\t * Minimum gzip size change in bytes to consider as a change.\n\t * Changes below this threshold are treated as no change.\n\t * @default 0\n\t */\n\tthreshold?: number;\n}\n\n/**\n * Bundlesize configuration object.\n */\nexport interface BundlesizeConfig {\n\t/**\n\t * Array of file size entries to check.\n\t * Each entry can be either a SizeEntry (file to check) or HeaderEntry (group separator).\n\t */\n\tsizes?: (SizeEntry | HeaderEntry)[];\n\t/**\n\t * Configuration for generating comparison reports.\n\t */\n\treport?: ReportConfiguration;\n}\n\n/**\n * Helper function to define bundlesize configuration with full type support.\n * Provides IntelliSense and type checking for configuration files.\n *\n * @example\n * ```js\n * import { defineConfig } from \"@node-cli/bundlesize\";\n *\n * export default defineConfig({\n * sizes: [\n * { path: \"dist/bundle.js\", limit: \"10 kB\" }\n * ]\n * });\n * ```\n */\n/* v8 ignore start */\nexport function defineConfig(config: BundlesizeConfig): BundlesizeConfig {\n\treturn config;\n}\n/* v8 ignore stop */\n"],"names":["defineConfig","config"],"mappings":"AA6FA;;;;;;;;;;;;;;CAcC,GACD,mBAAmB,GACnB,OAAO,SAASA,aAAaC,MAAwB;IACpD,OAAOA;AACR,EACA,kBAAkB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-cli/bundlesize",
3
- "version": "4.5.1",
3
+ "version": "4.6.0",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "description": "Simple CLI tool that checks file(s) size and report if limits have been reached",
@@ -35,20 +35,20 @@
35
35
  "watch": "swc --strip-leading-paths --watch --out-dir dist src"
36
36
  },
37
37
  "dependencies": {
38
- "@node-cli/logger": "1.3.2",
39
- "@node-cli/parser": "2.4.3",
38
+ "@node-cli/logger": "1.3.3",
39
+ "@node-cli/parser": "2.4.4",
40
40
  "bytes": "3.1.2",
41
- "fs-extra": "11.3.1",
42
- "glob": "11.0.3",
43
- "semver": "7.7.2"
41
+ "fs-extra": "11.3.3",
42
+ "glob": "13.0.0",
43
+ "semver": "7.7.3"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
48
  "devDependencies": {
49
- "@node-cli/comments": "0.2.6",
50
- "@vitest/coverage-v8": "3.2.4",
51
- "vitest": "3.2.4"
49
+ "@node-cli/comments": "0.2.8",
50
+ "@vitest/coverage-v8": "4.0.16",
51
+ "vitest": "4.0.16"
52
52
  },
53
- "gitHead": "b19e02fcb4745190530c693093fe87a5af5517bf"
53
+ "gitHead": "81c697fb358e4341ae58e5750f7f9503943e4686"
54
54
  }