Skip to content

feat(bundlecheck): Add platform support (browser/node) - #484

Merged
aversini merged 1 commit into
mainfrom
feat(bundlecheck)-Add-platform-support-(browser/node)
Jan 31, 2026
Merged

aversini merged 1 commit into
mainfrom
feat(bundlecheck)-Add-platform-support-(browser/node)

Conversation

@aversini

Copy link
Copy Markdown
Collaborator

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.

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 normalizePlatform and isValidPlatform helpers, adds a --platform/-p CLI flag (with aliases and validation), and wires the normalized platform through to checkBundleSize, analyzeTrend, and esbuild.
  • Enhances bundling behavior to auto-detect Node packages via engines.node (when engines.browser is absent), sets BundleResult.platform, and skips gzip computation for Node (gzipSize is now null there).
  • 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”.

Comment thread packages/bundlecheck/src/defaults.ts
Comment thread packages/bundlecheck/src/parse.ts
@aversini
aversini merged commit c7a02e0 into main Jan 31, 2026
12 checks passed
@aversini
aversini deleted the feat(bundlecheck)-Add-platform-support-(browser/node) branch January 31, 2026 19:27
@aversini aversini mentioned this pull request Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants