@node-cli/bundlecheck 1.3.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.
- package/README.md +202 -0
- package/dist/bundlecheck.js +23 -21
- package/dist/bundlecheck.js.map +1 -1
- package/dist/bundler.d.ts +10 -6
- package/dist/bundler.js +92 -84
- package/dist/bundler.js.map +1 -1
- package/dist/cache.d.ts +18 -15
- package/dist/cache.js +39 -35
- package/dist/cache.js.map +1 -1
- package/dist/defaults.d.ts +2 -2
- package/dist/defaults.js +10 -10
- package/dist/defaults.js.map +1 -1
- package/dist/index.d.ts +320 -10
- package/dist/index.js +229 -0
- package/dist/index.js.map +1 -0
- package/dist/trend.d.ts +14 -8
- package/dist/trend.js +39 -33
- package/dist/trend.js.map +1 -1
- package/dist/versions.d.ts +1 -1
- package/dist/versions.js +12 -10
- package/dist/versions.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,321 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
* @node-cli/bundlecheck - Library API
|
|
3
|
+
*
|
|
4
|
+
* Programmatic interface for analyzing npm package bundle sizes.
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
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/dist/index.js
ADDED
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @node-cli/bundlecheck - Library API
|
|
3
|
+
*
|
|
4
|
+
* Programmatic interface for analyzing npm package bundle sizes.
|
|
5
|
+
*
|
|
6
|
+
*/ import { checkBundleSize, formatBytes, getExternals, parsePackageSpecifier } from "./bundler.js";
|
|
7
|
+
import { getCachedResult, normalizeCacheKey, setCachedResult } from "./cache.js";
|
|
8
|
+
import { normalizePlatform, TREND_VERSION_COUNT } from "./defaults.js";
|
|
9
|
+
import { analyzeTrend, selectTrendVersions } from "./trend.js";
|
|
10
|
+
import { fetchPackageVersions as fetchVersions } from "./versions.js";
|
|
11
|
+
/**
|
|
12
|
+
* =============================================================================
|
|
13
|
+
* Library Functions
|
|
14
|
+
* =============================================================================
|
|
15
|
+
*/ /**
|
|
16
|
+
* Get bundle size statistics for an npm package.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```js
|
|
20
|
+
* import { getBundleStats } from "@node-cli/bundlecheck";
|
|
21
|
+
*
|
|
22
|
+
* const stats = await getBundleStats({
|
|
23
|
+
* package: "@mantine/core@7.0.0",
|
|
24
|
+
* exports: ["Button", "Input"],
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* console.log(stats.gzipSizeFormatted); // "12.3 kB"
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
*/ export async function getBundleStats(options) {
|
|
31
|
+
const { package: packageName, exports: exportsList, external: additionalExternals, noExternal, gzipLevel = 5, registry, platform: platformOption = "auto", force = false } = options;
|
|
32
|
+
// Normalize platform.
|
|
33
|
+
const platform = normalizePlatform(platformOption === "auto" ? undefined : platformOption);
|
|
34
|
+
// Parse package specifier.
|
|
35
|
+
const { name: baseName, version: requestedVersion } = parsePackageSpecifier(packageName);
|
|
36
|
+
// Resolve "latest" to actual version for cache key.
|
|
37
|
+
let resolvedVersion = requestedVersion;
|
|
38
|
+
if (requestedVersion === "latest") {
|
|
39
|
+
const { tags } = await fetchVersions({
|
|
40
|
+
packageName: baseName,
|
|
41
|
+
registry
|
|
42
|
+
});
|
|
43
|
+
resolvedVersion = tags.latest || requestedVersion;
|
|
44
|
+
}
|
|
45
|
+
// Compute externals for cache key.
|
|
46
|
+
const externals = getExternals(baseName, additionalExternals, noExternal);
|
|
47
|
+
// Build cache key.
|
|
48
|
+
const cacheKey = normalizeCacheKey({
|
|
49
|
+
packageName: baseName,
|
|
50
|
+
version: resolvedVersion,
|
|
51
|
+
exports: exportsList,
|
|
52
|
+
platform,
|
|
53
|
+
gzipLevel,
|
|
54
|
+
externals,
|
|
55
|
+
noExternal: noExternal ?? false
|
|
56
|
+
});
|
|
57
|
+
// Check cache (unless force is set).
|
|
58
|
+
if (!force) {
|
|
59
|
+
const cached = getCachedResult(cacheKey);
|
|
60
|
+
if (cached) {
|
|
61
|
+
return formatBundleStats(cached, true);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Perform the analysis.
|
|
65
|
+
const result = await checkBundleSize({
|
|
66
|
+
packageName,
|
|
67
|
+
exports: exportsList,
|
|
68
|
+
additionalExternals,
|
|
69
|
+
noExternal,
|
|
70
|
+
gzipLevel,
|
|
71
|
+
registry,
|
|
72
|
+
platform
|
|
73
|
+
});
|
|
74
|
+
// Store in cache.
|
|
75
|
+
setCachedResult(cacheKey, result);
|
|
76
|
+
return formatBundleStats(result, false);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get bundle size trend across multiple versions of a package.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```js
|
|
83
|
+
* import { getBundleTrend } from "@node-cli/bundlecheck";
|
|
84
|
+
*
|
|
85
|
+
* const trend = await getBundleTrend({
|
|
86
|
+
* package: "@mantine/core",
|
|
87
|
+
* versionCount: 5,
|
|
88
|
+
* });
|
|
89
|
+
*
|
|
90
|
+
* console.log(trend.change?.rawDiffFormatted); // "+5.2 kB"
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
*/ export async function getBundleTrend(options) {
|
|
94
|
+
const { package: packageName, versionCount = TREND_VERSION_COUNT, exports: exportsList, external: additionalExternals, noExternal, gzipLevel, registry, platform: platformOption = "auto", force = false } = options;
|
|
95
|
+
// Normalize platform.
|
|
96
|
+
const platform = normalizePlatform(platformOption === "auto" ? undefined : platformOption);
|
|
97
|
+
// Parse package name (ignore version if provided).
|
|
98
|
+
const { name: baseName, subpath } = parsePackageSpecifier(packageName);
|
|
99
|
+
const fullPackagePath = subpath ? `${baseName}/${subpath}` : baseName;
|
|
100
|
+
// Fetch available versions.
|
|
101
|
+
const { versions } = await fetchVersions({
|
|
102
|
+
packageName: baseName,
|
|
103
|
+
registry
|
|
104
|
+
});
|
|
105
|
+
if (versions.length === 0) {
|
|
106
|
+
throw new Error(`No versions found for package: ${baseName}`);
|
|
107
|
+
}
|
|
108
|
+
// Select versions for trend.
|
|
109
|
+
const trendVersions = selectTrendVersions(versions, versionCount);
|
|
110
|
+
// Analyze all versions (silently - no console output).
|
|
111
|
+
const results = await analyzeTrend({
|
|
112
|
+
packageName: fullPackagePath,
|
|
113
|
+
versions: trendVersions,
|
|
114
|
+
exports: exportsList,
|
|
115
|
+
additionalExternals,
|
|
116
|
+
noExternal,
|
|
117
|
+
gzipLevel,
|
|
118
|
+
boring: true,
|
|
119
|
+
registry,
|
|
120
|
+
platform,
|
|
121
|
+
force
|
|
122
|
+
});
|
|
123
|
+
if (results.length === 0) {
|
|
124
|
+
throw new Error(`Failed to analyze any versions for package: ${baseName}`);
|
|
125
|
+
}
|
|
126
|
+
// Format results.
|
|
127
|
+
const formattedVersions = results.map((r)=>({
|
|
128
|
+
version: r.version,
|
|
129
|
+
rawSize: r.rawSize,
|
|
130
|
+
gzipSize: r.gzipSize,
|
|
131
|
+
rawSizeFormatted: formatBytes(r.rawSize),
|
|
132
|
+
gzipSizeFormatted: r.gzipSize !== null ? formatBytes(r.gzipSize) : null
|
|
133
|
+
}));
|
|
134
|
+
// Calculate change between oldest and newest.
|
|
135
|
+
let change = null;
|
|
136
|
+
if (results.length > 1) {
|
|
137
|
+
const newest = results[0];
|
|
138
|
+
const oldest = results[results.length - 1];
|
|
139
|
+
const rawDiff = newest.rawSize - oldest.rawSize;
|
|
140
|
+
// Handle division by zero: if oldest size is 0, percent is null.
|
|
141
|
+
const rawPercent = oldest.rawSize === 0 ? null : rawDiff / oldest.rawSize * 100;
|
|
142
|
+
let gzipDiff = null;
|
|
143
|
+
let gzipPercent = null;
|
|
144
|
+
let gzipDiffFormatted = null;
|
|
145
|
+
if (newest.gzipSize !== null && oldest.gzipSize !== null) {
|
|
146
|
+
gzipDiff = newest.gzipSize - oldest.gzipSize;
|
|
147
|
+
// Handle division by zero: if oldest size is 0, percent is null.
|
|
148
|
+
gzipPercent = oldest.gzipSize === 0 ? null : gzipDiff / oldest.gzipSize * 100;
|
|
149
|
+
gzipDiffFormatted = gzipDiff >= 0 ? `+${formatBytes(gzipDiff)}` : `-${formatBytes(Math.abs(gzipDiff))}`;
|
|
150
|
+
}
|
|
151
|
+
change = {
|
|
152
|
+
fromVersion: oldest.version,
|
|
153
|
+
toVersion: newest.version,
|
|
154
|
+
rawDiff,
|
|
155
|
+
rawPercent: rawPercent !== null ? Number.parseFloat(rawPercent.toFixed(1)) : null,
|
|
156
|
+
rawDiffFormatted: rawDiff >= 0 ? `+${formatBytes(rawDiff)}` : `-${formatBytes(Math.abs(rawDiff))}`,
|
|
157
|
+
gzipDiff,
|
|
158
|
+
gzipPercent: gzipPercent !== null ? Number.parseFloat(gzipPercent.toFixed(1)) : null,
|
|
159
|
+
gzipDiffFormatted
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
packageName: fullPackagePath,
|
|
164
|
+
versions: formattedVersions,
|
|
165
|
+
change
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Get available versions for an npm package.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```js
|
|
173
|
+
* import { getPackageVersions } from "@node-cli/bundlecheck";
|
|
174
|
+
*
|
|
175
|
+
* const { versions, tags } = await getPackageVersions({
|
|
176
|
+
* package: "@mantine/core",
|
|
177
|
+
* });
|
|
178
|
+
*
|
|
179
|
+
* console.log(tags.latest); // "7.0.0"
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
*/ export async function getPackageVersions(options) {
|
|
183
|
+
const { package: packageName, registry } = options;
|
|
184
|
+
const result = await fetchVersions({
|
|
185
|
+
packageName,
|
|
186
|
+
registry
|
|
187
|
+
});
|
|
188
|
+
return {
|
|
189
|
+
versions: result.versions,
|
|
190
|
+
tags: result.tags
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* =============================================================================
|
|
195
|
+
* Re-exports for advanced usage
|
|
196
|
+
* =============================================================================
|
|
197
|
+
*/ /**
|
|
198
|
+
* - Format bytes to human-readable string (e.g., 1024 → "1 kB").
|
|
199
|
+
* - Parse a package specifier (e.g., "@scope/name@1.0.0" → { name, version,
|
|
200
|
+
* subpath }).
|
|
201
|
+
*/ export { formatBytes, parsePackageSpecifier } from "./bundler.js";
|
|
202
|
+
/**
|
|
203
|
+
* - Clear the bundle cache.
|
|
204
|
+
* - Get the number of cached entries.
|
|
205
|
+
*/ export { clearCache, getCacheCount } from "./cache.js";
|
|
206
|
+
/**
|
|
207
|
+
* =============================================================================
|
|
208
|
+
* Internal Helpers
|
|
209
|
+
* =============================================================================
|
|
210
|
+
*/ /**
|
|
211
|
+
* Format a BundleResult into a BundleStats object.
|
|
212
|
+
*/ function formatBundleStats(result, fromCache) {
|
|
213
|
+
return {
|
|
214
|
+
packageName: result.packageName,
|
|
215
|
+
packageVersion: result.packageVersion,
|
|
216
|
+
exports: result.exports,
|
|
217
|
+
rawSize: result.rawSize,
|
|
218
|
+
gzipSize: result.gzipSize,
|
|
219
|
+
gzipLevel: result.gzipLevel,
|
|
220
|
+
externals: result.externals,
|
|
221
|
+
dependencies: result.dependencies,
|
|
222
|
+
platform: result.platform,
|
|
223
|
+
rawSizeFormatted: formatBytes(result.rawSize),
|
|
224
|
+
gzipSizeFormatted: result.gzipSize !== null ? formatBytes(result.gzipSize) : null,
|
|
225
|
+
fromCache
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @node-cli/bundlecheck - Library API\n *\n * Programmatic interface for analyzing npm package bundle sizes.\n *\n */\n\nimport {\n\ttype BundleResult,\n\tcheckBundleSize,\n\tformatBytes,\n\tgetExternals,\n\tparsePackageSpecifier,\n} from \"./bundler.js\";\nimport {\n\tgetCachedResult,\n\tnormalizeCacheKey,\n\tsetCachedResult,\n} from \"./cache.js\";\nimport { normalizePlatform, TREND_VERSION_COUNT } from \"./defaults.js\";\nimport { analyzeTrend, selectTrendVersions } from \"./trend.js\";\nimport { fetchPackageVersions as fetchVersions } from \"./versions.js\";\n\n/**\n * =============================================================================\n * Types\n * =============================================================================\n */\n\n/**\n * Options for getting bundle stats of a single package.\n */\nexport type GetBundleStatsOptions = {\n\t/**\n\t * Package name with optional version (e.g., \"@mantine/core\" or\n\t * \"@mantine/core@7.0.0\").\n\t */\n\tpackage: string;\n\t/**\n\t * Specific exports to measure (e.g., [\"Button\", \"Input\"]).\n\t */\n\texports?: string[];\n\t/**\n\t * Additional packages to mark as external (not bundled).\n\t */\n\texternal?: string[];\n\t/**\n\t * Bundle everything including default externals (react, react-dom).\n\t */\n\tnoExternal?: boolean;\n\t/**\n\t * Gzip compression level (1-9, default 5).\n\t */\n\tgzipLevel?: number;\n\t/**\n\t * Custom npm registry URL.\n\t */\n\tregistry?: string;\n\t/**\n\t * Target platform: \"browser\", \"node\", or \"auto\" (default: \"auto\" - auto-detect\n\t * from package.json).\n\t */\n\tplatform?: \"browser\" | \"node\" | \"auto\";\n\t/**\n\t * Bypass cache and force re-analysis.\n\t */\n\tforce?: boolean;\n};\n\n/**\n * Result from getBundleStats.\n */\nexport type BundleStats = {\n\t/**\n\t * Display name of the package (may include subpath).\n\t */\n\tpackageName: string;\n\t/**\n\t * Resolved package version.\n\t */\n\tpackageVersion: string;\n\t/**\n\t * Exports that were analyzed.\n\t */\n\texports: string[];\n\t/**\n\t * Raw (minified) bundle size in bytes.\n\t */\n\trawSize: number;\n\t/**\n\t * Gzipped bundle size in bytes (null for node platform).\n\t */\n\tgzipSize: number | null;\n\t/**\n\t * Gzip compression level used.\n\t */\n\tgzipLevel: number;\n\t/**\n\t * Packages marked as external (not included in bundle).\n\t */\n\texternals: string[];\n\t/**\n\t * Package dependencies.\n\t */\n\tdependencies: string[];\n\t/**\n\t * Target platform used for bundling.\n\t */\n\tplatform: \"browser\" | \"node\";\n\t/**\n\t * Human-readable raw size (e.g., \"45.2 kB\").\n\t */\n\trawSizeFormatted: string;\n\t/**\n\t * Human-readable gzip size (e.g., \"12.3 kB\") or null.\n\t */\n\tgzipSizeFormatted: string | null;\n\t/**\n\t * Whether the result was retrieved from cache.\n\t */\n\tfromCache: boolean;\n};\n\n/**\n * Options for getting bundle size trend across versions.\n */\nexport type GetBundleTrendOptions = {\n\t/**\n\t * Package name (e.g., \"@mantine/core\") - version is ignored if provided.\n\t */\n\tpackage: string;\n\t/**\n\t * Number of versions to analyze (default 5).\n\t */\n\tversionCount?: number;\n\t/**\n\t * Specific exports to measure (e.g., [\"Button\", \"Input\"]).\n\t */\n\texports?: string[];\n\t/**\n\t * Additional packages to mark as external (not bundled).\n\t */\n\texternal?: string[];\n\t/**\n\t * Bundle everything including default externals (react, react-dom).\n\t */\n\tnoExternal?: boolean;\n\t/**\n\t * Gzip compression level (1-9, default 5).\n\t */\n\tgzipLevel?: number;\n\t/**\n\t * Custom npm registry URL.\n\t */\n\tregistry?: string;\n\t/**\n\t * Target platform: \"browser\", \"node\", or \"auto\" (default: \"auto\" - auto-detect\n\t * from package.json).\n\t */\n\tplatform?: \"browser\" | \"node\" | \"auto\";\n\t/**\n\t * Bypass cache and force re-analysis.\n\t */\n\tforce?: boolean;\n};\n\n/**\n * Single version result in trend analysis.\n */\nexport type TrendVersionResult = {\n\t/**\n\t * Package version.\n\t */\n\tversion: string;\n\t/**\n\t * Raw (minified) bundle size in bytes.\n\t */\n\trawSize: number;\n\t/**\n\t * Gzipped bundle size in bytes (null for node platform).\n\t */\n\tgzipSize: number | null;\n\t/**\n\t * Human-readable raw size (e.g., \"45.2 kB\").\n\t */\n\trawSizeFormatted: string;\n\t/**\n\t * Human-readable gzip size (e.g., \"12.3 kB\") or null.\n\t */\n\tgzipSizeFormatted: string | null;\n};\n\n/**\n * Size change information between oldest and newest versions.\n */\nexport type TrendChange = {\n\t/**\n\t * Oldest version analyzed.\n\t */\n\tfromVersion: string;\n\t/**\n\t * Newest version analyzed.\n\t */\n\ttoVersion: string;\n\t/**\n\t * Raw size difference in bytes (positive = increase, negative = decrease).\n\t */\n\trawDiff: number;\n\t/**\n\t * Raw size percentage change (null if oldest size was 0).\n\t */\n\trawPercent: number | null;\n\t/**\n\t * Human-readable raw size change (e.g., \"+5.2 kB\" or \"-1.3 kB\").\n\t */\n\trawDiffFormatted: string;\n\t/**\n\t * Gzip size difference in bytes (null if not applicable).\n\t */\n\tgzipDiff: number | null;\n\t/**\n\t * Gzip size percentage change (null if not applicable or oldest size was 0).\n\t */\n\tgzipPercent: number | null;\n\t/**\n\t * Human-readable gzip size change (e.g., \"+1.5 kB\" or \"-0.8 kB\") or null.\n\t */\n\tgzipDiffFormatted: string | null;\n};\n\n/**\n * Result from getBundleTrend.\n */\nexport type BundleTrend = {\n\t/**\n\t * Package name.\n\t */\n\tpackageName: string;\n\t/**\n\t * Results for each version analyzed (newest first).\n\t */\n\tversions: TrendVersionResult[];\n\t/**\n\t * Size change between oldest and newest versions (null if only one version).\n\t */\n\tchange: TrendChange | null;\n};\n\n/**\n * Options for fetching package versions.\n */\nexport type GetPackageVersionsOptions = {\n\t/**\n\t * Package name (e.g., \"@mantine/core\").\n\t */\n\tpackage: string;\n\t/**\n\t * Custom npm registry URL.\n\t */\n\tregistry?: string;\n};\n\n/**\n * Result from getPackageVersions.\n */\nexport type PackageVersions = {\n\t/**\n\t * All available versions (sorted newest first).\n\t */\n\tversions: string[];\n\t/**\n\t * Distribution tags (e.g., { latest: \"7.0.0\", next: \"8.0.0-beta.1\" }).\n\t */\n\ttags: Record<string, string>;\n};\n\n/**\n * =============================================================================\n * Library Functions\n * =============================================================================\n */\n\n/**\n * Get bundle size statistics for an npm package.\n *\n * @example\n * ```js\n * import { getBundleStats } from \"@node-cli/bundlecheck\";\n *\n * const stats = await getBundleStats({\n * package: \"@mantine/core@7.0.0\",\n * exports: [\"Button\", \"Input\"],\n * });\n *\n * console.log(stats.gzipSizeFormatted); // \"12.3 kB\"\n * ```\n *\n */\nexport async function getBundleStats(\n\toptions: GetBundleStatsOptions,\n): Promise<BundleStats> {\n\tconst {\n\t\tpackage: packageName,\n\t\texports: exportsList,\n\t\texternal: additionalExternals,\n\t\tnoExternal,\n\t\tgzipLevel = 5,\n\t\tregistry,\n\t\tplatform: platformOption = \"auto\",\n\t\tforce = false,\n\t} = options;\n\n\t// Normalize platform.\n\tconst platform = normalizePlatform(\n\t\tplatformOption === \"auto\" ? undefined : platformOption,\n\t);\n\n\t// Parse package specifier.\n\tconst { name: baseName, version: requestedVersion } =\n\t\tparsePackageSpecifier(packageName);\n\n\t// Resolve \"latest\" to actual version for cache key.\n\tlet resolvedVersion = requestedVersion;\n\tif (requestedVersion === \"latest\") {\n\t\tconst { tags } = await fetchVersions({\n\t\t\tpackageName: baseName,\n\t\t\tregistry,\n\t\t});\n\t\tresolvedVersion = tags.latest || requestedVersion;\n\t}\n\n\t// Compute externals for cache key.\n\tconst externals = getExternals(baseName, additionalExternals, noExternal);\n\n\t// Build cache key.\n\tconst cacheKey = normalizeCacheKey({\n\t\tpackageName: baseName,\n\t\tversion: resolvedVersion,\n\t\texports: exportsList,\n\t\tplatform,\n\t\tgzipLevel,\n\t\texternals,\n\t\tnoExternal: noExternal ?? false,\n\t});\n\n\t// Check cache (unless force is set).\n\tif (!force) {\n\t\tconst cached = getCachedResult(cacheKey);\n\t\tif (cached) {\n\t\t\treturn formatBundleStats(cached, true);\n\t\t}\n\t}\n\n\t// Perform the analysis.\n\tconst result = await checkBundleSize({\n\t\tpackageName,\n\t\texports: exportsList,\n\t\tadditionalExternals,\n\t\tnoExternal,\n\t\tgzipLevel,\n\t\tregistry,\n\t\tplatform,\n\t});\n\n\t// Store in cache.\n\tsetCachedResult(cacheKey, result);\n\n\treturn formatBundleStats(result, false);\n}\n\n/**\n * Get bundle size trend across multiple versions of a package.\n *\n * @example\n * ```js\n * import { getBundleTrend } from \"@node-cli/bundlecheck\";\n *\n * const trend = await getBundleTrend({\n * package: \"@mantine/core\",\n * versionCount: 5,\n * });\n *\n * console.log(trend.change?.rawDiffFormatted); // \"+5.2 kB\"\n * ```\n *\n */\nexport async function getBundleTrend(\n\toptions: GetBundleTrendOptions,\n): Promise<BundleTrend> {\n\tconst {\n\t\tpackage: packageName,\n\t\tversionCount = TREND_VERSION_COUNT,\n\t\texports: exportsList,\n\t\texternal: additionalExternals,\n\t\tnoExternal,\n\t\tgzipLevel,\n\t\tregistry,\n\t\tplatform: platformOption = \"auto\",\n\t\tforce = false,\n\t} = options;\n\n\t// Normalize platform.\n\tconst platform = normalizePlatform(\n\t\tplatformOption === \"auto\" ? undefined : platformOption,\n\t);\n\n\t// Parse package name (ignore version if provided).\n\tconst { name: baseName, subpath } = parsePackageSpecifier(packageName);\n\tconst fullPackagePath = subpath ? `${baseName}/${subpath}` : baseName;\n\n\t// Fetch available versions.\n\tconst { versions } = await fetchVersions({\n\t\tpackageName: baseName,\n\t\tregistry,\n\t});\n\n\tif (versions.length === 0) {\n\t\tthrow new Error(`No versions found for package: ${baseName}`);\n\t}\n\n\t// Select versions for trend.\n\tconst trendVersions = selectTrendVersions(versions, versionCount);\n\n\t// Analyze all versions (silently - no console output).\n\tconst results = await analyzeTrend({\n\t\tpackageName: fullPackagePath,\n\t\tversions: trendVersions,\n\t\texports: exportsList,\n\t\tadditionalExternals,\n\t\tnoExternal,\n\t\tgzipLevel,\n\t\tboring: true, // Suppress logging\n\t\tregistry,\n\t\tplatform,\n\t\tforce,\n\t});\n\n\tif (results.length === 0) {\n\t\tthrow new Error(`Failed to analyze any versions for package: ${baseName}`);\n\t}\n\n\t// Format results.\n\tconst formattedVersions: TrendVersionResult[] = results.map((r) => ({\n\t\tversion: r.version,\n\t\trawSize: r.rawSize,\n\t\tgzipSize: r.gzipSize,\n\t\trawSizeFormatted: formatBytes(r.rawSize),\n\t\tgzipSizeFormatted: r.gzipSize !== null ? formatBytes(r.gzipSize) : null,\n\t}));\n\n\t// Calculate change between oldest and newest.\n\tlet change: TrendChange | null = null;\n\tif (results.length > 1) {\n\t\tconst newest = results[0];\n\t\tconst oldest = results[results.length - 1];\n\n\t\tconst rawDiff = newest.rawSize - oldest.rawSize;\n\t\t// Handle division by zero: if oldest size is 0, percent is null.\n\t\tconst rawPercent =\n\t\t\toldest.rawSize === 0 ? null : (rawDiff / oldest.rawSize) * 100;\n\n\t\tlet gzipDiff: number | null = null;\n\t\tlet gzipPercent: number | null = null;\n\t\tlet gzipDiffFormatted: string | null = null;\n\n\t\tif (newest.gzipSize !== null && oldest.gzipSize !== null) {\n\t\t\tgzipDiff = newest.gzipSize - oldest.gzipSize;\n\t\t\t// Handle division by zero: if oldest size is 0, percent is null.\n\t\t\tgzipPercent =\n\t\t\t\toldest.gzipSize === 0 ? null : (gzipDiff / oldest.gzipSize) * 100;\n\t\t\tgzipDiffFormatted =\n\t\t\t\tgzipDiff >= 0\n\t\t\t\t\t? `+${formatBytes(gzipDiff)}`\n\t\t\t\t\t: `-${formatBytes(Math.abs(gzipDiff))}`;\n\t\t}\n\n\t\tchange = {\n\t\t\tfromVersion: oldest.version,\n\t\t\ttoVersion: newest.version,\n\t\t\trawDiff,\n\t\t\trawPercent:\n\t\t\t\trawPercent !== null ? Number.parseFloat(rawPercent.toFixed(1)) : null,\n\t\t\trawDiffFormatted:\n\t\t\t\trawDiff >= 0\n\t\t\t\t\t? `+${formatBytes(rawDiff)}`\n\t\t\t\t\t: `-${formatBytes(Math.abs(rawDiff))}`,\n\t\t\tgzipDiff,\n\t\t\tgzipPercent:\n\t\t\t\tgzipPercent !== null ? Number.parseFloat(gzipPercent.toFixed(1)) : null,\n\t\t\tgzipDiffFormatted,\n\t\t};\n\t}\n\n\treturn {\n\t\tpackageName: fullPackagePath,\n\t\tversions: formattedVersions,\n\t\tchange,\n\t};\n}\n\n/**\n * Get available versions for an npm package.\n *\n * @example\n * ```js\n * import { getPackageVersions } from \"@node-cli/bundlecheck\";\n *\n * const { versions, tags } = await getPackageVersions({\n * package: \"@mantine/core\",\n * });\n *\n * console.log(tags.latest); // \"7.0.0\"\n * ```\n *\n */\nexport async function getPackageVersions(\n\toptions: GetPackageVersionsOptions,\n): Promise<PackageVersions> {\n\tconst { package: packageName, registry } = options;\n\n\tconst result = await fetchVersions({\n\t\tpackageName,\n\t\tregistry,\n\t});\n\n\treturn {\n\t\tversions: result.versions,\n\t\ttags: result.tags,\n\t};\n}\n\n/**\n * =============================================================================\n * Re-exports for advanced usage\n * =============================================================================\n */\n\n/**\n * - Format bytes to human-readable string (e.g., 1024 → \"1 kB\").\n * - Parse a package specifier (e.g., \"@scope/name@1.0.0\" → { name, version,\n * subpath }).\n */\nexport { formatBytes, parsePackageSpecifier } from \"./bundler.js\";\n/**\n * - Clear the bundle cache.\n * - Get the number of cached entries.\n */\nexport { clearCache, getCacheCount } from \"./cache.js\";\n\n/**\n * =============================================================================\n * Internal Helpers\n * =============================================================================\n */\n\n/**\n * Format a BundleResult into a BundleStats object.\n */\nfunction formatBundleStats(\n\tresult: BundleResult,\n\tfromCache: boolean,\n): BundleStats {\n\treturn {\n\t\tpackageName: result.packageName,\n\t\tpackageVersion: result.packageVersion,\n\t\texports: result.exports,\n\t\trawSize: result.rawSize,\n\t\tgzipSize: result.gzipSize,\n\t\tgzipLevel: result.gzipLevel,\n\t\texternals: result.externals,\n\t\tdependencies: result.dependencies,\n\t\tplatform: result.platform,\n\t\trawSizeFormatted: formatBytes(result.rawSize),\n\t\tgzipSizeFormatted:\n\t\t\tresult.gzipSize !== null ? formatBytes(result.gzipSize) : null,\n\t\tfromCache,\n\t};\n}\n"],"names":["checkBundleSize","formatBytes","getExternals","parsePackageSpecifier","getCachedResult","normalizeCacheKey","setCachedResult","normalizePlatform","TREND_VERSION_COUNT","analyzeTrend","selectTrendVersions","fetchPackageVersions","fetchVersions","getBundleStats","options","package","packageName","exports","exportsList","external","additionalExternals","noExternal","gzipLevel","registry","platform","platformOption","force","undefined","name","baseName","version","requestedVersion","resolvedVersion","tags","latest","externals","cacheKey","cached","formatBundleStats","result","getBundleTrend","versionCount","subpath","fullPackagePath","versions","length","Error","trendVersions","results","boring","formattedVersions","map","r","rawSize","gzipSize","rawSizeFormatted","gzipSizeFormatted","change","newest","oldest","rawDiff","rawPercent","gzipDiff","gzipPercent","gzipDiffFormatted","Math","abs","fromVersion","toVersion","Number","parseFloat","toFixed","rawDiffFormatted","getPackageVersions","clearCache","getCacheCount","fromCache","packageVersion","dependencies"],"mappings":"AAAA;;;;;CAKC,GAED,SAECA,eAAe,EACfC,WAAW,EACXC,YAAY,EACZC,qBAAqB,QACf,eAAe;AACtB,SACCC,eAAe,EACfC,iBAAiB,EACjBC,eAAe,QACT,aAAa;AACpB,SAASC,iBAAiB,EAAEC,mBAAmB,QAAQ,gBAAgB;AACvE,SAASC,YAAY,EAAEC,mBAAmB,QAAQ,aAAa;AAC/D,SAASC,wBAAwBC,aAAa,QAAQ,gBAAgB;AA+PtE;;;;CAIC,GAED;;;;;;;;;;;;;;;CAeC,GACD,OAAO,eAAeC,eACrBC,OAA8B;IAE9B,MAAM,EACLC,SAASC,WAAW,EACpBC,SAASC,WAAW,EACpBC,UAAUC,mBAAmB,EAC7BC,UAAU,EACVC,YAAY,CAAC,EACbC,QAAQ,EACRC,UAAUC,iBAAiB,MAAM,EACjCC,QAAQ,KAAK,EACb,GAAGZ;IAEJ,sBAAsB;IACtB,MAAMU,WAAWjB,kBAChBkB,mBAAmB,SAASE,YAAYF;IAGzC,2BAA2B;IAC3B,MAAM,EAAEG,MAAMC,QAAQ,EAAEC,SAASC,gBAAgB,EAAE,GAClD5B,sBAAsBa;IAEvB,oDAAoD;IACpD,IAAIgB,kBAAkBD;IACtB,IAAIA,qBAAqB,UAAU;QAClC,MAAM,EAAEE,IAAI,EAAE,GAAG,MAAMrB,cAAc;YACpCI,aAAaa;YACbN;QACD;QACAS,kBAAkBC,KAAKC,MAAM,IAAIH;IAClC;IAEA,mCAAmC;IACnC,MAAMI,YAAYjC,aAAa2B,UAAUT,qBAAqBC;IAE9D,mBAA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AAK,OAAOrD,YAAYsC,OAAOe,QAAQ,IAAI;QAC3DsB;IACD;AACD"}
|
package/dist/trend.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export type TrendResult = {
|
|
2
2
|
version: string;
|
|
3
3
|
rawSize: number;
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Gzip size in bytes, or null for node platform.
|
|
6
|
+
*/
|
|
5
7
|
gzipSize: number | null;
|
|
6
8
|
};
|
|
7
9
|
export type TrendOptions = {
|
|
@@ -13,22 +15,26 @@ export type TrendOptions = {
|
|
|
13
15
|
gzipLevel?: number;
|
|
14
16
|
boring?: boolean;
|
|
15
17
|
registry?: string;
|
|
16
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Target platform. If undefined, auto-detects from package.json engines.
|
|
20
|
+
*/
|
|
17
21
|
platform?: "browser" | "node";
|
|
18
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* Bypass cache and force re-fetch/re-calculation.
|
|
24
|
+
*/
|
|
19
25
|
force?: boolean;
|
|
20
26
|
};
|
|
21
27
|
/**
|
|
22
|
-
* Select versions for trend analysis
|
|
23
|
-
*
|
|
24
|
-
*
|
|
28
|
+
* Select versions for trend analysis Returns the most recent stable versions
|
|
29
|
+
* (newest first) Filters out prerelease versions (canary, alpha, beta, rc,
|
|
30
|
+
* etc.)
|
|
25
31
|
*/
|
|
26
32
|
export declare function selectTrendVersions(allVersions: string[], count?: number): string[];
|
|
27
33
|
/**
|
|
28
|
-
* Analyze bundle size trend across multiple versions
|
|
34
|
+
* Analyze bundle size trend across multiple versions.
|
|
29
35
|
*/
|
|
30
36
|
export declare function analyzeTrend(options: TrendOptions): Promise<TrendResult[]>;
|
|
31
37
|
/**
|
|
32
|
-
* Render a bar graph showing bundle size trend
|
|
38
|
+
* Render a bar graph showing bundle size trend.
|
|
33
39
|
*/
|
|
34
40
|
export declare function renderTrendGraph(packageName: string, results: TrendResult[], boring?: boolean): string[];
|