docs: improve tree shaking docs#4155
Conversation
| ``` | ||
|
|
||
| For setup details, options, bundle-size checks, and known limitations, see the | ||
| [tree shaking guide](/docs/guides/tree-shaking). |
There was a problem hiding this comment.
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?
| [tree shaking guide](/docs/guides/tree-shaking). | |
| [tree shaking guide](/docs/tools/metro-serializer-esbuild). |
There was a problem hiding this comment.
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.
a6504aa to
3f79e12
Compare
tido64
left a comment
There was a problem hiding this comment.
Thanks, I've left some minor comments
| 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 | ||
| ``` |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
We should include that users can refer to the Options section further down for available options.
Summary
@rnx-kit/metro-serializer-esbuilddocumentation instead of adding a separate tree-shaking guidernx-bundletree-shaking setup, serializer options, one-off CLI usage, production-only behavior, and bundle-size checksFixes #1280
Test plan
git diff --checkyarn buildindocsitegenerated static files successfully and reported existing/rnx-kit/docs/communityHTML minifier warnings; the process did not return after success and was terminated manually