Environment
agentation@3.0.2
- React 19.x, ReactDOM 19.x
- Vite (dev server, ESM)
Repro
- Install
agentation in a Vite + React 19 app
- Render
<Agentation endpoint="…" />
- Click any element with the toolbar active
Error
Uncaught TypeError: Cannot read properties of undefined
(reading '__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE')
at getReactDispatcher (agentation.js:12205)
at probeComponentSource (agentation.js:12273)
at probeSourceWalk (agentation.js:12308)
at getSourceLocation (agentation.js:12336)
at detectSourceFile (agentation.js:13270)
at HTMLDocument.handleClick (agentation.js:14458)
Root cause
src/utils/source-location.ts uses a default import:
import React from "react";
react does not have a default export — it's a namespace. Under tsup's CJS interop in your dev environment (and React 18's looser shape) the default-import shim makes this work. But under Vite's ESM resolution with React 19's exports map, the default import resolves to undefined, so React.__CLIENT_INTERNALS_… throws inside getReactDispatcher.
This is visible in the published bundle at dist/index.mjs line 7050:
// src/utils/source-location.ts
import React from "react";
Fix
Change the source to a namespace import:
import * as React from "react";
That keeps the React 18 / React 19 dual-shape guard inside getReactDispatcher working as intended (since the function already handles both __CLIENT_INTERNALS_… and __SECRET_INTERNALS_…).
Workaround for users on the current release
Apply a pnpm patch (or equivalent) editing dist/index.mjs line 7050 from import React from "react" to import * as React from "react".
Environment
agentation@3.0.2Repro
agentationin a Vite + React 19 app<Agentation endpoint="…" />Error
Root cause
src/utils/source-location.tsuses a default import:reactdoes not have a default export — it's a namespace. Under tsup's CJS interop in your dev environment (and React 18's looser shape) the default-import shim makes this work. But under Vite's ESM resolution with React 19'sexportsmap, the default import resolves toundefined, soReact.__CLIENT_INTERNALS_…throws insidegetReactDispatcher.This is visible in the published bundle at
dist/index.mjsline 7050:Fix
Change the source to a namespace import:
That keeps the React 18 / React 19 dual-shape guard inside
getReactDispatcherworking as intended (since the function already handles both__CLIENT_INTERNALS_…and__SECRET_INTERNALS_…).Workaround for users on the current release
Apply a
pnpm patch(or equivalent) editingdist/index.mjsline 7050 fromimport React from "react"toimport * as React from "react".