Skip to content
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

Optimize default bundle size #3718

Open
krystofwoldrich opened this issue Mar 27, 2024 · 0 comments
Open

Optimize default bundle size #3718

krystofwoldrich opened this issue Mar 27, 2024 · 0 comments

Comments

@krystofwoldrich
Copy link
Member

krystofwoldrich commented Mar 27, 2024

Description

Metro currently doesn't support tree shaking out of the box. And so all @sentry/* dependencies are included in the final bundle.

Some packages can be easily excluded using the metro resolver options:

Current solution

const config = {
  resolver: {
    resolveRequest: (context, moduleName, platform) => {
      if (moduleName.includes('@sentry/replay')) {
        return { type: 'empty' };
      }
      return context.resolveRequest(context, moduleName, platform);
    },
  },
};

Proposed solution

Sentry Metro config will automatically remove web replay for mobile platforms and expose an option to remove it for web builds.

const { withSentryConfig } = require('@sentry/react-native/metro');

const m = mergeConfig(getDefaultConfig(__dirname), config);
module.exports = withSentryConfig(m, { includeReplay: true });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

2 participants