refactor: split React surface behind ./react subpath (core barrel react-free)#6
Closed
orveth wants to merge 1 commit into
Closed
refactor: split React surface behind ./react subpath (core barrel react-free)#6orveth wants to merge 1 commit into
orveth wants to merge 1 commit into
Conversation
…ct-free)
Packaging change only — no runtime/logic edits. Importing the default
package entry now pulls ZERO react into the module graph; the React
provider/contexts/hooks move behind an opt-in "<pkg>/react" subpath.
- New src/lib/react.ts barrel: re-exports full core + the React surface
(OpenSecretProvider/Context, OpenSecretDeveloper/Context, useOpenSecret,
useOpenSecretDeveloper, and React-surface types).
- src/lib/index.ts: drop the React re-exports; default barrel is core-only.
After this it no longer (transitively) imports ./main, ./developer,
./context, ./developerContext, or ./util.
- Delete orphan src/lib/util.ts (imported react; nothing imported it).
- package.json: add "./react" export, repoint default artifact to
opensecret-core.{es,cjs}.js, make react/react-dom optional peers,
0.1.0 -> 0.2.0 (breaking surface change for React consumers only).
- vite.config.ts: two lib entries (index -> opensecret-core,
react -> opensecret-react). Multi-entry lib mode can't emit UMD, so
emit ["es","cjs"]; vite-plugin-dts emits index.d.ts + react.d.ts.
- Repoint the in-repo demo app (AI/App/main.tsx) at ./lib/react.
Invariant proven: grep for react in dist/opensecret-core.* = 0 matches;
in dist/opensecret-react.* = >0. Core index.d.ts retains every symbol
agicash imports. agicash needs no code change for react-removal.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
9ed90ec to
3b05e9c
Compare
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Standalone PR — targets
masterdirectly. One commit, replayed cleanly ontomaster. The react-removal does not depend on the storage (#4) or crypto-uuid (#5) PRs — it only coincidentally editssrc/lib/index.tsin a different region (the storage block #4 adds sits near the top; this PR removes the React export block ~80 lines lower), so it replays ontomasterwithout conflict. #4/#5 proceed independently. Re-verified on themasterbase — not assumed. DO NOT publish — gudnuf-gated.What changed
Packaging change only — no runtime/logic edits. Importing the default package entry now pulls ZERO react into the module graph; the React provider/contexts/hooks move behind an opt-in
<pkg>/reactsubpath.src/lib/react.tsbarrel — re-exports the full core (so/reactstays a drop-in superset) plus the React surface:OpenSecretProvider/OpenSecretContext,OpenSecretDeveloper/OpenSecretDeveloperContext,useOpenSecret,useOpenSecretDeveloper, and the React-surface types.src/lib/index.ts— dropped the React re-exports; the default barrel is now core-only. It no longer (transitively) imports./main,./developer,./context,./developerContext, or./util. All core exports retained.src/lib/util.ts— it importedreact(useEffect/useRef) and nothing imported it.package.json— added the./reactexport; repointed the default artifact toopensecret-core.{es,cjs}.js; madereact/react-domoptional peers (peerDependenciesMeta);0.1.0→0.2.0.vite.config.ts— two lib entries (index→opensecret-core,react→opensecret-react). Multi-entry lib mode cannot emit UMD → dropped UMD, emit["es","cjs"](consumers are ESM/bundler; nothing used the UMD global). React stays externalized exactly as before.vite-plugin-dtsnow emits bothindex.d.tsandreact.d.ts.src/AI.tsx,src/App.tsx,src/main.tsx) repointed at./lib/react(they consume the React surface). No library code; keepsbun run devand the dts pass clean.Version / breaking-change note
0.2.0is breaking only for React consumers (they migrate<pkg>→<pkg>/react). There are none in agicash — agicash imports only the core functions, which stay on the default entry. agicash needs no code change for react-removal.Gate proof (re-run on the
masterbase; repo has notestscript)bun install+bun run build→ green (tsc + vite, exit 0).dist/containsopensecret-core.{es,cjs}.js,opensecret-react.{es,cjs}.js,index.d.ts,react.d.ts.THE INVARIANT — react in the FULL core graph (entry + its shared chunk, chunk filenames chased):
The core entries reference only the shared chunk (
index-L0b06DVu.js/index-DwqL0JUQ.cjs), and that chunk is itself react-free, so the core graph is closed and react-free in both formats.Runtime smoke:
bun -e 'await import("./dist/opensecret-core.es.js")'→ loads clean (55 exports;configure/signMessageare functions;OpenSecretProviderisundefinedon the core bundle, confirming the React surface lives only behind/react).Core export-set intact —
dist/index.d.tsstill declares every symbol agicash imports (configure, fetchUser, signIn, signInGuest, signOut, signUp, signUpGuest, convertGuestToUserAccount, confirmPasswordReset, requestPasswordReset, requestNewVerificationCode, verifyEmail, initiateGoogleAuth, handleGoogleCallback, generateThirdPartyToken, getPrivateKey, getPrivateKeyBytes, getPublicKey, signMessage) + typesLoginResponse, UserResponse. The React symbols are absent fromindex.d.tsand present inreact.d.ts.Out of scope (do NOT)
No
npm publish, no agicash catalog-pin bump (gudnuf-gated, held for explicit trigger). No agicash / wallet-SDK / consumer edits. No upstreamOpenSecretCloud/OpenSecret-SDKchanges. No React provider/hook logic touched — only their export location moved.🤖 Generated with Claude Code