@node-cli/bundlecheck 1.4.0 → 1.4.1

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.
Files changed (2) hide show
  1. package/dist/index.d.ts +319 -3
  2. package/package.json +3 -4
package/dist/index.d.ts CHANGED
@@ -1,5 +1,321 @@
1
1
  /**
2
- * @file Automatically generated by barrelsby.
2
+ * @node-cli/bundlecheck - Library API
3
+ *
4
+ * Programmatic interface for analyzing npm package bundle sizes.
5
+ *
3
6
  */
4
-
5
- export * from "./index";
7
+ /**
8
+ * =============================================================================
9
+ * Types
10
+ * =============================================================================
11
+ */
12
+ /**
13
+ * Options for getting bundle stats of a single package.
14
+ */
15
+ export type GetBundleStatsOptions = {
16
+ /**
17
+ * Package name with optional version (e.g., "@mantine/core" or
18
+ * "@mantine/core@7.0.0").
19
+ */
20
+ package: string;
21
+ /**
22
+ * Specific exports to measure (e.g., ["Button", "Input"]).
23
+ */
24
+ exports?: string[];
25
+ /**
26
+ * Additional packages to mark as external (not bundled).
27
+ */
28
+ external?: string[];
29
+ /**
30
+ * Bundle everything including default externals (react, react-dom).
31
+ */
32
+ noExternal?: boolean;
33
+ /**
34
+ * Gzip compression level (1-9, default 5).
35
+ */
36
+ gzipLevel?: number;
37
+ /**
38
+ * Custom npm registry URL.
39
+ */
40
+ registry?: string;
41
+ /**
42
+ * Target platform: "browser", "node", or "auto" (default: "auto" - auto-detect
43
+ * from package.json).
44
+ */
45
+ platform?: "browser" | "node" | "auto";
46
+ /**
47
+ * Bypass cache and force re-analysis.
48
+ */
49
+ force?: boolean;
50
+ };
51
+ /**
52
+ * Result from getBundleStats.
53
+ */
54
+ export type BundleStats = {
55
+ /**
56
+ * Display name of the package (may include subpath).
57
+ */
58
+ packageName: string;
59
+ /**
60
+ * Resolved package version.
61
+ */
62
+ packageVersion: string;
63
+ /**
64
+ * Exports that were analyzed.
65
+ */
66
+ exports: string[];
67
+ /**
68
+ * Raw (minified) bundle size in bytes.
69
+ */
70
+ rawSize: number;
71
+ /**
72
+ * Gzipped bundle size in bytes (null for node platform).
73
+ */
74
+ gzipSize: number | null;
75
+ /**
76
+ * Gzip compression level used.
77
+ */
78
+ gzipLevel: number;
79
+ /**
80
+ * Packages marked as external (not included in bundle).
81
+ */
82
+ externals: string[];
83
+ /**
84
+ * Package dependencies.
85
+ */
86
+ dependencies: string[];
87
+ /**
88
+ * Target platform used for bundling.
89
+ */
90
+ platform: "browser" | "node";
91
+ /**
92
+ * Human-readable raw size (e.g., "45.2 kB").
93
+ */
94
+ rawSizeFormatted: string;
95
+ /**
96
+ * Human-readable gzip size (e.g., "12.3 kB") or null.
97
+ */
98
+ gzipSizeFormatted: string | null;
99
+ /**
100
+ * Whether the result was retrieved from cache.
101
+ */
102
+ fromCache: boolean;
103
+ };
104
+ /**
105
+ * Options for getting bundle size trend across versions.
106
+ */
107
+ export type GetBundleTrendOptions = {
108
+ /**
109
+ * Package name (e.g., "@mantine/core") - version is ignored if provided.
110
+ */
111
+ package: string;
112
+ /**
113
+ * Number of versions to analyze (default 5).
114
+ */
115
+ versionCount?: number;
116
+ /**
117
+ * Specific exports to measure (e.g., ["Button", "Input"]).
118
+ */
119
+ exports?: string[];
120
+ /**
121
+ * Additional packages to mark as external (not bundled).
122
+ */
123
+ external?: string[];
124
+ /**
125
+ * Bundle everything including default externals (react, react-dom).
126
+ */
127
+ noExternal?: boolean;
128
+ /**
129
+ * Gzip compression level (1-9, default 5).
130
+ */
131
+ gzipLevel?: number;
132
+ /**
133
+ * Custom npm registry URL.
134
+ */
135
+ registry?: string;
136
+ /**
137
+ * Target platform: "browser", "node", or "auto" (default: "auto" - auto-detect
138
+ * from package.json).
139
+ */
140
+ platform?: "browser" | "node" | "auto";
141
+ /**
142
+ * Bypass cache and force re-analysis.
143
+ */
144
+ force?: boolean;
145
+ };
146
+ /**
147
+ * Single version result in trend analysis.
148
+ */
149
+ export type TrendVersionResult = {
150
+ /**
151
+ * Package version.
152
+ */
153
+ version: string;
154
+ /**
155
+ * Raw (minified) bundle size in bytes.
156
+ */
157
+ rawSize: number;
158
+ /**
159
+ * Gzipped bundle size in bytes (null for node platform).
160
+ */
161
+ gzipSize: number | null;
162
+ /**
163
+ * Human-readable raw size (e.g., "45.2 kB").
164
+ */
165
+ rawSizeFormatted: string;
166
+ /**
167
+ * Human-readable gzip size (e.g., "12.3 kB") or null.
168
+ */
169
+ gzipSizeFormatted: string | null;
170
+ };
171
+ /**
172
+ * Size change information between oldest and newest versions.
173
+ */
174
+ export type TrendChange = {
175
+ /**
176
+ * Oldest version analyzed.
177
+ */
178
+ fromVersion: string;
179
+ /**
180
+ * Newest version analyzed.
181
+ */
182
+ toVersion: string;
183
+ /**
184
+ * Raw size difference in bytes (positive = increase, negative = decrease).
185
+ */
186
+ rawDiff: number;
187
+ /**
188
+ * Raw size percentage change (null if oldest size was 0).
189
+ */
190
+ rawPercent: number | null;
191
+ /**
192
+ * Human-readable raw size change (e.g., "+5.2 kB" or "-1.3 kB").
193
+ */
194
+ rawDiffFormatted: string;
195
+ /**
196
+ * Gzip size difference in bytes (null if not applicable).
197
+ */
198
+ gzipDiff: number | null;
199
+ /**
200
+ * Gzip size percentage change (null if not applicable or oldest size was 0).
201
+ */
202
+ gzipPercent: number | null;
203
+ /**
204
+ * Human-readable gzip size change (e.g., "+1.5 kB" or "-0.8 kB") or null.
205
+ */
206
+ gzipDiffFormatted: string | null;
207
+ };
208
+ /**
209
+ * Result from getBundleTrend.
210
+ */
211
+ export type BundleTrend = {
212
+ /**
213
+ * Package name.
214
+ */
215
+ packageName: string;
216
+ /**
217
+ * Results for each version analyzed (newest first).
218
+ */
219
+ versions: TrendVersionResult[];
220
+ /**
221
+ * Size change between oldest and newest versions (null if only one version).
222
+ */
223
+ change: TrendChange | null;
224
+ };
225
+ /**
226
+ * Options for fetching package versions.
227
+ */
228
+ export type GetPackageVersionsOptions = {
229
+ /**
230
+ * Package name (e.g., "@mantine/core").
231
+ */
232
+ package: string;
233
+ /**
234
+ * Custom npm registry URL.
235
+ */
236
+ registry?: string;
237
+ };
238
+ /**
239
+ * Result from getPackageVersions.
240
+ */
241
+ export type PackageVersions = {
242
+ /**
243
+ * All available versions (sorted newest first).
244
+ */
245
+ versions: string[];
246
+ /**
247
+ * Distribution tags (e.g., { latest: "7.0.0", next: "8.0.0-beta.1" }).
248
+ */
249
+ tags: Record<string, string>;
250
+ };
251
+ /**
252
+ * =============================================================================
253
+ * Library Functions
254
+ * =============================================================================
255
+ */
256
+ /**
257
+ * Get bundle size statistics for an npm package.
258
+ *
259
+ * @example
260
+ * ```js
261
+ * import { getBundleStats } from "@node-cli/bundlecheck";
262
+ *
263
+ * const stats = await getBundleStats({
264
+ * package: "@mantine/core@7.0.0",
265
+ * exports: ["Button", "Input"],
266
+ * });
267
+ *
268
+ * console.log(stats.gzipSizeFormatted); // "12.3 kB"
269
+ * ```
270
+ *
271
+ */
272
+ export declare function getBundleStats(options: GetBundleStatsOptions): Promise<BundleStats>;
273
+ /**
274
+ * Get bundle size trend across multiple versions of a package.
275
+ *
276
+ * @example
277
+ * ```js
278
+ * import { getBundleTrend } from "@node-cli/bundlecheck";
279
+ *
280
+ * const trend = await getBundleTrend({
281
+ * package: "@mantine/core",
282
+ * versionCount: 5,
283
+ * });
284
+ *
285
+ * console.log(trend.change?.rawDiffFormatted); // "+5.2 kB"
286
+ * ```
287
+ *
288
+ */
289
+ export declare function getBundleTrend(options: GetBundleTrendOptions): Promise<BundleTrend>;
290
+ /**
291
+ * Get available versions for an npm package.
292
+ *
293
+ * @example
294
+ * ```js
295
+ * import { getPackageVersions } from "@node-cli/bundlecheck";
296
+ *
297
+ * const { versions, tags } = await getPackageVersions({
298
+ * package: "@mantine/core",
299
+ * });
300
+ *
301
+ * console.log(tags.latest); // "7.0.0"
302
+ * ```
303
+ *
304
+ */
305
+ export declare function getPackageVersions(options: GetPackageVersionsOptions): Promise<PackageVersions>;
306
+ /**
307
+ * =============================================================================
308
+ * Re-exports for advanced usage
309
+ * =============================================================================
310
+ */
311
+ /**
312
+ * - Format bytes to human-readable string (e.g., 1024 → "1 kB").
313
+ * - Parse a package specifier (e.g., "@scope/name@1.0.0" → { name, version,
314
+ * subpath }).
315
+ */
316
+ export { formatBytes, parsePackageSpecifier } from "./bundler.js";
317
+ /**
318
+ * - Clear the bundle cache.
319
+ * - Get the number of cached entries.
320
+ */
321
+ export { clearCache, getCacheCount } from "./cache.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-cli/bundlecheck",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "license": "MIT",
5
5
  "author": "Arno Versini",
6
6
  "description": "CLI tool to check the bundle size of npm packages (like bundlephobia)",
@@ -20,8 +20,7 @@
20
20
  ],
21
21
  "node": ">=20",
22
22
  "scripts": {
23
- "build": "npm-run-all --serial clean build:types build:js build:barrel",
24
- "build:barrel": "barrelsby --delete --directory dist --pattern \"**/*.d.ts\" --name \"index.d\"",
23
+ "build": "npm-run-all --serial clean build:types build:js",
25
24
  "build:js": "swc --strip-leading-paths --source-maps --out-dir dist src",
26
25
  "build:types": "tsc",
27
26
  "clean": "rimraf dist types coverage",
@@ -51,5 +50,5 @@
51
50
  "@vitest/coverage-v8": "4.0.18",
52
51
  "vitest": "4.0.18"
53
52
  },
54
- "gitHead": "e6ab3435a49c7cd2a0ef27bd692e3de658a29ef4"
53
+ "gitHead": "00b91b9bd59c6e8edc7f1730eef4d5042a7fb555"
55
54
  }