Skip to content

fix: clean up plugin dependency metadata#1892

Open
Juice10 wants to merge 12 commits into
mainfrom
work/plugin-dependency-design
Open

fix: clean up plugin dependency metadata#1892
Juice10 wants to merge 12 commits into
mainfrom
work/plugin-dependency-design

Conversation

@Juice10

@Juice10 Juice10 commented Jun 27, 2026

Copy link
Copy Markdown
Member

What changed

  • Adds a host-neutral ReplayPlugin contract in @rrweb/types, keeps the concrete rrweb alias for compatibility, and re-exports ReplayPlugin from @rrweb/replay.
  • Removes plugin source/declaration coupling to the monolithic rrweb host where plugins only need shared public types.
  • Updates plugin package metadata so actual published-artifact imports are declared as dependencies, while misleading host peers are removed.
  • Documents compatible record/replay host entrypoints, adds a changeset, and adds a packed-package smoke test for split-host installs.

Options considered

Option 1: No host peer

Pros:

  • supports all valid host entrypoints: rrweb, rrweb/all, @rrweb/record, and @rrweb/replay
  • avoids false peer warnings for consumers that intentionally use split packages
  • keeps plugin manifests focused on packages that the plugin artifacts actually import
  • works with strict package managers once declaration files stop referencing undeclared host packages

Cons:

  • package managers will not warn when a user installs a plugin without a compatible host
  • host compatibility has to be documented and covered by type/smoke tests instead of peer metadata

Chosen because npm peer dependencies cannot express “one of these hosts is required” cleanly. A strict rrweb peer is now misleading, and optional peers add noise without enforcing that any compatible host exists.

Option 2: Optional host peers

Pros:

  • keeps host compatibility visible in package metadata
  • avoids hard install failures when peers are marked optional

Cons:

  • does not require at least one compatible host to be installed
  • can imply every listed host applies to every plugin
  • still requires fixing real undeclared imports separately
  • creates noisy peer metadata for split-package consumers

Option 3: Strict host peer

Pros:

  • gives clear install-time feedback when there is one canonical host package
  • matches a familiar plugin-package model

Cons:

  • no longer matches rrweb’s package split
  • forces or warns about rrweb for valid @rrweb/record, @rrweb/replay, and rrweb/all consumers
  • encourages plugin type surfaces to drift back toward the monolithic entrypoint

Validation

  • Built affected packages, including @rrweb/types, rrweb, @rrweb/record, @rrweb/replay, and all record/replay plugin packages.
  • Ran focused type checks for @rrweb/types, rrweb, @rrweb/replay, and all eight plugin packages.
  • Ran node --check scripts/check-plugin-host-smoke.mjs && yarn check:plugin-hosts.
  • Ran yarn workspace @rrweb/rrweb-plugin-console-record test && yarn workspace @rrweb/rrweb-plugin-network-record test.
  • Verified plugin declaration output has no rrweb imports with rg.
  • Ran git diff --check across the branch diff.
  • Final subagent review passed after tightening the smoke test to cover all plugin pairs and explicitly reject forbidden plugin declaration imports.

@changeset-bot

changeset-bot Bot commented Jun 27, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 97488e7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 22 packages
Name Type
rrweb Patch
@rrweb/types Patch
@rrweb/replay Patch
@rrweb/rrweb-plugin-console-record Patch
@rrweb/rrweb-plugin-console-replay Patch
@rrweb/rrweb-plugin-sequential-id-record Patch
@rrweb/rrweb-plugin-sequential-id-replay Patch
@rrweb/rrweb-plugin-canvas-webrtc-record Patch
@rrweb/rrweb-plugin-canvas-webrtc-replay Patch
@rrweb/rrweb-plugin-network-record Patch
@rrweb/rrweb-plugin-network-replay Patch
rrweb-snapshot Patch
rrdom Patch
rrdom-nodejs Patch
rrweb-player Patch
@rrweb/all Patch
@rrweb/record Patch
@rrweb/packer Patch
@rrweb/utils Patch
@rrweb/browser-client Patch
@rrweb/web-extension Patch
rrvideo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Changes

Size change: +64 B (+0.00%) | Total size: 9775.83 kB

