Skip to content

Allow tree shaking of @sentry/replay if unused #6886

@ChrisRast

Description

@ChrisRast

Problem Statement

Currently, if we use @sentry/browser or any similar package, but we don't use any replay feature (for any reason), we want to avoid shipping the whole replay package to our customers.

We use webpack and I setup a specific rule through resolve.alias configuration to resolve all occurrences of the replay package to null.

resolve: {
  alias: {
    '@sentry/replay': false
  }
}

It works, and doesn't create any error, but it's not really "clean".

Solution Brainstorm

Offer a flag to let bundler choose similar to these https://docs.sentry.io/platforms/javascript/guides/react/configuration/tree-shaking/#list-of-flags

Tag: __SENTRY_REPLAY__

It would be much cleaner than a webpack resolve config.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions