Repository navigation
Treeshaking is not implemented in metro, yet there is a tree shaking option in the plugin config. How does this work? #2922
Answered
by
tido64
Karim (karimb11)
asked this question in
Q&A
Replies: 2 comments 5 replies
|
have you checked out https://microsoft.github.io/rnx-kit/docs/guides/bundling and https://microsoft.github.io/rnx-kit/docs/tools/metro-serializer-esbuild ? |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

The Metro flow goes something like this:
flowchart LR Parse --> Transform --> Serialize --> WriteOur plugins are run inside the "Serialize" step. By this step, Metro is done transforming all source code and is ready to write to disk. We take all the transformed code and pass it to esbuild for yet another pass. The output of this pass is then written to disk.
As you can probably see, it is a bit hacky. I wish there was a better way to implement tree shaking in Metro right now, but it's going to take a while to do it correctly. That said, we are using it in a number of products, including Office apps if I remember correctly.