plugins - 255.47 kB -> 255.53 kB (+64 B (+0.02%))
File Base PR Diff
packages/plugins/rrweb-plugin-canvas-webrtc-record/dist/rrweb-plugin-canvas-webrtc-record.cjs 36.71 kB 36.71 kB +8 B (+0.02%)
packages/plugins/rrweb-plugin-canvas-webrtc-record/dist/rrweb-plugin-canvas-webrtc-record.js 36.57 kB 36.58 kB +8 B (+0.02%)
packages/plugins/rrweb-plugin-canvas-webrtc-record/dist/rrweb-plugin-canvas-webrtc-record.umd.cjs 37.76 kB 37.77 kB +8 B (+0.02%)
packages/plugins/rrweb-plugin-canvas-webrtc-record/dist/rrweb-plugin-canvas-webrtc-record.umd.min.cjs 22.33 kB 22.34 kB +8 B (+0.03%)
packages/plugins/rrweb-plugin-canvas-webrtc-replay/dist/rrweb-plugin-canvas-webrtc-replay.cjs 33.50 kB 33.50 kB +8 B (+0.02%)
packages/plugins/rrweb-plugin-canvas-webrtc-replay/dist/rrweb-plugin-canvas-webrtc-replay.js 33.38 kB 33.39 kB +8 B (+0.02%)
packages/plugins/rrweb-plugin-canvas-webrtc-replay/dist/rrweb-plugin-canvas-webrtc-replay.umd.cjs 34.55 kB 34.56 kB +8 B (+0.02%)
packages/plugins/rrweb-plugin-canvas-webrtc-replay/dist/rrweb-plugin-canvas-webrtc-replay.umd.min.cjs 20.67 kB 20.68 kB +8 B (+0.04%)

@Juice10 Juice10 changed the title docs: design plugin dependency cleanup fix: clean up plugin dependency metadata Jun 27, 2026
@Juice10
Juice10 marked this pull request as ready for review July 7, 2026 08:21
Copilot AI review requested due to automatic review settings July 7, 2026 08:21
…ugin-dependency-design

# Conflicts:
#	packages/plugins/rrweb-plugin-canvas-webrtc-record/package.json
#	packages/plugins/rrweb-plugin-canvas-webrtc-replay/package.json
#	packages/plugins/rrweb-plugin-console-replay/package.json
#	packages/plugins/rrweb-plugin-network-record/package.json
#	packages/plugins/rrweb-plugin-network-replay/package.json
#	packages/plugins/rrweb-plugin-sequential-id-record/package.json
#	packages/plugins/rrweb-plugin-sequential-id-replay/package.json

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors rrweb plugin type/dependency surfaces to be host-entrypoint agnostic (monolithic rrweb vs split @rrweb/record / @rrweb/replay), and updates plugin package metadata/docs accordingly so published artifacts declare the dependencies they actually import.

Changes:

  • Introduces a host-neutral ReplayPlugin contract in @rrweb/types, keeps rrweb’s concrete alias, and re-exports ReplayPlugin from @rrweb/replay.
  • Removes plugin source/declaration coupling to rrweb by switching replay plugins to import ReplayPlugin from @rrweb/types, and updates TS project references accordingly.
  • Updates plugin package.json dependency/peer metadata, adds documentation about compatible host entrypoints, adds a changeset, and adds a packed-install smoke test script.

