build(rrweb): generate record declarations with Oxc - #4752
Conversation
|
📝 No Changeset FoundThis PR doesn't include a changeset. A changeset is required to release a new version. How to add a changesetRun this command and follow the prompts: pnpm changesetRemember: Never use |
Replay incident risk checkThis diff touches code involved in past incidents. This is a heads-up, not a verdict: read the matched sections of INCIDENTS.md and answer their review questions before merging. For a judgment on whether this diff has the same failure mode, run the |
|
Size Change: 0 B Total Size: 20.4 MB ℹ️ View Unchanged
|
…rations # Conflicts: # packages/rrweb/replay/test/build-output.test.ts # packages/rrweb/rrweb/test/build-output.test.ts # packages/rrweb/rrweb/test/vite-config-utils.test.ts # packages/rrweb/vite.config.default.ts # packages/rrweb/vite.config.utils.ts # pnpm-lock.yaml # pnpm-workspace.yaml
Prompt To Fix All With AI### Issue 1
packages/rrweb/record/package.json:10-14
**Declaration command is duplicated**
The same Rolldown command is defined in `build:declarations` and repeated directly in `prepublish`. This creates two sources of truth that can drift, violating the repository directive to say everything OnceAndOnlyOnce and avoid superfluous parts. This repository requirement must be satisfied before merging.
```suggestion
"build:declarations": "rolldown -c rolldown.dts.config.mts",
"test": "vitest run",
"test:watch": "vitest watch",
"check-types": "tsc -noEmit",
"prepublish": "tsc -noEmit && vite build && pnpm build:declarations",
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." | Re-trigger Greptile |
Before/after build compatibility validationI compared clean builds from the exact PR snapshots:
Results
A single forced local comparison completed in approximately 11.6 seconds before and 8.6 seconds after. This is directional rather than a benchmark, but is consistent with the benchmark results in the PR description. TypeScript compatibility caveatThe Oxc declaration output uses That does not affect regular Conclusion: no runtime, packaging, or type-level breaking changes within the supported compatibility surface. |
Problem
@posthog/rrweb-recordusesvite-plugin-dtsduring every production build. Declaration generation accounts for a meaningful part of this small package's build time, while semantic type checking already runs separately withtsc --noEmit.This PR is stacked on #4748 so its diff only contains the declaration-generation pilot.
Changes
rolldown-plugin-dtsand the Oxc declaration generator.tsc --noEmitas a separate semantic type check.index.d.tsandindex.d.ctsfiles and test their expected exports.Across ten clean
prepublishruns, median build time decreased from 1,312 ms to 1,022 ms, a 22.1% improvement. Runtime JavaScript outputs remained byte-identical. The generated declarations match the previous public declarations.Release info Sub-libraries affected
Libraries affected
Checklist
If releasing new changes
pnpm changesetto generate a changeset fileNo changeset is included because this only changes the build tool used to produce equivalent published artifacts.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Pi was used to implement and validate this pilot. We retained
tsc --noEmitbecause Oxc declaration generation does not perform semantic checking. The pilot was validated with clean build benchmarks, package tests, type checking, linting, Publint, consumer type checking, watch mode, tarball inspection, and runtime artifact comparisons.