You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rrweb statically bundled into main package despite session replay being disabled #336
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.
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.
Activity
fix: replay splitting for web sdk (when used as a module) #336
lindesvard commentedon Apr 24, 2026
Hoping @openpanel/web@1.4.0 has solved this now!
keiwanmosaddegh commentedon Jul 13, 2026
Thanks for the
splitting: truefix, it did move replay out of the main chunk.One gap remains: apps that never enable
sessionReplaystill ship the replay chunk (rrweb, ~55 KB gz) to their CDN, becauseloadReplayModulekeeps an unconditionalimport('./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.