Skip to content

Huge bundle size in react-native for sentry/react-native (264kb) #1818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jayshah123 opened this issue Oct 9, 2021 · 5 comments
Closed

Huge bundle size in react-native for sentry/react-native (264kb) #1818

jayshah123 opened this issue Oct 9, 2021 · 5 comments
Labels
dependencies Pull requests that update a dependency file

Comments

@jayshah123
Copy link

Environment

How do you use Sentry?
Sentry SaaS (sentry.io)

Which SDK and version?
sentry-react-native 3.0.0
React native 0.63.2

Steps to Reproduce

  1. analyze using npx react-native-bundle-visualizer in a project that contains sentry/react-native

Expected Result

Smaller bundle size, I see packages like browser etc included which would probably not be needed.

Actual Result

264kb bundle

Screenshot 2021-10-09 at 10 46 43

@shamilovtim
Copy link

Sentry team can treeshake in react native with require + try/catch. Dev dependencies should not be imported and should be behind an env var for imports.

@marandaneto marandaneto added bundle size dependencies Pull requests that update a dependency file labels Oct 11, 2021
@marandaneto
Copy link
Contributor

@jayshah123 is 264kb before or after treeshake?

browser and integrations are vitals for the RN SDK so we can't remove them, but only used code should be bundled anyway.

@jayshah123
Copy link
Author

Metro does not have treeshaking as far as I know

@shamilovtim
Copy link

Treeshaking in metro is not automatic but can be done manually with require + try/catch. if you ever import a dev dependency you must treeshake it or else you will bloat the production bundle with a bunch of useless code. For instance, this is how you can treeshake reactotron:

if (__DEV__) {
  try {
    const Reactotron = require('reactotron-react-native');
    Reactotron.configure() // controls connection & communication settings
      .useReactNative() // add all built-in react native plugins
      .connect(); // let's connect!
  } catch (e) {}
}

@marandaneto
Copy link
Contributor

dup of #1733

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

3 participants