Repository navigation
fix(pacer): only run devtools integration in development - #308
schiller-manuel wants to merge 6 commits into
Conversation
…n tree-shake it Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
🦋 Changeset detectedLatest commit: 7054b8d The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
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 |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
🚀 Changeset Version Preview1 package(s) bumped directly, 10 bumped as dependents. 🟩 Patch bumps
|
|
View your CI Pipeline Execution ↗ for commit 49885b6
☁️ Nx Cloud last updated this comment at |
This reverts commit debc359.
TypeScript 6 no longer loads @types/node by default, and the docs tsconfigs don't include the config files that pull it in. The new `process.env.NODE_ENV` checks then failed type-checking in typedoc, which made generate-docs wipe every reference docs folder without writing new output. Declare a minimal `process` type in pacer (same as preact-pacer-devtools) and include it in the framework docs tsconfigs, which compile pacer from source. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
🎯 Changes
Since 0.5,
@tanstack/devtools-event-clientturnsEventClientinto a no-op unlessprocess.env.NODE_ENV === 'development'. Pacer's own devtools code around it had no such check, so production builds still shipped and ran it:emitChangestored the instance in a module-level map that is never cleared, and deep-cloned its state and options withJSON.parse(JSON.stringify())before passing them to the no-opemit.d-*events in their constructors.pacerEventClientwas created at module load from a subclass, so bundlers could not drop it or@tanstack/devtools-event-client.This PR puts the same
NODE_ENV === 'development'check in front ofemitChangeand the constructor subscriptions. It also createspacerEventClientas a/* @__PURE__ */ new EventClient(...)without the subclass, because esbuild keeps an unusedclass extends. The guards checkkeyfirst, so unkeyed utils in unbundled Node skip theprocess.envlookup.Exports and development behaviour are unchanged. Events never reached devtools in production before this change, so the only production difference is that the registry and cloning no longer run.
Bundle of
new Throttler(...).maybeExecute()withNODE_ENV=productionand minification:After the change, neither bundle contains event client code.
I did not use
@__NO_SIDE_EFFECTS__onemitChange. Its return value is never used, so bundlers would remove every call, including in development. I checked this with rolldown: devtools stopped receiving updates.A new
event-client.test.tscovers both modes. The existing registry tests now stubNODE_ENV=development, because vitest runs withtest.✅ Checklist
pnpm run test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Summary by CodeRabbit