Reviewed changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/check-plugin-host-smoke.mjs Adds a pack-and-install TypeScript smoke test for plugin/host install combinations and declaration host-neutrality.
packages/types/src/index.ts Adds a generic, host-neutral ReplayPlugin type alongside existing plugin types.
packages/rrweb/src/types.ts Replaces the concrete ReplayPlugin definition with a specialization of the base type for compatibility.
packages/replay/src/index.ts Re-exports ReplayPlugin type from the replay entrypoint for @rrweb/replay consumers.
packages/plugins/rrweb-plugin-sequential-id-replay/tsconfig.json Updates TS references to align with importing shared types instead of rrweb.
packages/plugins/rrweb-plugin-sequential-id-replay/src/index.ts Switches ReplayPlugin import to @rrweb/types.
packages/plugins/rrweb-plugin-sequential-id-replay/README.md Documents compatible replay host entrypoints.
packages/plugins/rrweb-plugin-sequential-id-replay/package.json Moves published-artifact type deps into dependencies and removes host peer metadata.
packages/plugins/rrweb-plugin-sequential-id-record/tsconfig.json Updates TS references to align with shared type dependency direction.
packages/plugins/rrweb-plugin-sequential-id-record/README.md Documents compatible recording host entrypoints.
packages/plugins/rrweb-plugin-sequential-id-record/package.json Declares @rrweb/types as a runtime/type dependency and removes rrweb peer metadata.
packages/plugins/rrweb-plugin-network-replay/tsconfig.json Adjusts TS references to match record-plugin + shared type dependencies.
packages/plugins/rrweb-plugin-network-replay/src/index.ts Removes local replay-plugin type and uses shared ReplayPlugin from @rrweb/types.
packages/plugins/rrweb-plugin-network-replay/README.md Documents compatible replay host entrypoints.
packages/plugins/rrweb-plugin-network-replay/package.json Moves required imports to dependencies and removes misleading peers.
packages/plugins/rrweb-plugin-network-record/README.md Documents compatible recording host entrypoints.
packages/plugins/rrweb-plugin-network-record/package.json Moves required imports to dependencies and removes host peer metadata.
packages/plugins/rrweb-plugin-console-replay/tsconfig.json Updates TS references to align with shared type dependency direction.
packages/plugins/rrweb-plugin-console-replay/src/index.ts Switches to shared ReplayPlugin and introduces a local structural replayer context type.
packages/plugins/rrweb-plugin-console-replay/README.md Documents compatible replay host entrypoints.
packages/plugins/rrweb-plugin-console-replay/package.json Declares actual published-artifact deps in dependencies and removes host peer metadata.
packages/plugins/rrweb-plugin-console-record/tsconfig.json Formats config and adds TS references for types/utils.
packages/plugins/rrweb-plugin-console-record/README.md Documents compatible recording host entrypoints.
packages/plugins/rrweb-plugin-console-record/package.json Moves @rrweb/types/@rrweb/utils into dependencies and removes peer metadata.
packages/plugins/rrweb-plugin-canvas-webrtc-replay/tsconfig.json Updates TS references to depend on shared types rather than rrweb.
packages/plugins/rrweb-plugin-canvas-webrtc-replay/src/index.ts Removes concrete host-type imports and uses structural types + shared ReplayPlugin.
packages/plugins/rrweb-plugin-canvas-webrtc-replay/README.md Documents compatible replay host entrypoints.
packages/plugins/rrweb-plugin-canvas-webrtc-replay/package.json Declares @rrweb/types and simple-peer-light as dependencies and removes host peers.
packages/plugins/rrweb-plugin-canvas-webrtc-record/tsconfig.json Updates TS references to depend on shared types rather than rrweb.
packages/plugins/rrweb-plugin-canvas-webrtc-record/src/index.ts Introduces structural peer/signal types to avoid leaking simple-peer-light types and updates callback signatures.
packages/plugins/rrweb-plugin-canvas-webrtc-record/README.md Documents compatible recording host entrypoints.
packages/plugins/rrweb-plugin-canvas-webrtc-record/package.json Declares @rrweb/types and simple-peer-light as dependencies and removes host peers.
package.json Adds check:plugin-hosts script to run the new smoke test.
docs/superpowers/specs/2026-06-27-plugin-dependencies-design.md Adds design rationale/constraints for the dependency/host-neutrality approach.
docs/superpowers/plans/2026-06-27-plugin-dependencies.md Adds an implementation plan/checklist for the change set.
docs/recipes/plugin-api.md Updates docs to reference importing RecordPlugin/ReplayPlugin from @rrweb/types and reflects the new replay shape.
docs/recipes/network.md Updates replay example to use @rrweb/replay’s Replayer entrypoint.
.changeset/plugin-dependency-cleanup.md Adds a patch changeset covering affected packages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +162 to +166
'@rrweb/rrweb-plugin-sequential-id-record': packed.sequentialIdRecord,
rrdom: packed.rrdom,
rrweb: packed.rrweb,
'rrweb-snapshot': packed.rrwebSnapshot,
},
Comment on lines +206 to +210
'@rrweb/rrweb-plugin-sequential-id-replay': packed.sequentialIdReplay,
rrdom: packed.rrdom,
rrweb: packed.rrweb,
'rrweb-snapshot': packed.rrwebSnapshot,
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants