@node-cli/bundlecheck 1.0.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.
@@ -0,0 +1,455 @@
1
+ import { execSync } from "node:child_process";
2
+ import fs from "node:fs";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import { promisify } from "node:util";
6
+ import zlib from "node:zlib";
7
+ import * as esbuild from "esbuild";
8
+ import { DEFAULT_EXTERNALS } from "./defaults.js";
9
+ const gzipAsync = promisify(zlib.gzip);
10
+ /**
11
+ * Escape special regex characters in a string
12
+ */ function escapeRegExp(str) {
13
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
14
+ }
15
+ /**
16
+ * Parse a package specifier to extract name, version, and subpath
17
+ * Handles:
18
+ * - @scope/package@1.0.0
19
+ * - @scope/package/subpath@1.0.0
20
+ * - @scope/package/subpath
21
+ * - package/subpath@1.0.0
22
+ */ export function parsePackageSpecifier(specifier) {
23
+ let workingSpec = specifier;
24
+ let version = "latest";
25
+ // Handle scoped packages (@scope/name...)
26
+ if (workingSpec.startsWith("@")) {
27
+ // Find the second @ which would separate version
28
+ const secondAtIndex = workingSpec.indexOf("@", 1);
29
+ if (secondAtIndex !== -1) {
30
+ version = workingSpec.substring(secondAtIndex + 1);
31
+ workingSpec = workingSpec.substring(0, secondAtIndex);
32
+ }
33
+ // Now workingSpec is like @scope/name or @scope/name/subpath
34
+ // Split by / and check if there are more than 2 parts
35
+ const parts = workingSpec.split("/");
36
+ if (parts.length > 2) {
37
+ // Has subpath: @scope/name/subpath/more
38
+ const name = `${parts[0]}/${parts[1]}`;
39
+ const subpath = parts.slice(2).join("/");
40
+ return {
41
+ name,
42
+ version,
43
+ subpath
44
+ };
45
+ }
46
+ // No subpath: @scope/name
47
+ return {
48
+ name: workingSpec,
49
+ version
50
+ };
51
+ }
52
+ // Handle non-scoped packages (name@version or name/subpath@version)
53
+ const atIndex = workingSpec.indexOf("@");
54
+ if (atIndex !== -1) {
55
+ version = workingSpec.substring(atIndex + 1);
56
+ workingSpec = workingSpec.substring(0, atIndex);
57
+ }
58
+ // Check for subpath in non-scoped packages
59
+ const slashIndex = workingSpec.indexOf("/");
60
+ if (slashIndex !== -1) {
61
+ const name = workingSpec.substring(0, slashIndex);
62
+ const subpath = workingSpec.substring(slashIndex + 1);
63
+ return {
64
+ name,
65
+ version,
66
+ subpath
67
+ };
68
+ }
69
+ return {
70
+ name: workingSpec,
71
+ version
72
+ };
73
+ }
74
+ /**
75
+ * Format bytes to human-readable string
76
+ */ export function formatBytes(bytes) {
77
+ if (bytes === 0) {
78
+ return "0 B";
79
+ }
80
+ const k = 1024;
81
+ const sizes = [
82
+ "B",
83
+ "kB",
84
+ "MB",
85
+ "GB"
86
+ ];
87
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
88
+ return `${Number.parseFloat((bytes / k ** i).toFixed(2))} ${sizes[i]}`;
89
+ }
90
+ /**
91
+ * Create a temporary directory for bundling
92
+ */ function createTempDir() {
93
+ const tmpDir = path.join(os.tmpdir(), `bundlecheck-${Date.now()}`);
94
+ fs.mkdirSync(tmpDir, {
95
+ recursive: true
96
+ });
97
+ return tmpDir;
98
+ }
99
+ /**
100
+ * Clean up temporary directory
101
+ */ function cleanupTempDir(tmpDir) {
102
+ try {
103
+ fs.rmSync(tmpDir, {
104
+ recursive: true,
105
+ force: true
106
+ });
107
+ } catch {
108
+ // Ignore cleanup errors
109
+ }
110
+ }
111
+ /**
112
+ * Check if pnpm is available
113
+ */ function isPnpmAvailable() {
114
+ try {
115
+ execSync("pnpm --version", {
116
+ stdio: "pipe"
117
+ });
118
+ return true;
119
+ } catch {
120
+ return false;
121
+ }
122
+ }
123
+ // Cache the result of pnpm availability check
124
+ let usePnpm = null;
125
+ /**
126
+ * Get the install command (pnpm preferred, npm fallback)
127
+ */ function getInstallCommand() {
128
+ if (usePnpm === null) {
129
+ usePnpm = isPnpmAvailable();
130
+ }
131
+ if (usePnpm) {
132
+ return "pnpm install --ignore-scripts --no-frozen-lockfile";
133
+ }
134
+ return "npm install --legacy-peer-deps --ignore-scripts";
135
+ }
136
+ /**
137
+ * Generate the entry file content based on package, subpath, and exports
138
+ */ function generateEntryContent(options) {
139
+ const { packageName, subpath, exports, allSubpaths, exportToSubpath } = options;
140
+ // If we have exports mapped to different subpaths
141
+ if (exportToSubpath && exportToSubpath.size > 0) {
142
+ // Group exports by subpath
143
+ const subpathToExports = new Map();
144
+ for (const [exportName, sp] of exportToSubpath){
145
+ const existing = subpathToExports.get(sp) || [];
146
+ existing.push(exportName);
147
+ subpathToExports.set(sp, existing);
148
+ }
149
+ // Generate imports for each subpath
150
+ const lines = [];
151
+ const allExportNames = [];
152
+ for (const [sp, exportNames] of subpathToExports){
153
+ const importPath = `${packageName}/${sp}`;
154
+ const names = exportNames.join(", ");
155
+ lines.push(`import { ${names} } from "${importPath}";`);
156
+ allExportNames.push(...exportNames);
157
+ }
158
+ lines.push(`export { ${allExportNames.join(", ")} };`);
159
+ return lines.join("\n") + "\n";
160
+ }
161
+ // If we have specific exports to import
162
+ if (exports && exports.length > 0) {
163
+ // Determine the import path
164
+ const importPath = subpath ? `${packageName}/${subpath}` : packageName;
165
+ const importNames = exports.join(", ");
166
+ return `import { ${importNames} } from "${importPath}";\nexport { ${importNames} };\n`;
167
+ }
168
+ // If we have a specific subpath (but no specific exports)
169
+ if (subpath) {
170
+ const importPath = `${packageName}/${subpath}`;
171
+ return `import * as pkg from "${importPath}";\nexport default pkg;\n`;
172
+ }
173
+ // If package has subpath exports only (no main entry), import all subpaths
174
+ if (allSubpaths && allSubpaths.length > 0) {
175
+ const imports = allSubpaths.map((sp, i)=>`import * as sub${i} from "${packageName}/${sp}";\nexport { sub${i} };`).join("\n");
176
+ return imports + "\n";
177
+ }
178
+ // Default: import everything from main entry
179
+ return `import * as pkg from "${packageName}";\nexport default pkg;\n`;
180
+ }
181
+ /**
182
+ * Get externals list based on options
183
+ */ function getExternals(packageName, externals, noExternal) {
184
+ if (noExternal) {
185
+ return [];
186
+ }
187
+ // Start with default externals (react, react-dom)
188
+ let result = [
189
+ ...DEFAULT_EXTERNALS
190
+ ];
191
+ // If checking react or react-dom themselves, don't mark them as external
192
+ if (packageName === "react") {
193
+ result = result.filter((e)=>e !== "react");
194
+ } else if (packageName === "react-dom") {
195
+ result = result.filter((e)=>e !== "react-dom");
196
+ }
197
+ // Add any additional externals
198
+ if (externals && externals.length > 0) {
199
+ result = [
200
+ ...new Set([
201
+ ...result,
202
+ ...externals
203
+ ])
204
+ ];
205
+ }
206
+ return result;
207
+ }
208
+ /**
209
+ * Get version, dependencies, peer dependencies, and exports from an installed package
210
+ */ function getPackageInfo(tmpDir, packageName) {
211
+ try {
212
+ // Handle scoped packages - the package name in node_modules
213
+ const pkgJsonPath = path.join(tmpDir, "node_modules", packageName, "package.json");
214
+ if (fs.existsSync(pkgJsonPath)) {
215
+ const pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, "utf-8"));
216
+ // Check if package has a main entry point
217
+ const hasMainEntry = Boolean(pkgJson.main || pkgJson.module || pkgJson.exports?.["."] || pkgJson.exports?.["./index"] || !pkgJson.exports && !pkgJson.main && !pkgJson.module);
218
+ return {
219
+ version: pkgJson.version || "unknown",
220
+ dependencies: pkgJson.dependencies || {},
221
+ peerDependencies: pkgJson.peerDependencies || {},
222
+ exports: pkgJson.exports || null,
223
+ hasMainEntry
224
+ };
225
+ }
226
+ } catch {
227
+ // Ignore errors reading package info
228
+ }
229
+ return {
230
+ version: "unknown",
231
+ dependencies: {},
232
+ peerDependencies: {},
233
+ exports: null,
234
+ hasMainEntry: true
235
+ };
236
+ }
237
+ /**
238
+ * Extract subpath export names from package exports field
239
+ * Returns array of subpaths like ["header", "body", "datagrid"]
240
+ */ function getSubpathExports(exports) {
241
+ if (!exports) {
242
+ return [];
243
+ }
244
+ const subpaths = [];
245
+ for (const key of Object.keys(exports)){
246
+ // Skip the main entry point and package.json
247
+ if (key === "." || key === "./package.json") {
248
+ continue;
249
+ }
250
+ // Remove leading "./" to get subpath name
251
+ if (key.startsWith("./")) {
252
+ subpaths.push(key.substring(2));
253
+ }
254
+ }
255
+ return subpaths;
256
+ }
257
+ /**
258
+ * Find which subpath(s) export the given component names
259
+ * Reads type definition files or JS files to find the exports
260
+ */ function findSubpathsForExports(tmpDir, packageName, exports, componentNames) {
261
+ const packageDir = path.join(tmpDir, "node_modules", packageName);
262
+ const exportToSubpath = new Map();
263
+ for (const [subpathKey, subpathValue] of Object.entries(exports)){
264
+ // Skip main entry and package.json
265
+ if (subpathKey === "." || subpathKey === "./package.json") {
266
+ continue;
267
+ }
268
+ // Get the types or import path
269
+ let filePath;
270
+ if (typeof subpathValue === "object" && subpathValue !== null) {
271
+ // Prefer types file for more accurate export detection
272
+ filePath = subpathValue.types || subpathValue.import;
273
+ } else if (typeof subpathValue === "string") {
274
+ filePath = subpathValue;
275
+ }
276
+ if (!filePath) {
277
+ continue;
278
+ }
279
+ // Resolve the file path
280
+ const fullPath = path.join(packageDir, filePath);
281
+ try {
282
+ if (fs.existsSync(fullPath)) {
283
+ const content = fs.readFileSync(fullPath, "utf-8");
284
+ const subpath = subpathKey.startsWith("./") ? subpathKey.substring(2) : subpathKey;
285
+ // Check each component name
286
+ for (const name of componentNames){
287
+ // Skip if already found
288
+ if (exportToSubpath.has(name)) {
289
+ continue;
290
+ }
291
+ // Escape regex special characters in the name to prevent injection
292
+ const escapedName = escapeRegExp(name);
293
+ // Look for various export patterns
294
+ const patterns = [
295
+ new RegExp(`export\\s*\\{[^}]*\\b${escapedName}\\b[^}]*\\}`, "m"),
296
+ new RegExp(`export\\s+declare\\s+(?:const|function|class)\\s+${escapedName}\\b`, "m"),
297
+ new RegExp(`export\\s+(?:const|function|class)\\s+${escapedName}\\b`, "m")
298
+ ];
299
+ if (patterns.some((pattern)=>pattern.test(content))) {
300
+ exportToSubpath.set(name, subpath);
301
+ }
302
+ }
303
+ }
304
+ } catch {
305
+ // Ignore read errors, continue to next subpath
306
+ }
307
+ }
308
+ // Check if all exports were found
309
+ if (exportToSubpath.size !== componentNames.length) {
310
+ return {}; // Not all exports found
311
+ }
312
+ // Check if all exports are from the same subpath
313
+ const subpaths = new Set(exportToSubpath.values());
314
+ if (subpaths.size === 1) {
315
+ return {
316
+ singleSubpath: [
317
+ ...subpaths
318
+ ][0]
319
+ };
320
+ }
321
+ // Multiple subpaths needed
322
+ return {
323
+ exportToSubpath
324
+ };
325
+ }
326
+ /**
327
+ * Check the bundle size of an npm package
328
+ */ export async function checkBundleSize(options) {
329
+ const { packageName: packageSpecifier, exports, additionalExternals, noExternal, gzipLevel = 5 } = options;
330
+ // Parse the package specifier to extract name, version, and subpath
331
+ const { name: packageName, version: requestedVersion, subpath } = parsePackageSpecifier(packageSpecifier);
332
+ const tmpDir = createTempDir();
333
+ try {
334
+ // Create initial package.json
335
+ const packageJson = {
336
+ name: "bundlecheck-temp",
337
+ version: "1.0.0",
338
+ type: "module",
339
+ dependencies: {
340
+ [packageName]: requestedVersion
341
+ }
342
+ };
343
+ fs.writeFileSync(path.join(tmpDir, "package.json"), JSON.stringify(packageJson, null, 2));
344
+ // Install the main package (try pnpm first, fallback to npm)
345
+ const installCmd = getInstallCommand();
346
+ execSync(installCmd, {
347
+ cwd: tmpDir,
348
+ stdio: "pipe"
349
+ });
350
+ // Get package info (version, dependencies, peer dependencies, exports)
351
+ const pkgInfo = getPackageInfo(tmpDir, packageName);
352
+ const peerDepKeys = Object.keys(pkgInfo.peerDependencies);
353
+ // Collect all dependency names (prod + peer)
354
+ const allDependencies = [
355
+ ...new Set([
356
+ ...Object.keys(pkgInfo.dependencies),
357
+ ...peerDepKeys
358
+ ])
359
+ ].sort();
360
+ if (peerDepKeys.length > 0) {
361
+ // Add peer dependencies to package.json
362
+ for (const dep of peerDepKeys){
363
+ // Use the version range from peer dependencies
364
+ packageJson.dependencies[dep] = pkgInfo.peerDependencies[dep];
365
+ }
366
+ // Update package.json and reinstall
367
+ fs.writeFileSync(path.join(tmpDir, "package.json"), JSON.stringify(packageJson, null, 2));
368
+ execSync(installCmd, {
369
+ cwd: tmpDir,
370
+ stdio: "pipe"
371
+ });
372
+ }
373
+ // Determine if we need to use all subpath exports or find the right subpath(s)
374
+ let allSubpaths;
375
+ let resolvedSubpath = subpath;
376
+ let exportToSubpath;
377
+ if (!subpath && !pkgInfo.hasMainEntry && pkgInfo.exports) {
378
+ if (exports && exports.length > 0) {
379
+ // User specified exports but no subpath - try to find the right subpath(s)
380
+ const mapping = findSubpathsForExports(tmpDir, packageName, pkgInfo.exports, exports);
381
+ if (mapping.singleSubpath) {
382
+ // All exports from the same subpath
383
+ resolvedSubpath = mapping.singleSubpath;
384
+ } else if (mapping.exportToSubpath) {
385
+ // Exports from multiple subpaths
386
+ exportToSubpath = mapping.exportToSubpath;
387
+ }
388
+ }
389
+ // If still no subpath resolved and no mapping, bundle all subpaths
390
+ if (!resolvedSubpath && !exportToSubpath) {
391
+ allSubpaths = getSubpathExports(pkgInfo.exports);
392
+ }
393
+ }
394
+ // Create entry file with appropriate content
395
+ const entryContent = generateEntryContent({
396
+ packageName,
397
+ subpath: resolvedSubpath,
398
+ exports,
399
+ allSubpaths,
400
+ exportToSubpath
401
+ });
402
+ const entryFile = path.join(tmpDir, "entry.js");
403
+ fs.writeFileSync(entryFile, entryContent);
404
+ // Get externals
405
+ const externals = getExternals(packageName, additionalExternals, noExternal);
406
+ // Bundle with esbuild
407
+ const result = await esbuild.build({
408
+ entryPoints: [
409
+ entryFile
410
+ ],
411
+ bundle: true,
412
+ write: false,
413
+ format: "esm",
414
+ platform: "browser",
415
+ target: "es2020",
416
+ minify: true,
417
+ treeShaking: true,
418
+ external: externals,
419
+ metafile: true
420
+ });
421
+ // Get raw size
422
+ const bundleContent = result.outputFiles[0].contents;
423
+ const rawSize = bundleContent.length;
424
+ // Gzip the bundle
425
+ const gzipped = await gzipAsync(Buffer.from(bundleContent), {
426
+ level: gzipLevel
427
+ });
428
+ const gzipSize = gzipped.length;
429
+ // Determine the display name
430
+ let displayName = packageName;
431
+ if (resolvedSubpath) {
432
+ displayName = `${packageName}/${resolvedSubpath}`;
433
+ } else if (exportToSubpath && exportToSubpath.size > 0) {
434
+ // Multiple subpaths - show them all
435
+ const uniqueSubpaths = [
436
+ ...new Set(exportToSubpath.values())
437
+ ].sort();
438
+ displayName = `${packageName}/{${uniqueSubpaths.join(", ")}}`;
439
+ }
440
+ return {
441
+ packageName: displayName,
442
+ packageVersion: pkgInfo.version,
443
+ exports: exports || [],
444
+ rawSize,
445
+ gzipSize,
446
+ gzipLevel,
447
+ externals,
448
+ dependencies: allDependencies
449
+ };
450
+ } finally{
451
+ cleanupTempDir(tmpDir);
452
+ }
453
+ }
454
+
455
+ //# sourceMappingURL=bundler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/bundler.ts"],"sourcesContent":["import { execSync } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { promisify } from \"node:util\";\nimport zlib from \"node:zlib\";\nimport * as esbuild from \"esbuild\";\nimport { DEFAULT_EXTERNALS } from \"./defaults.js\";\n\nconst gzipAsync = promisify(zlib.gzip);\n\n/**\n * Escape special regex characters in a string\n */\nfunction escapeRegExp(str: string): string {\n\treturn str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\nexport type ParsedPackage = {\n\tname: string;\n\tversion: string;\n\tsubpath?: string;\n};\n\n/**\n * Parse a package specifier to extract name, version, and subpath\n * Handles:\n * - @scope/package@1.0.0\n * - @scope/package/subpath@1.0.0\n * - @scope/package/subpath\n * - package/subpath@1.0.0\n */\nexport function parsePackageSpecifier(specifier: string): ParsedPackage {\n\tlet workingSpec = specifier;\n\tlet version = \"latest\";\n\n\t// Handle scoped packages (@scope/name...)\n\tif (workingSpec.startsWith(\"@\")) {\n\t\t// Find the second @ which would separate version\n\t\tconst secondAtIndex = workingSpec.indexOf(\"@\", 1);\n\t\tif (secondAtIndex !== -1) {\n\t\t\tversion = workingSpec.substring(secondAtIndex + 1);\n\t\t\tworkingSpec = workingSpec.substring(0, secondAtIndex);\n\t\t}\n\n\t\t// Now workingSpec is like @scope/name or @scope/name/subpath\n\t\t// Split by / and check if there are more than 2 parts\n\t\tconst parts = workingSpec.split(\"/\");\n\t\tif (parts.length > 2) {\n\t\t\t// Has subpath: @scope/name/subpath/more\n\t\t\tconst name = `${parts[0]}/${parts[1]}`;\n\t\t\tconst subpath = parts.slice(2).join(\"/\");\n\t\t\treturn { name, version, subpath };\n\t\t}\n\t\t// No subpath: @scope/name\n\t\treturn { name: workingSpec, version };\n\t}\n\n\t// Handle non-scoped packages (name@version or name/subpath@version)\n\tconst atIndex = workingSpec.indexOf(\"@\");\n\tif (atIndex !== -1) {\n\t\tversion = workingSpec.substring(atIndex + 1);\n\t\tworkingSpec = workingSpec.substring(0, atIndex);\n\t}\n\n\t// Check for subpath in non-scoped packages\n\tconst slashIndex = workingSpec.indexOf(\"/\");\n\tif (slashIndex !== -1) {\n\t\tconst name = workingSpec.substring(0, slashIndex);\n\t\tconst subpath = workingSpec.substring(slashIndex + 1);\n\t\treturn { name, version, subpath };\n\t}\n\n\treturn { name: workingSpec, version };\n}\n\nexport type BundleOptions = {\n\tpackageName: string;\n\texports?: string[];\n\tadditionalExternals?: string[];\n\tnoExternal?: boolean;\n\tgzipLevel?: number;\n};\n\nexport type BundleResult = {\n\tpackageName: string;\n\tpackageVersion: string;\n\texports: string[];\n\trawSize: number;\n\tgzipSize: number;\n\tgzipLevel: number;\n\texternals: string[];\n\tdependencies: string[];\n};\n\n/**\n * Format bytes to human-readable string\n */\nexport function formatBytes(bytes: number): string {\n\tif (bytes === 0) {\n\t\treturn \"0 B\";\n\t}\n\tconst k = 1024;\n\tconst sizes = [\"B\", \"kB\", \"MB\", \"GB\"];\n\tconst i = Math.floor(Math.log(bytes) / Math.log(k));\n\treturn `${Number.parseFloat((bytes / k ** i).toFixed(2))} ${sizes[i]}`;\n}\n\n/**\n * Create a temporary directory for bundling\n */\nfunction createTempDir(): string {\n\tconst tmpDir = path.join(os.tmpdir(), `bundlecheck-${Date.now()}`);\n\tfs.mkdirSync(tmpDir, { recursive: true });\n\treturn tmpDir;\n}\n\n/**\n * Clean up temporary directory\n */\nfunction cleanupTempDir(tmpDir: string): void {\n\ttry {\n\t\tfs.rmSync(tmpDir, { recursive: true, force: true });\n\t} catch {\n\t\t// Ignore cleanup errors\n\t}\n}\n\n/**\n * Check if pnpm is available\n */\nfunction isPnpmAvailable(): boolean {\n\ttry {\n\t\texecSync(\"pnpm --version\", { stdio: \"pipe\" });\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n// Cache the result of pnpm availability check\nlet usePnpm: boolean | null = null;\n\n/**\n * Get the install command (pnpm preferred, npm fallback)\n */\nfunction getInstallCommand(): string {\n\tif (usePnpm === null) {\n\t\tusePnpm = isPnpmAvailable();\n\t}\n\n\tif (usePnpm) {\n\t\treturn \"pnpm install --ignore-scripts --no-frozen-lockfile\";\n\t}\n\treturn \"npm install --legacy-peer-deps --ignore-scripts\";\n}\n\nexport type EntryContentOptions = {\n\tpackageName: string;\n\tsubpath?: string;\n\texports?: string[];\n\tallSubpaths?: string[];\n\texportToSubpath?: Map<string, string>;\n};\n\n/**\n * Generate the entry file content based on package, subpath, and exports\n */\nfunction generateEntryContent(options: EntryContentOptions): string {\n\tconst { packageName, subpath, exports, allSubpaths, exportToSubpath } =\n\t\toptions;\n\n\t// If we have exports mapped to different subpaths\n\tif (exportToSubpath && exportToSubpath.size > 0) {\n\t\t// Group exports by subpath\n\t\tconst subpathToExports = new Map<string, string[]>();\n\t\tfor (const [exportName, sp] of exportToSubpath) {\n\t\t\tconst existing = subpathToExports.get(sp) || [];\n\t\t\texisting.push(exportName);\n\t\t\tsubpathToExports.set(sp, existing);\n\t\t}\n\n\t\t// Generate imports for each subpath\n\t\tconst lines: string[] = [];\n\t\tconst allExportNames: string[] = [];\n\n\t\tfor (const [sp, exportNames] of subpathToExports) {\n\t\t\tconst importPath = `${packageName}/${sp}`;\n\t\t\tconst names = exportNames.join(\", \");\n\t\t\tlines.push(`import { ${names} } from \"${importPath}\";`);\n\t\t\tallExportNames.push(...exportNames);\n\t\t}\n\n\t\tlines.push(`export { ${allExportNames.join(\", \")} };`);\n\t\treturn lines.join(\"\\n\") + \"\\n\";\n\t}\n\n\t// If we have specific exports to import\n\tif (exports && exports.length > 0) {\n\t\t// Determine the import path\n\t\tconst importPath = subpath ? `${packageName}/${subpath}` : packageName;\n\t\tconst importNames = exports.join(\", \");\n\t\treturn `import { ${importNames} } from \"${importPath}\";\\nexport { ${importNames} };\\n`;\n\t}\n\n\t// If we have a specific subpath (but no specific exports)\n\tif (subpath) {\n\t\tconst importPath = `${packageName}/${subpath}`;\n\t\treturn `import * as pkg from \"${importPath}\";\\nexport default pkg;\\n`;\n\t}\n\n\t// If package has subpath exports only (no main entry), import all subpaths\n\tif (allSubpaths && allSubpaths.length > 0) {\n\t\tconst imports = allSubpaths\n\t\t\t.map(\n\t\t\t\t(sp, i) =>\n\t\t\t\t\t`import * as sub${i} from \"${packageName}/${sp}\";\\nexport { sub${i} };`,\n\t\t\t)\n\t\t\t.join(\"\\n\");\n\t\treturn imports + \"\\n\";\n\t}\n\n\t// Default: import everything from main entry\n\treturn `import * as pkg from \"${packageName}\";\\nexport default pkg;\\n`;\n}\n\n/**\n * Get externals list based on options\n */\nfunction getExternals(\n\tpackageName: string,\n\texternals?: string[],\n\tnoExternal?: boolean,\n): string[] {\n\tif (noExternal) {\n\t\treturn [];\n\t}\n\n\t// Start with default externals (react, react-dom)\n\tlet result = [...DEFAULT_EXTERNALS];\n\n\t// If checking react or react-dom themselves, don't mark them as external\n\tif (packageName === \"react\") {\n\t\tresult = result.filter((e) => e !== \"react\");\n\t} else if (packageName === \"react-dom\") {\n\t\tresult = result.filter((e) => e !== \"react-dom\");\n\t}\n\n\t// Add any additional externals\n\tif (externals && externals.length > 0) {\n\t\tresult = [...new Set([...result, ...externals])];\n\t}\n\n\treturn result;\n}\n\nexport type PackageExports = Record<\n\tstring,\n\tstring | { import?: string; types?: string }\n>;\n\nexport type PackageInfo = {\n\tversion: string;\n\tdependencies: Record<string, string>;\n\tpeerDependencies: Record<string, string>;\n\texports: PackageExports | null;\n\thasMainEntry: boolean;\n};\n\n/**\n * Get version, dependencies, peer dependencies, and exports from an installed package\n */\nfunction getPackageInfo(tmpDir: string, packageName: string): PackageInfo {\n\ttry {\n\t\t// Handle scoped packages - the package name in node_modules\n\t\tconst pkgJsonPath = path.join(\n\t\t\ttmpDir,\n\t\t\t\"node_modules\",\n\t\t\tpackageName,\n\t\t\t\"package.json\",\n\t\t);\n\t\tif (fs.existsSync(pkgJsonPath)) {\n\t\t\tconst pkgJson = JSON.parse(fs.readFileSync(pkgJsonPath, \"utf-8\"));\n\n\t\t\t// Check if package has a main entry point\n\t\t\tconst hasMainEntry = Boolean(\n\t\t\t\tpkgJson.main ||\n\t\t\t\t\tpkgJson.module ||\n\t\t\t\t\tpkgJson.exports?.[\".\"] ||\n\t\t\t\t\tpkgJson.exports?.[\"./index\"] ||\n\t\t\t\t\t(!pkgJson.exports && !pkgJson.main && !pkgJson.module),\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tversion: pkgJson.version || \"unknown\",\n\t\t\t\tdependencies: pkgJson.dependencies || {},\n\t\t\t\tpeerDependencies: pkgJson.peerDependencies || {},\n\t\t\t\texports: pkgJson.exports || null,\n\t\t\t\thasMainEntry,\n\t\t\t};\n\t\t}\n\t} catch {\n\t\t// Ignore errors reading package info\n\t}\n\treturn {\n\t\tversion: \"unknown\",\n\t\tdependencies: {},\n\t\tpeerDependencies: {},\n\t\texports: null,\n\t\thasMainEntry: true,\n\t};\n}\n\n/**\n * Extract subpath export names from package exports field\n * Returns array of subpaths like [\"header\", \"body\", \"datagrid\"]\n */\nfunction getSubpathExports(exports: PackageExports | null): string[] {\n\tif (!exports) {\n\t\treturn [];\n\t}\n\n\tconst subpaths: string[] = [];\n\tfor (const key of Object.keys(exports)) {\n\t\t// Skip the main entry point and package.json\n\t\tif (key === \".\" || key === \"./package.json\") {\n\t\t\tcontinue;\n\t\t}\n\t\t// Remove leading \"./\" to get subpath name\n\t\tif (key.startsWith(\"./\")) {\n\t\t\tsubpaths.push(key.substring(2));\n\t\t}\n\t}\n\treturn subpaths;\n}\n\n/**\n * Result of finding subpaths for exports\n */\ntype SubpathMapping = {\n\t// Single subpath if all exports are from the same subpath\n\tsingleSubpath?: string;\n\t// Map of export name to subpath for multiple subpaths\n\texportToSubpath?: Map<string, string>;\n};\n\n/**\n * Find which subpath(s) export the given component names\n * Reads type definition files or JS files to find the exports\n */\nfunction findSubpathsForExports(\n\ttmpDir: string,\n\tpackageName: string,\n\texports: PackageExports,\n\tcomponentNames: string[],\n): SubpathMapping {\n\tconst packageDir = path.join(tmpDir, \"node_modules\", packageName);\n\tconst exportToSubpath = new Map<string, string>();\n\n\tfor (const [subpathKey, subpathValue] of Object.entries(exports)) {\n\t\t// Skip main entry and package.json\n\t\tif (subpathKey === \".\" || subpathKey === \"./package.json\") {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Get the types or import path\n\t\tlet filePath: string | undefined;\n\t\tif (typeof subpathValue === \"object\" && subpathValue !== null) {\n\t\t\t// Prefer types file for more accurate export detection\n\t\t\tfilePath = subpathValue.types || subpathValue.import;\n\t\t} else if (typeof subpathValue === \"string\") {\n\t\t\tfilePath = subpathValue;\n\t\t}\n\n\t\tif (!filePath) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// Resolve the file path\n\t\tconst fullPath = path.join(packageDir, filePath);\n\n\t\ttry {\n\t\t\tif (fs.existsSync(fullPath)) {\n\t\t\t\tconst content = fs.readFileSync(fullPath, \"utf-8\");\n\t\t\t\tconst subpath = subpathKey.startsWith(\"./\")\n\t\t\t\t\t? subpathKey.substring(2)\n\t\t\t\t\t: subpathKey;\n\n\t\t\t\t// Check each component name\n\t\t\t\tfor (const name of componentNames) {\n\t\t\t\t\t// Skip if already found\n\t\t\t\t\tif (exportToSubpath.has(name)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Escape regex special characters in the name to prevent injection\n\t\t\t\t\tconst escapedName = escapeRegExp(name);\n\n\t\t\t\t\t// Look for various export patterns\n\t\t\t\t\tconst patterns = [\n\t\t\t\t\t\tnew RegExp(`export\\\\s*\\\\{[^}]*\\\\b${escapedName}\\\\b[^}]*\\\\}`, \"m\"),\n\t\t\t\t\t\tnew RegExp(\n\t\t\t\t\t\t\t`export\\\\s+declare\\\\s+(?:const|function|class)\\\\s+${escapedName}\\\\b`,\n\t\t\t\t\t\t\t\"m\",\n\t\t\t\t\t\t),\n\t\t\t\t\t\tnew RegExp(\n\t\t\t\t\t\t\t`export\\\\s+(?:const|function|class)\\\\s+${escapedName}\\\\b`,\n\t\t\t\t\t\t\t\"m\",\n\t\t\t\t\t\t),\n\t\t\t\t\t];\n\n\t\t\t\t\tif (patterns.some((pattern) => pattern.test(content))) {\n\t\t\t\t\t\texportToSubpath.set(name, subpath);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {\n\t\t\t// Ignore read errors, continue to next subpath\n\t\t}\n\t}\n\n\t// Check if all exports were found\n\tif (exportToSubpath.size !== componentNames.length) {\n\t\treturn {}; // Not all exports found\n\t}\n\n\t// Check if all exports are from the same subpath\n\tconst subpaths = new Set(exportToSubpath.values());\n\tif (subpaths.size === 1) {\n\t\treturn { singleSubpath: [...subpaths][0] };\n\t}\n\n\t// Multiple subpaths needed\n\treturn { exportToSubpath };\n}\n\n/**\n * Check the bundle size of an npm package\n */\nexport async function checkBundleSize(\n\toptions: BundleOptions,\n): Promise<BundleResult> {\n\tconst {\n\t\tpackageName: packageSpecifier,\n\t\texports,\n\t\tadditionalExternals,\n\t\tnoExternal,\n\t\tgzipLevel = 5,\n\t} = options;\n\n\t// Parse the package specifier to extract name, version, and subpath\n\tconst {\n\t\tname: packageName,\n\t\tversion: requestedVersion,\n\t\tsubpath,\n\t} = parsePackageSpecifier(packageSpecifier);\n\n\tconst tmpDir = createTempDir();\n\n\ttry {\n\t\t// Create initial package.json\n\t\tconst packageJson: {\n\t\t\tname: string;\n\t\t\tversion: string;\n\t\t\ttype: string;\n\t\t\tdependencies: Record<string, string>;\n\t\t} = {\n\t\t\tname: \"bundlecheck-temp\",\n\t\t\tversion: \"1.0.0\",\n\t\t\ttype: \"module\",\n\t\t\tdependencies: {\n\t\t\t\t[packageName]: requestedVersion,\n\t\t\t},\n\t\t};\n\n\t\tfs.writeFileSync(\n\t\t\tpath.join(tmpDir, \"package.json\"),\n\t\t\tJSON.stringify(packageJson, null, 2),\n\t\t);\n\n\t\t// Install the main package (try pnpm first, fallback to npm)\n\t\tconst installCmd = getInstallCommand();\n\t\texecSync(installCmd, {\n\t\t\tcwd: tmpDir,\n\t\t\tstdio: \"pipe\",\n\t\t});\n\n\t\t// Get package info (version, dependencies, peer dependencies, exports)\n\t\tconst pkgInfo = getPackageInfo(tmpDir, packageName);\n\t\tconst peerDepKeys = Object.keys(pkgInfo.peerDependencies);\n\n\t\t// Collect all dependency names (prod + peer)\n\t\tconst allDependencies = [\n\t\t\t...new Set([...Object.keys(pkgInfo.dependencies), ...peerDepKeys]),\n\t\t].sort();\n\n\t\tif (peerDepKeys.length > 0) {\n\t\t\t// Add peer dependencies to package.json\n\t\t\tfor (const dep of peerDepKeys) {\n\t\t\t\t// Use the version range from peer dependencies\n\t\t\t\tpackageJson.dependencies[dep] = pkgInfo.peerDependencies[dep];\n\t\t\t}\n\n\t\t\t// Update package.json and reinstall\n\t\t\tfs.writeFileSync(\n\t\t\t\tpath.join(tmpDir, \"package.json\"),\n\t\t\t\tJSON.stringify(packageJson, null, 2),\n\t\t\t);\n\n\t\t\texecSync(installCmd, {\n\t\t\t\tcwd: tmpDir,\n\t\t\t\tstdio: \"pipe\",\n\t\t\t});\n\t\t}\n\n\t\t// Determine if we need to use all subpath exports or find the right subpath(s)\n\t\tlet allSubpaths: string[] | undefined;\n\t\tlet resolvedSubpath = subpath;\n\t\tlet exportToSubpath: Map<string, string> | undefined;\n\n\t\tif (!subpath && !pkgInfo.hasMainEntry && pkgInfo.exports) {\n\t\t\tif (exports && exports.length > 0) {\n\t\t\t\t// User specified exports but no subpath - try to find the right subpath(s)\n\t\t\t\tconst mapping = findSubpathsForExports(\n\t\t\t\t\ttmpDir,\n\t\t\t\t\tpackageName,\n\t\t\t\t\tpkgInfo.exports,\n\t\t\t\t\texports,\n\t\t\t\t);\n\n\t\t\t\tif (mapping.singleSubpath) {\n\t\t\t\t\t// All exports from the same subpath\n\t\t\t\t\tresolvedSubpath = mapping.singleSubpath;\n\t\t\t\t} else if (mapping.exportToSubpath) {\n\t\t\t\t\t// Exports from multiple subpaths\n\t\t\t\t\texportToSubpath = mapping.exportToSubpath;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If still no subpath resolved and no mapping, bundle all subpaths\n\t\t\tif (!resolvedSubpath && !exportToSubpath) {\n\t\t\t\tallSubpaths = getSubpathExports(pkgInfo.exports);\n\t\t\t}\n\t\t}\n\n\t\t// Create entry file with appropriate content\n\t\tconst entryContent = generateEntryContent({\n\t\t\tpackageName,\n\t\t\tsubpath: resolvedSubpath,\n\t\t\texports,\n\t\t\tallSubpaths,\n\t\t\texportToSubpath,\n\t\t});\n\t\tconst entryFile = path.join(tmpDir, \"entry.js\");\n\t\tfs.writeFileSync(entryFile, entryContent);\n\n\t\t// Get externals\n\t\tconst externals = getExternals(\n\t\t\tpackageName,\n\t\t\tadditionalExternals,\n\t\t\tnoExternal,\n\t\t);\n\n\t\t// Bundle with esbuild\n\t\tconst result = await esbuild.build({\n\t\t\tentryPoints: [entryFile],\n\t\t\tbundle: true,\n\t\t\twrite: false,\n\t\t\tformat: \"esm\",\n\t\t\tplatform: \"browser\",\n\t\t\ttarget: \"es2020\",\n\t\t\tminify: true,\n\t\t\ttreeShaking: true,\n\t\t\texternal: externals,\n\t\t\tmetafile: true,\n\t\t});\n\n\t\t// Get raw size\n\t\tconst bundleContent = result.outputFiles[0].contents;\n\t\tconst rawSize = bundleContent.length;\n\n\t\t// Gzip the bundle\n\t\tconst gzipped = await gzipAsync(Buffer.from(bundleContent), {\n\t\t\tlevel: gzipLevel,\n\t\t});\n\t\tconst gzipSize = gzipped.length;\n\n\t\t// Determine the display name\n\t\tlet displayName = packageName;\n\t\tif (resolvedSubpath) {\n\t\t\tdisplayName = `${packageName}/${resolvedSubpath}`;\n\t\t} else if (exportToSubpath && exportToSubpath.size > 0) {\n\t\t\t// Multiple subpaths - show them all\n\t\t\tconst uniqueSubpaths = [...new Set(exportToSubpath.values())].sort();\n\t\t\tdisplayName = `${packageName}/{${uniqueSubpaths.join(\", \")}}`;\n\t\t}\n\n\t\treturn {\n\t\t\tpackageName: displayName,\n\t\t\tpackageVersion: pkgInfo.version,\n\t\t\texports: exports || [],\n\t\t\trawSize,\n\t\t\tgzipSize,\n\t\t\tgzipLevel,\n\t\t\texternals,\n\t\t\tdependencies: allDependencies,\n\t\t};\n\t} finally {\n\t\tcleanupTempDir(tmpDir);\n\t}\n}\n"],"names":["execSync","fs","os","path","promisify","zlib","esbuild","DEFAULT_EXTERNALS","gzipAsync","gzip","escapeRegExp","str","replace","parsePackageSpecifier","specifier","workingSpec","version","startsWith","secondAtIndex","indexOf","substring","parts","split","length","name","subpath","slice","join","atIndex","slashIndex","formatBytes","bytes","k","sizes","i","Math","floor","log","Number","parseFloat","toFixed","createTempDir","tmpDir","tmpdir","Date","now","mkdirSync","recursive","cleanupTempDir","rmSync","force","isPnpmAvailable","stdio","usePnpm","getInstallCommand","generateEntryContent","options","packageName","exports","allSubpaths","exportToSubpath","size","subpathToExports","Map","exportName","sp","existing","get","push","set","lines","allExportNames","exportNames","importPath","names","importNames","imports","map","getExternals","externals","noExternal","result","filter","e","Set","getPackageInfo","pkgJsonPath","existsSync","pkgJson","JSON","parse","readFileSync","hasMainEntry","Boolean","main","module","dependencies","peerDependencies","getSubpathExports","subpaths","key","Object","keys","findSubpathsForExports","componentNames","packageDir","subpathKey","subpathValue","entries","filePath","types","import","fullPath","content","has","escapedName","patterns","RegExp","some","pattern","test","values","singleSubpath","checkBundleSize","packageSpecifier","additionalExternals","gzipLevel","requestedVersion","packageJson","type","writeFileSync","stringify","installCmd","cwd","pkgInfo","peerDepKeys","allDependencies","sort","dep","resolvedSubpath","mapping","entryContent","entryFile","build","entryPoints","bundle","write","format","platform","target","minify","treeShaking","external","metafile","bundleContent","outputFiles","contents","rawSize","gzipped","Buffer","from","level","gzipSize","displayName","uniqueSubpaths","packageVersion"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,qBAAqB;AAC9C,OAAOC,QAAQ,UAAU;AACzB,OAAOC,QAAQ,UAAU;AACzB,OAAOC,UAAU,YAAY;AAC7B,SAASC,SAAS,QAAQ,YAAY;AACtC,OAAOC,UAAU,YAAY;AAC7B,YAAYC,aAAa,UAAU;AACnC,SAASC,iBAAiB,QAAQ,gBAAgB;AAElD,MAAMC,YAAYJ,UAAUC,KAAKI,IAAI;AAErC;;CAEC,GACD,SAASC,aAAaC,GAAW;IAChC,OAAOA,IAAIC,OAAO,CAAC,uBAAuB;AAC3C;AAQA;;;;;;;CAOC,GACD,OAAO,SAASC,sBAAsBC,SAAiB;IACtD,IAAIC,cAAcD;IAClB,IAAIE,UAAU;IAEd,0CAA0C;IAC1C,IAAID,YAAYE,UAAU,CAAC,MAAM;QAChC,iDAAiD;QACjD,MAAMC,gBAAgBH,YAAYI,OAAO,CAAC,KAAK;QAC/C,IAAID,kBAAkB,CAAC,GAAG;YACzBF,UAAUD,YAAYK,SAAS,CAACF,gBAAgB;YAChDH,cAAcA,YAAYK,SAAS,CAAC,GAAGF;QACxC;QAEA,6DAA6D;QAC7D,sDAAsD;QACtD,MAAMG,QAAQN,YAAYO,KAAK,CAAC;QAChC,IAAID,MAAME,MAAM,GAAG,GAAG;YACrB,wCAAwC;YACxC,MAAMC,OAAO,GAAGH,KAAK,CAAC,EAAE,CAAC,CAAC,EA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 +1,9 @@
1
+ export declare const defaultFlags: {
2
+ boring: boolean;
3
+ gzipLevel: number;
4
+ external: string;
5
+ noExternal: boolean;
6
+ versions: boolean;
7
+ };
8
+ export declare const TREND_VERSION_COUNT = 5;
9
+ export declare const DEFAULT_EXTERNALS: string[];
@@ -0,0 +1,14 @@
1
+ /* istanbul ignore file */ export const defaultFlags = {
2
+ boring: false,
3
+ gzipLevel: 5,
4
+ external: "",
5
+ noExternal: false,
6
+ versions: false
7
+ };
8
+ export const TREND_VERSION_COUNT = 5;
9
+ export const DEFAULT_EXTERNALS = [
10
+ "react",
11
+ "react-dom"
12
+ ];
13
+
14
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/defaults.ts"],"sourcesContent":["/* istanbul ignore file */\n\nexport const defaultFlags = {\n\tboring: false,\n\tgzipLevel: 5,\n\texternal: \"\",\n\tnoExternal: false,\n\tversions: false,\n};\n\nexport const TREND_VERSION_COUNT = 5;\n\nexport const DEFAULT_EXTERNALS = [\"react\", \"react-dom\"];\n"],"names":["defaultFlags","boring","gzipLevel","external","noExternal","versions","TREND_VERSION_COUNT","DEFAULT_EXTERNALS"],"mappings":"AAAA,wBAAwB,GAExB,OAAO,MAAMA,eAAe;IAC3BC,QAAQ;IACRC,WAAW;IACXC,UAAU;IACVC,YAAY;IACZC,UAAU;AACX,EAAE;AAEF,OAAO,MAAMC,sBAAsB,EAAE;AAErC,OAAO,MAAMC,oBAAoB;IAAC;IAAS;CAAY,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @file Automatically generated by barrelsby.
3
+ */
4
+
5
+ export * from "./bundlecheck";
6
+ export * from "./bundler";
7
+ export * from "./defaults";
8
+ export * from "./parse";
9
+ export * from "./trend";
10
+ export * from "./versions";
@@ -0,0 +1,21 @@
1
+ export type Flags = {
2
+ boring?: boolean;
3
+ help?: boolean;
4
+ version?: boolean;
5
+ versions?: boolean;
6
+ trend?: string;
7
+ gzipLevel?: number;
8
+ external?: string;
9
+ noExternal?: boolean;
10
+ };
11
+ export type Parameters = {
12
+ ["0"]?: string;
13
+ ["1"]?: string;
14
+ };
15
+ export type Configuration = {
16
+ flags?: Flags;
17
+ parameters?: Parameters;
18
+ usage?: boolean;
19
+ showHelp?: () => void;
20
+ };
21
+ export declare const config: Configuration;