IjzerenHein / react-native-bundle-visualizer

See what packages are increasing your react-native bundle size 📦
MIT License
1.46k stars 44 forks source link

Accept metro bundler config as an argument. #126

Open Sakethtadimeti opened 6 months ago

Sakethtadimeti commented 6 months ago

Proposed change:

Accept a --config argument & pass it on to react native bundle command.

Example usage - react-native-bundle-visualizer --platform android --config metro+esbuild.config.js

Why is this needed: It'll be easier to view bundle sizes when testing out different configurations of metro config.

Ex:: Bundling with es-build /without es-build.

Sakethtadimeti commented 6 months ago

@IjzerenHein Please let me if this makes sense. I'll be happy to send a PR in.

For more context - Esbuild (with tree shaking support) for metro bundler is out in beta. https://www.npmjs.com/package/@rnx-kit/metro-serializer-esbuild. There is a known limitation that it only works correctly with production builds & hence needs us to maintain 2 versions of metro config.

While trying to visualize the difference in bundle sizes with & without es-build transformations, we realized doesn't accept a config arg currently.

https://github.com/IjzerenHein/react-native-bundle-visualizer/blob/main/src/react-native-bundle-visualizer.js#L86-#L100