React Native は(デフォルトでは) Tree Shaking をサポートしない
Published: 2023/9/29
React Native (のデフォルト bundler である Metro bundler) は、 Tree Shaking をサポートしていない。
Does React Native perform Tree Shaking?
I am trying to weigh up the benefits of converting moment to date-fns. Moment is currently 316k or 67.6k gzipped. date-fns/format is 3k. We deliver updates through CodePush so minimising the
stackoverflow.com

Tree Shaking を行いたい場合などは、 webpack ベースで React Native のバンドリングを行う Re.Pack などのツールを使うのが、スジが良さそうである。
Re.Pack
A Webpack-based toolkit to build your React Native application with full support of Webpack ecosystem.
re-pack.netlify.app
参考スレッド
Tree shaking while bundling · Issue #227 · facebook/metro
Is it possible anyhow to implement tree shaking during bundling. Suppose I have a file say greetings.js: export const sayHi = (name) => {return `Jarvis says hi to ${name}`}; export const sayBye = (...
github.com
Tags: react-native
関連記事
react-native-modal で複数モーダルを扱う際の注意点
2023/12/2
createAnimatedComponent について
2023/10/16
./gradlew EACCESS エラーが発生したときの対処
2023/9/4