Skip to content

docs: improve tree shaking docs#4155

Open
vivekjm wants to merge 1 commit into
microsoft:mainfrom
vivekjm:docs-tree-shaking-guide
Open

docs: improve tree shaking docs#4155
vivekjm wants to merge 1 commit into
microsoft:mainfrom
vivekjm:docs-tree-shaking-guide

Conversation

@vivekjm
Copy link
Copy Markdown

@vivekjm vivekjm commented May 17, 2026

Summary

  • point the bundling guide at the existing @rnx-kit/metro-serializer-esbuild documentation instead of adding a separate tree-shaking guide
  • expand the serializer README with rnx-bundle tree-shaking setup, serializer options, one-off CLI usage, production-only behavior, and bundle-size checks

Fixes #1280

Test plan

  • git diff --check
  • yarn build in docsite generated static files successfully and reported existing /rnx-kit/docs/community HTML minifier warnings; the process did not return after success and was terminated manually

Comment thread docsite/docs/guides/bundling.mdx Outdated
```

For setup details, options, bundle-size checks, and known limitations, see the
[tree shaking guide](/docs/guides/tree-shaking).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As mentioned in the issue you've linked, I don't think we actually need an entire page for tree shaking. Can we point to metro-serializer-esbuild and improve the existing documentation instead?

Suggested change
[tree shaking guide](/docs/guides/tree-shaking).
[tree shaking guide](/docs/tools/metro-serializer-esbuild).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated, thanks. I removed the separate tree-shaking guide and now point the bundling guide at the existing metro-serializer-esbuild docs instead. I also moved the useful setup/checking details into the serializer README so the tree-shaking docs live with the tool.

@vivekjm vivekjm force-pushed the docs-tree-shaking-guide branch from a6504aa to 3f79e12 Compare May 19, 2026 09:02
@vivekjm vivekjm changed the title docs: add tree shaking guide docs: improve tree shaking docs May 19, 2026
Copy link
Copy Markdown
Member

@tido64 tido64 left a comment

Choose a reason for hiding this comment

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

Thanks, I've left some minor comments

Comment on lines +152 to +160
Build once without tree shaking and once with it, then compare bundle sizes:

```sh
react-native rnx-bundle --platform ios --dev false --tree-shake false
mv index.ios.jsbundle index.ios.baseline.jsbundle

react-native rnx-bundle --platform ios --dev false --tree-shake true
ls -lh index.ios.baseline.jsbundle index.ios.jsbundle
```
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think we need this section. It's not platform agnostic and people should know how to do this already. I would maybe expand the section about the analyzer a bit and include a link to it: https://esbuild.github.io/analyze/


## Usage

If you use `react-native rnx-bundle`, enable tree shaking in your rnx-kit
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should mention @rnx-kit/cli and the rnx-bundle command in a parenthesis e.g., "if you use @rnx-kit/cli (or react-native rnx-bundle)…

}
```

For one-off validation, use the command-line override:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should include that users can refer to the Options section further down for available options.

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.

how-to guide for tree-shaking

2 participants