feat(abacus-react): add separate /static export path for React Server Components
- Create src/static.ts entry point with only server-compatible exports - Configure Vite to build separate static.es.js and static.cjs.js bundles - Add @soroban/abacus-react/static export path in package.json - Enables RSC usage without importing client-side hooks/animations Fixes build errors when importing AbacusStatic in Next.js App Router pages without "use client" directive. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
9d322301ef
commit
ed69f6b917
|
|
@ -10,6 +10,11 @@
|
|||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.es.js",
|
||||
"require": "./dist/index.cjs.js"
|
||||
},
|
||||
"./static": {
|
||||
"types": "./dist/static.d.ts",
|
||||
"import": "./dist/static.es.js",
|
||||
"require": "./dist/static.cjs.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
/**
|
||||
* Server Component compatible exports
|
||||
* This entry point only exports components that work without "use client"
|
||||
*/
|
||||
|
||||
export { AbacusStatic } from './AbacusStatic'
|
||||
export type { AbacusStaticConfig } from './AbacusStatic'
|
||||
export { AbacusStaticBead } from './AbacusStaticBead'
|
||||
export type { StaticBeadProps } from './AbacusStaticBead'
|
||||
|
||||
// Re-export shared utilities that are safe for server components
|
||||
export { numberToAbacusState } from './AbacusUtils'
|
||||
export type {
|
||||
AbacusCustomStyles,
|
||||
BeadConfig,
|
||||
PlaceState,
|
||||
ValidPlaceValues,
|
||||
} from './AbacusReact'
|
||||
|
|
@ -8,10 +8,12 @@ export default defineConfig(async () => {
|
|||
plugins: [react()],
|
||||
build: {
|
||||
lib: {
|
||||
entry: resolve(__dirname, "src/index.ts"),
|
||||
name: "AbacusReact",
|
||||
entry: {
|
||||
index: resolve(__dirname, "src/index.ts"),
|
||||
static: resolve(__dirname, "src/static.ts"),
|
||||
},
|
||||
formats: ["es", "cjs"],
|
||||
fileName: (format) => `index.${format}.js`,
|
||||
fileName: (format, entryName) => `${entryName}.${format === "es" ? "es" : "cjs"}.js`,
|
||||
},
|
||||
sourcemap: true,
|
||||
rollupOptions: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue