Skip to content

chore(build): apply signaliumPreset to lib build (vite.config.ts) - #34

Closed
jimmy-phantom wants to merge 1 commit into
mainfrom
fix-lib-build-signalium-preset
Closed

jimmy-phantom wants to merge 1 commit into
mainfrom
fix-lib-build-signalium-preset

Conversation

@jimmy-phantom

Copy link
Copy Markdown
Collaborator

Draft. Open question first: is the lib build expected to apply this preset, or is it intentionally consumer-driven? Filing for discussion before deciding to merge.

Context

Today the Signalium Babel preset is configured in packages/fetchium/vitest.config.ts (test environment) but NOT in packages/fetchium/vite.config.ts (lib build). The published dist/ ships fetchium's source untransformed. Consumers can't fix this from their side because bundlers don't recompile node_modules by default.

What this PR does

Adds signaliumPreset() to vite.config.ts's react() plugin, mirroring the vitest react-project config:

react({
  babel: { presets: [signaliumPreset()] },
}),

That's the entire functional change. A patch changeset is included with a hygiene-only framing.

What this PR does NOT fix

PR #33 (fix(react): stabilize useQuery thunk identity across re-renders) addressed a downstream consumer bug where useQuery produced a fresh signal per render under React 18 / React Native commit ordering. That PR's fix lives at the source level (useMemo + hashValue(args)) and works regardless of whether the preset runs.

Applying the preset alone does NOT fix that bug. The preset would produce useReactive(useCallback(fn, [QueryClass, args])), but args is the rest collection (fresh array literal per call), so Object.is deps compare false every render and useCallback returns a new fn anyway. This was confirmed empirically by a downstream consumer who built fetchium with the preset applied and re-ran the original repro: the bug still fired with structurally-identical traces.

So this PR is purely about lib-build/vitest-config consistency, not about fixing any specific runtime issue.

Caveats worth reviewer attention

The preset rewrites all inline arrows at fetchium's reactive callsites: relay(state => ...), reactiveSignal(() => ...), reactiveMethod(proxy, methods[prop].bind(proxy)), etc. Fetchium has roughly 12 such sites across EntityInstance.ts, QueryResult.ts, LiveCollection.ts. After this change the published bundle's behavior at those sites changes from "inline arrow per call" to "preset-rewritten form" (whatever the callback/async/promise/useReactive transforms produce).

I have NOT done a diff-the-bundle audit at each affected callsite to confirm semantics are preserved. The test suite (1235 tests) passes with the preset applied, which is some signal but not conclusive — the tests already run against transformed code, so they don't reveal transformed-vs-untransformed parity gaps.

Open question for the Signalium team

Is lib-ships-untransformed the intended design, with consumers expected to configure their bundler to also transform fetchium's node_modules path? Or is the convention that lib authors should apply the preset in their own build?

If the latter, this PR is straightforward and we should ship after the bundle audit. If the former, this PR should close.

🤖 Generated with Claude Code

Mirror the vitest react-project config: pass
{ babel: { presets: [signaliumPreset()] } } to react() in vite.config.ts
so fetchium's own reactive callsites are transformed in the published
bundle, consistent with how the test environment transforms them.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jimmy-phantom
jimmy-phantom force-pushed the fix-lib-build-signalium-preset branch from 46c9cee to b4ab225 Compare May 22, 2026 22:04
@jimmy-phantom
jimmy-phantom deleted the fix-lib-build-signalium-preset branch June 12, 2026 15:43
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.

1 participant