@node-cli/bundlecheck 1.5.0 → 1.5.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 +38 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,12 +11,12 @@ A CLI tool to check the bundle size of npm packages, similar to [bundlephobia.co
|
|
|
11
11
|
- Interactive version selection with `--versions` flag
|
|
12
12
|
- Bundle size trend analysis with `--trend` flag (bar graph across versions)
|
|
13
13
|
- Support for checking specific exports (tree-shaking)
|
|
14
|
-
- Smart externalization of React and React-DOM (
|
|
14
|
+
- Smart externalization of React and React-DOM (including subpaths like `jsx-runtime`)
|
|
15
15
|
- Raw and gzip sizes with configurable compression level
|
|
16
16
|
- **Platform support**: target `browser` (default) or `node` with smart auto-detection
|
|
17
17
|
- Custom npm registry support (for private registries)
|
|
18
18
|
- Fast bundling using esbuild (with pnpm support)
|
|
19
|
-
- **Local caching** for faster repeated lookups (SQLite-based, max
|
|
19
|
+
- **Local caching** for faster repeated lookups (SQLite-based, max 1000 entries)
|
|
20
20
|
- **Library API** for programmatic usage in Node.js applications
|
|
21
21
|
|
|
22
22
|
## Installation
|
|
@@ -406,11 +406,13 @@ clearCache(); // Clears all cached results
|
|
|
406
406
|
## How It Works
|
|
407
407
|
|
|
408
408
|
1. Creates a temporary directory
|
|
409
|
-
2. Installs the specified npm package
|
|
409
|
+
2. Installs the specified npm package (and its peer dependencies)
|
|
410
410
|
3. Creates an entry file importing the package/exports
|
|
411
411
|
4. Bundles with esbuild (minified, tree-shaken)
|
|
412
|
-
5.
|
|
413
|
-
6.
|
|
412
|
+
5. If bundling fails due to unresolved React imports, automatically adds React to externals and retries
|
|
413
|
+
6. Reports raw and gzip sizes
|
|
414
|
+
7. Caches the result for faster future lookups
|
|
415
|
+
8. Cleans up temporary files
|
|
414
416
|
|
|
415
417
|
## Platform Support
|
|
416
418
|
|
|
@@ -437,9 +439,37 @@ bundlecheck fastify -p server # "server" is an alias for "node"
|
|
|
437
439
|
|
|
438
440
|
When a package declares `react` or `react-dom` in its `dependencies` or `peerDependencies`, they are automatically marked as external (not included in the bundle size). This matches how these packages would typically be used in a real application where React is provided by the host application.
|
|
439
441
|
|
|
440
|
-
|
|
442
|
+
### Subpath externalization
|
|
441
443
|
|
|
442
|
-
|
|
444
|
+
When `react` is externalized, the following subpaths are also automatically externalized:
|
|
445
|
+
|
|
446
|
+
- `react/jsx-runtime`
|
|
447
|
+
- `react/jsx-dev-runtime`
|
|
448
|
+
|
|
449
|
+
When `react-dom` is externalized:
|
|
450
|
+
|
|
451
|
+
- `react-dom/client`
|
|
452
|
+
- `react-dom/server`
|
|
453
|
+
|
|
454
|
+
This ensures that modern JSX transform imports and React 18+ APIs work correctly.
|
|
455
|
+
|
|
456
|
+
### Auto-detection for improperly packaged libraries
|
|
457
|
+
|
|
458
|
+
Some npm packages import from `react` without declaring it in their `peerDependencies`. Bundlecheck automatically detects this scenario: if the initial bundle fails due to unresolved React imports, it will automatically add `react` and/or `react-dom` to externals and retry.
|
|
459
|
+
|
|
460
|
+
This means commands like the following work out of the box, even when the package doesn't properly declare its peer dependencies:
|
|
461
|
+
|
|
462
|
+
```bash
|
|
463
|
+
bundlecheck @versini/ui-button # Works even though react is not in peerDependencies
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### Disabling externals
|
|
467
|
+
|
|
468
|
+
To include all dependencies (including React when present) in the bundle size calculation, use the `--no-external` flag:
|
|
469
|
+
|
|
470
|
+
```bash
|
|
471
|
+
bundlecheck react --no-external # Include React itself in the bundle
|
|
472
|
+
```
|
|
443
473
|
|
|
444
474
|
## Custom Registry
|
|
445
475
|
|
|
@@ -463,7 +493,7 @@ Bundle size results are cached locally to speed up repeated lookups. The cache i
|
|
|
463
493
|
### How it works
|
|
464
494
|
|
|
465
495
|
- Results are cached based on: package name, version, exports, platform, gzip level, and externals configuration
|
|
466
|
-
- The cache holds up to **
|
|
496
|
+
- The cache holds up to **1000 entries** (least recently used entries are evicted first)
|
|
467
497
|
- When you check a package, the CLI first looks for a cached result with matching parameters
|
|
468
498
|
|
|
469
499
|
### Smart version matching
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-cli/bundlecheck",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.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)",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"@vitest/coverage-v8": "4.0.18",
|
|
51
51
|
"vitest": "4.0.18"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "363bf7a7b6fa50a94fc07bbded9e198acf52e2e8"
|
|
54
54
|
}
|