ENG-1992 Downgrade Obsidian react version to 18#1227
Conversation
React 19's react-dom bundles createElement("script") from its hoistable
resource/preload APIs, which trips the Obsidian community-plugin store's
automated review (flagged in ENG-1988). Pin the Obsidian app to React 18.2.0
to remove the pattern.
- Set catalog:obsidian react/react-dom to 18.2.0 (matching catalog:roam so
both apps dedupe to a single React copy). tldraw@3.14.2 peer-accepts ^18.
- Widen two manually-assigned refs to useRef<T | null>(null); React 18 types
make RefObject.current read-only otherwise.
Verified: rebuilt dist/main.js has 0 createElement("script") occurrences
(was 3) and carries React 18.2.0; check-types and Obsidian lint pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
PR size/scope checkThis PR is over our review-size guideline.
Please split this into smaller PRs unless there is a clear reason the changes need to land together. If keeping it as one PR, please add a brief justification covering:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Fixes packages/ui type-check break from the previous commit. The workspace shares a single hoisted @types/react; changing obsidian's @types to 18 flipped that global slot, leaking React 18 types into type-less deps (lucide-react, sonner) consumed by React 19 packages/ui. Only the runtime react/react-dom (which the bundle depends on) needs to be 18.2.0 to remove createElement("script"). @types stay on ^19 as before, so the hoist slot is unchanged and packages/ui is untouched. Reverts the now-unneeded useRef typing change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
With obsidian on react 18.2.0 and website/ui on 19, pnpm hoisted a single
react into the shared .pnpm store, and the version it picked flipped to 18.
Vercel's pruned website-only build then dangled on .pnpm/node_modules/react
(18.2.0 not in its graph) -> ENOENT.
Exclude react/react-dom from hoisting so no shared bare copy exists; every
package resolves its own anchored react via its declared dep/peer. Verified:
full check-types 8/8, obsidian bundle has 0 createElement("script") and React
18.2.0, website builds clean.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Testing showed hoistPattern was unnecessary (the website builds cleanly with react@18 hoisted) and it could not fix the Vercel failure anyway: it only applies on a clean node_modules, and Vercel reuses a cached one. The Vercel red is build-cache staleness from the react 19->18 transition, not a code issue, and is resolved by a clean install rather than a workspace change. Net change is now just catalog:obsidian react/react-dom -> 18.2.0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| "@types/react": ^19.0.12 | ||
| "@types/react-dom": ^19.0.4 |
There was a problem hiding this comment.
Critical Type Mismatch: The PR description states that @types/* should be downgraded to 18.2.21/18.2.17 to match React 18.2.0, but these lines show the types are still pinned to React 19 versions (^19.0.12 and ^19.0.4). This creates a dangerous mismatch where:
- Runtime uses React 18.2.0
- TypeScript uses React 19 type definitions
This will cause runtime errors when code compiles successfully but uses React 19-only APIs that don't exist in React 18.
Fix:
obsidian:
"@types/react": 18.2.21
"@types/react-dom": 18.2.17
react: 18.2.0
react-dom: 18.2.0| "@types/react": ^19.0.12 | |
| "@types/react-dom": ^19.0.4 | |
| "@types/react": 18.2.21 | |
| "@types/react-dom": 18.2.17 | |
Spotted by Graphite
Is this helpful? React 👍 or 👎 to let us know.
Design note: why obsidian keeps
|
4150aa1 to
d2b1a03
Compare
592789e to
7c13533
Compare
What & why
React 19's
react-dombundlescreateElement("script")(from its hoistable-resource / preload/preinit APIs), which trips the Obsidian community-plugin store's automated review. Root cause was confirmed in ENG-1988. The community-recommended fix is to pin the plugin to React 18.This downgrades the Obsidian app from React
19.0.0→18.2.0.Changes
pnpm-workspace.yaml— setcatalog:obsidianreact/react-dom to18.2.0and@types/*to18.2.21/18.2.17, matchingcatalog:roamso both apps dedupe to a single React copy.tldraw@3.14.2peer-accepts^18.2.0 || ^19, so no patch is needed.pnpm-lock.yaml— regenerated bypnpm install.TldrawViewComponent.tsx— widened two manually-assigned refs touseRef<T | null>(null); React 18 types makeRefObject.currentread-only otherwise.No React-19-only APIs are used, and no shared
@repo/*package on Obsidian's path depends on React (@repo/uiis website-only), so this is isolated to the Obsidian app.Verification
apps/obsidian/dist/main.jscontains 0createElement("script")occurrences (was 3) and carries React18.2.0.turbo check-types --filter=@discourse-graphs/obsidianpasses.lintpasses (0 errors).🤖 Generated with Claude Code