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.
When using
@openpanel/webvia npm withsessionReplay: { enabled: false },rrwebis 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.jscontains a static top-levelimport { record } from "rrweb", making tree-shaking or code-splitting impossible for any downstream bundler.Root cause: The main library build in
tsup.config.tssetssplitting: false. This prevents tsup from emitting theimport('./replay')dynamic import as a separate chunk, so it inlines the replay module – and its rrweb dependency – directly intoindex.js. The source code itself is correctly written with a dynamic import insideloadReplayModule();only the build config contradicts the intent.Suggested fix: Enable
splitting: trueon the main library build target intsup.config.ts, or explicitly mark the replay subpath as an external entry so it is emitted as a separate file rather than inlined.