Repository navigation
feat(bundlecheck): Add platform support (browser/node) - #484
Merged
aversini merged 1 commit intoJan 31, 2026
Merged
Conversation
Introduce platform targeting for bundle builds: add --platform/-p flag (auto|browser|node) with alias support and validation. Implement normalizePlatform and isValidPlatform helpers, wire platform through CLI parsing, bundlecheck, bundler and trend logic, and pass platform to esbuild. Auto-detect platform from package.json engines when platform is "auto"/undefined; treat packages with engines.node (and no engines.browser) as node. For node platform gzip sizes are not calculated (gzipSize becomes null) and UIs/tests updated accordingly. Update README and add/adjust tests to cover normalization, auto-detection, rendering (trend) behavior, and bundle checks.
There was a problem hiding this comment.
Pull request overview
This PR adds explicit platform targeting to bundlecheck, allowing builds for browser or Node.js and auto-detecting platform from package.json engines, and updates the CLI, core bundling logic, trend reporting, tests, and README accordingly.
Changes:
- Introduces
normalizePlatformandisValidPlatformhelpers, adds a--platform/-pCLI flag (with aliases and validation), and wires the normalized platform through tocheckBundleSize,analyzeTrend, and esbuild. - Enhances bundling behavior to auto-detect Node packages via
engines.node(whenengines.browseris absent), setsBundleResult.platform, and skips gzip computation for Node (gzipSizeis nownullthere). - Updates trend graph rendering and summaries to handle
gzipSize: null, adds focused tests for platform normalization/detection and trend behavior, and documents the new flag and platform semantics in the README.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
packages/bundlecheck/src/defaults.ts |
Adds defaultFlags.platform, and implements normalizePlatform/isValidPlatform helpers used to normalize and validate platform values. |
packages/bundlecheck/src/parse.ts |
Extends CLI parsing with a --platform/-p flag, usage examples, and a validation restriction that rejects invalid platform values. |
packages/bundlecheck/src/bundler.ts |
Extends bundle options/results with platform, reads engines from package.json, auto-detects browser vs node, passes platform to esbuild, and skips gzip for Node (returning gzipSize: null). |
packages/bundlecheck/src/trend.ts |
Threads the platform option through analyzeTrend, changes TrendResult.gzipSize to `number |
packages/bundlecheck/src/bundlecheck.ts |
Normalizes CLI --platform to canonical values, passes platform to bundle/trend functions, and updates the CLI output to show platform (with auto-detection note) and handle gzipSize: null for Node. |
packages/bundlecheck/src/__tests__/defaults.test.ts |
New tests verifying platform normalization (aliases, case/whitespace, auto) and validation rules for valid/invalid platform values. |
packages/bundlecheck/src/__tests__/bundler.test.ts |
Adds a dedicated platform option suite to assert default/explicit platform behavior, auto-detection from engines, gzip handling for Node vs browser, and that esbuild receives the correct platform. |
packages/bundlecheck/src/__tests__/trend.test.ts |
Extends trend tests to cover gzipSize: null handling in graphs and summaries, and to assert that the platform option is correctly passed to checkBundleSize. |
packages/bundlecheck/README.md |
Documents platform support, the new --platform flag, auto-detection behavior from engines, and the fact that gzip size is omitted for Node platform and shown as “N/A”. |
aversini
deleted the
feat(bundlecheck)-Add-platform-support-(browser/node)
branch
January 31, 2026 19:27
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce platform targeting for bundle builds: add --platform/-p flag (auto|browser|node) with alias support and validation. Implement normalizePlatform and isValidPlatform helpers, wire platform through CLI parsing, bundlecheck, bundler and trend logic, and pass platform to esbuild. Auto-detect platform from package.json engines when platform is "auto"/undefined; treat packages with engines.node (and no engines.browser) as node. For node platform gzip sizes are not calculated (gzipSize becomes null) and UIs/tests updated accordingly. Update README and add/adjust tests to cover normalization, auto-detection, rendering (trend) behavior, and bundle checks.