Skip to content

rrweb statically bundled into main package despite session replay being disabled #336

Closed

Description

@Sindrake

When using @openpanel/web via npm with sessionReplay: { enabled: false }, rrweb is unconditionally included in the host application's bundle.
This adds significant dead weight, despite the fact that replay is never used.

Expected behavior: The replay module is a dynamic import, code-split by the host bundler and never included when replay is disabled.
This is supported by the documenation and source code intent.

Actual behavior: the published dist/index.js contains a static top-level import { record } from "rrweb", making tree-shaking or code-splitting impossible for any downstream bundler.

Root cause: The main library build in tsup.config.ts sets splitting: false. This prevents tsup from emitting the import('./replay') dynamic import as a separate chunk, so it inlines the replay module – and its rrweb dependency – directly into index.js. The source code itself is correctly written with a dynamic import inside loadReplayModule(); only the build config contradicts the intent.

Suggested fix: Enable splitting: true on the main library build target in tsup.config.ts, or explicitly mark the replay subpath as an external entry so it is emitted as a separate file rather than inlined.

Activity

  1. lindesvard commented on Apr 24, 2026

    @lindesvard
    Contributor

    Hoping @openpanel/web@1.4.0 has solved this now!

  2. keiwanmosaddegh commented on Jul 13, 2026

    @keiwanmosaddegh
    Contributor

    Thanks for the splitting: true fix, it did move replay out of the main chunk.

    One gap remains: apps that never enable sessionReplay still ship the replay chunk (rrweb, ~55 KB gz) to their CDN, because loadReplayModule keeps an unconditional import('./replay') in the library build. It's lazy now so there's no TTI cost, but it's still deployed as dead code with no way to drop it short of stubbing rrweb or patching.

    Wrote up a small opt-in proposal in #414.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions