Skip to content

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

@Sindrake

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.

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