fix(devtools-vite): inject data-tsd-source before other plugins transform (#548)

* fix(devtools-vite): inject data-tsd-source before other plugins transform

inject-source uses `enforce: 'pre'`, so a `pre` plugin listed before
devtools() transformed the code first. When that plugin changes the code of
one environment only (a server-function compiler, for example), the lines
shift, and data-tsd-source differs between the SSR and client output. React
then reports a hydration mismatch, for example
`editor.tsx:632:5` on the server and `editor.tsx:636:5` on the client.

The transform hook now has `order: 'pre'`, so it runs before the other
plugins' transform hooks, whatever their position in the array.

Fixes #405
Fixes #189

* docs(devtools-vite): note that an earlier order: 'pre' transform still runs first
This commit is contained in:
Alem Tuzlak 2026-10-29 16:18:54 +01:00 • committed by GitHub
commit 40f32e4cda
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 73 additions and 0 deletions