Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/pr-bundle-size-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
repository: ${{ github.repository }}
run-id: ${{ github.event.workflow_run.id }}

- name: Validate downloaded bundle size report
run: node apps/bundle-size/scripts/validate-report.mjs bundle-size-analysis/report.md

- name: Publish bundle size PR comment
env:
EXPECTED_HEAD_REPOSITORY: ${{ github.event.workflow_run.head_repository.full_name }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ jobs:
- name: Measure bundle sizes
run: yarn bundle-size --baseline "$env:RUNNER_TEMP\bundle-size-baseline.json"

- name: Validate bundle size report
run: yarn workspace @fluentui-react-native/bundle-size validate-report

- name: Publish bundle size summary
run: Get-Content apps\bundle-size\dist\bundle-size\report.md -Raw | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append

Expand Down
39 changes: 17 additions & 22 deletions apps/bundle-size/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Bundle-size fixture

This private app measures minified, tree-shaken Metro consumer bundles without including a test
app or Storybook catalog. It uses `@rnx-kit/metro-config`,
`@rnx-kit/metro-resolver-symlinks` with `oxc-resolver`, and
`@rnx-kit/metro-serializer-esbuild`. Each target scenario is compared with the same React Native
shell on macOS, Win32, and Windows.
This private app measures minified, tree-shaken esbuild consumer bundles without including a test
app or Storybook catalog. React, React Native, React Native SVG, desktop React Native forks, and
`@svgo` imports are external so measurements contain only the package code under test.

Run every configured scenario from the repository root:

Expand All @@ -20,16 +18,12 @@ yarn bundle-size --platform macos --platform win32
```

Results, source maps, and esbuild metafiles are written to the ignored `dist/bundle-size`
directory. The runner passes `--tree-shake true` and `--metafile <scenario>.meta.json` to
`rnx-cli bundle`. The JSON report contains raw bytes, gzip bytes, contributing esbuild input
counts, Metro source-map counts, workspace package contribution bytes, and shell deltas. Raw
bytes are the primary comparison; gzip and module attribution are diagnostic signals. The
terminal summary shows the shell's absolute cost and each package scenario's incremental module
and byte cost above its platform shell, plus signed deltas from the baseline.

The Babel configuration preserves ESM for the serializer while explicitly lowering JSX. The
explicit JSX transform is required because the desktop React Native packages publish JSX in
`.js` files, which esbuild otherwise parses with its plain JavaScript loader.
directory. Platform-specific module resolution prefers `.<platform>`, then `.native`, then
generic TypeScript and JavaScript extensions. Package exports use the `react-native` condition.
The JSON report contains raw bytes, gzip bytes, contributing esbuild input counts, and workspace
package contribution bytes. Raw bytes are the primary comparison; gzip and module attribution
are diagnostic signals. The terminal summary shows each scenario's absolute module and byte cost
plus signed deltas from the baseline.

## Baselines and pull requests

Expand All @@ -42,18 +36,19 @@ yarn bundle-size:update
```

Review the baseline diff together with the implementation that caused it. The PR workflow adds
the Markdown comparison to its job summary, updates one persistent PR comment, and uploads the
complete `dist/bundle-size` directory, including the esbuild metafiles, for investigation.
Same-repository PRs publish directly; fork and Dependabot reports are strictly validated and
published by a separate trusted completion workflow.
the Markdown comparison to its job summary only after validating the trusted report format,
updates one persistent PR comment, and uploads the complete `dist/bundle-size` directory,
including the esbuild metafiles, for investigation. Same-repository PRs publish directly; fork
and Dependabot reports are validated again and published by a separate trusted completion
workflow.

## Adding a package or submodule

1. Add the package to this fixture's dependencies so the pnpm linker exposes it to Metro.
1. Add the package to this fixture's dependencies so the pnpm linker exposes it to esbuild.
2. Add a scenario to `scenarios.json` with a stable name, module specifier, and either `exports`
or `namespace: true`.
3. Run `yarn bundle-size` and inspect the shell delta and generated esbuild metafile. The
metafile can also be loaded into the esbuild bundle analyzer.
3. Run `yarn bundle-size` and inspect the generated esbuild metafile. The metafile can also be
loaded into the esbuild bundle analyzer.

Use a supported public package or subpath export when measuring consumer cost. A source-relative
module path is useful for diagnostics, but it does not prove the cost of the published API.
13 changes: 0 additions & 13 deletions apps/bundle-size/babel.config.js

This file was deleted.

Loading
Loading