[codex] Split rrweb-snapshot utility implementations#1839
Conversation
|
Bundle Size ChangesNo bundle size changes. |
There was a problem hiding this comment.
Pull request overview
This PR refactors rrweb-snapshot’s former monolithic utils.ts into smaller, domain-focused utility modules while keeping utils.ts as a public compatibility shim (still re-exported from src/index.ts).
Changes:
- Introduces
shared-utils.tsfor cross-domain helpers (e.g.,Mirror,isElement,extractFileExtension). - Introduces
snapshot-utils.tsfor snapshot-only helpers (CSS serialization, masking, shadow DOM helpers, etc.) and updatessnapshot.tsto import from it. - Introduces
rebuild-utils.tsfor rebuild-only helpers (isNodeMetaEqual) and updatesrebuild.tsto import from it, while keepingutils.tsas a legacy re-export shim.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/rrweb-snapshot/src/utils.ts | Replaced implementation with a compatibility shim that re-exports from the new utility modules. |
| packages/rrweb-snapshot/src/snapshot.ts | Switched internal imports from ./utils to ./snapshot-utils. |
| packages/rrweb-snapshot/src/snapshot-utils.ts | New snapshot-specific utility module (moved logic from old utils.ts). |
| packages/rrweb-snapshot/src/shared-utils.ts | New shared utility module for cross-domain helpers. |
| packages/rrweb-snapshot/src/rebuild.ts | Switched internal imports from ./utils to ./rebuild-utils. |
| packages/rrweb-snapshot/src/rebuild-utils.ts | New rebuild-specific utility module (moved isNodeMetaEqual). |
| packages/rrweb-snapshot/src/index.ts | Keeps legacy export * from './utils' with guidance to prefer narrower internal entrypoints. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export { | ||
| absolutifyURLs, | ||
| escapeImportStatement, |
|
decision /w @eoghanmurray: defer it until such time as we can clear and triage the backlog of PRs, .... I think we should be able to do that soon given move to 2.1 |
|
Also packages/utils/src/index.ts has recording related stuff (mutationobserver) that is included in replay dist outputs where it is not needed |
Summary
shared-utils.tssnapshot-utils.tsrebuild-utils.tsutils.tsas an explicit public compatibility shimValidation
yarn workspace rrweb-snapshot check-typesyarn workspace @rrweb/record buildyarn workspace @rrweb/record testrg -n "postcss" packages/record/dist --glob '*.{js,cjs}'found no matches\n-yarn workspace rrweb-snapshot lint(warnings only, no errors)