Repository navigation
feat(react): export the current API from @deck.gl/react/legacy - #11181
Conversation
Move the module's sources under src/legacy and re-export them from the package root, and add a ./legacy subpath export. The root API is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
[Low impact] The PR appears safe to merge; no blocking issues were found. SummaryAdds
No new actionable issues found. Reviews (7) · Last reviewed commit: "Merge remote-tracking branch 'origin/mas..." · Reviewed by Greptile |
Comments Outside DiffThese findings could not be posted inline.
|
The build adds a .js extension to relative imports, so './legacy' became './legacy.js', which doesn't exist because legacy is a directory. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
ibgreen
left a comment
There was a problem hiding this comment.
CommonJS packaging needs a shared legacy implementation before this serves as an incremental migration path. Ocular bundles dist/index.cjs and dist/legacy/index.cjs independently, so they each create a different DeckGlContext. A widget/custom component using useWidget from one entry cannot consume the provider from the other entry.
I reproduced this at 6a8cc49 by bundling both source entries with the project's CJS settings (bundle: true, packages: 'external'). They expose the same names but different DeckGL/useWidget identities and two distinct contexts. With real React/ReactDOM server and stubbed deck imports, a cross-entry hook under the other entry's captured provider throws Cannot destructure property 'widgets' of 'context' as it is undefined; the same-entry control registers the widget. This was a focused diagnostic, not a full package/browser build.
The new source-alias identity test misses this because both imports resolve to the same TypeScript module. Could the CJS root forward to the legacy CJS entry (or otherwise share its implementation), with a built-entry regression test? This matters when an application switches to /legacy while a reusable component still imports the current root. The ESM re-export does not duplicate the context.
ocular's build-cjs bundles each `require` entry separately with only packages external, so `dist/index.cjs` inlined its own copy of `/legacy`, with its own DeckGL context. A component calling `useWidget` from one entry could not see a `DeckGL` from the other. The root now re-exports `@deck.gl/react/legacy` by package name, so its CJS bundle is a `require` of the legacy bundle. The default export is re-exported by name, because the CJS interop would otherwise make `default` the whole `module.exports` object. A node test bundles both entries with the build-cjs settings and checks the root requires `/legacy` and shares its identities. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 236c2ec. Configure here.
|
Thanks, confirmed and fixed.
#11183 had the same problem across the root, the three map roots and Generated by Claude Code |
Importing `@deck.gl/react/legacy` by package name left that specifier in
`dist/index.js` and `dist/index.d.ts`, which TypeScript with
`moduleResolution: node` and bundlers that ignore `exports` can't resolve.
The root imports `./legacy/index` again. A module build script, run after
ocular-build like CARTO's, rebuilds the CommonJS entries so that an import of
another entry's file becomes a relative `require` of that entry's bundle:
`dist/index.cjs` is `require("./legacy/index.cjs")`. The node test bundles the
entries with the script's own options and checks the root has no relative
package import.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
…cjs.mjs Takes #11181's module build script and goes back to relative imports: the DOM root imports `../reconciler/index` and the map roots `../index`, which the script turns into requires of `./reconciler/index.cjs` and `../index.cjs`, so no published file imports `@deck.gl/react` by package name. The root keeps the renderer, so #11181's root-to-legacy test doesn't apply; the entries test now bundles with the script's options and also checks the source has no package-name self imports. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
|
Generated by Claude Code |
ibgreen
left a comment
There was a problem hiding this comment.
Retested 0c13a10: the CommonJS context issue from my earlier review is fixed. I emitted the module, ran the actual build-cjs.mjs, packed it, and loaded both entries from an extracted consumer package with real React and stubbed deck dependencies. All runtime export identities (including default) match, only one context is created, and the cross-entry useWidget control now registers successfully. This is focused packaging verification, not a full repository build/browser run; declaration emission used noCheck.
One migration limitation remains: a consumer using moduleResolution: "node" can import the root again, but switching that import to @deck.gl/react/legacy still produces TS2307. The package has no root-level legacy declaration or typesVersions mapping; its exports map is only honored by newer resolution modes. I verified root and /legacy both resolve with node16/bundler, while only root resolves with node.
Since this entry is specifically intended to let existing applications migrate before the root changes, could we add the legacy declaration mapping (and a packed consumer test), or document the required resolution-mode change? This is distinct from the now-fixed root self-import regression.
TypeScript's `node` resolution ignores `exports`, so `@deck.gl/react/legacy` failed with TS2307 for apps still on it. `typesVersions` now maps `legacy` to `dist/legacy/index.d.ts`. A node test checks that every `exports` subpath has a `typesVersions` entry for the same declarations. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
|
Thanks for retesting. Reproduced the TS2307 and fixed it in 74936d3: Checked with a packed consumer ( For CI, Generated by Claude Code |
Takes #11181's `typesVersions` fix and its test, and maps every renderer subpath (`/mapbox`, `/maplibre`, `/google-maps`, the component subpaths and `/reconciler`), so they resolve under `moduleResolution: node` too. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LGNhMnSJ94uYgx7ihcVwPn
ibgreen
left a comment
There was a problem hiding this comment.
Verified the typesVersions fix at 74936d3. In a freshly extracted packed consumer, both root and /legacy resolve and the named/default component and props-type imports compile under node, node16, and bundler. The packed CJS checks also still pass: all export identities match, there is one context, and the cross-entry widget hook registers successfully. Both findings from my earlier reviews are addressed.
Verification scope: focused module emission using the repository's append-extension transforms (noCheck for emission), the actual CJS build helper, and TypeScript consumer checks with skipLibCheck; runtime checks used real React with stubbed deck dependencies. This is not a full local repository/browser test pass. The hosted test workflow for this head is successful.
…bpath # Conflicts: # docs/whats-new.md

Closes #11039
Background
In v10 the package root becomes the React renderer (#11036), and the current API stays at
@deck.gl/react/legacy. This adds that subpath first, so apps can move to it before the root changes.Change List
@deck.gl/react/legacysubpath export, same API as the rootsrc/legacy, re-exported from the rootbuild-cjs.mjsmodule build script: the CommonJS root requires./legacy/index.cjsinstead of inlining a second copy, so both entries share one React contexttsconfigand vitest aliases for the subpathVerified with
yarn lint, theheadlesstests fortest/modules/react, and a clean build of the module's ES and CommonJS entries, and thenodetest that bundles both CommonJS entries.Generated by Claude Code
Note
Low Risk
Low risk refactoring that adds a legacy subpath export for the current React API without modifying runtime behavior.
Overview
Prepares for the upcoming v10 React Fiber renderer by exposing the existing React API at
@deck.gl/react/legacywhile preserving full backwards compatibility at the package root.The React module's source files have been relocated to
src/legacy/, re-exported fromsrc/index.ts, and published via new package./legacysubpath exports and TypeScripttypesVersionsdefinitions. A custom CommonJS build script (build-cjs.mjs) ensures the root bundle requires the/legacyCommonJS entry rather than inlining a second copy, preventing split React context instances.Reviewed by Cursor Bugbot for commit 1328563. Bugbot is set up for automated code reviews on this repo. Configure here.
Generated by Claude Code