mirror of
https://github.com/vercel-labs/json-render.git
synced 2026-10-30 07:54:05 +08:00
Fixes a React runtime error where `useRef` was null due to multiple React instances being bundled. ## Changes Made - **Vite configuration**: Added `resolve.dedupe` for `react` and `react-dom` in `examples/mcp/vite.config.ts` to ensure only one instance of React is used during bundling - **React version constraints**: Changed from exact versions (`19.2.3`) to flexible ranges (`^19.0.0`) in `examples/mcp/package.json` to improve compatibility - **Build entry point**: Added new `build-app-html-entry.ts` file and updated `tsup.config.ts` to include it as a build target - **Package exports**: Added `./build-app-html` export path in `packages/mcp/package.json` - **Minor fixes**: Updated Next.js type reference path in stripe-app example The root cause was React being duplicated in the bundle, causing hooks like `useRef` to fail when components tried to access React's internal state from the wrong instance. The `dedupe` configuration ensures Vite resolves all React imports to the same module instance. Fixes #190
19 lines
440 B
TypeScript
19 lines
440 B
TypeScript
import { defineConfig } from "vite";
|
|
import react from "@vitejs/plugin-react";
|
|
import { viteSingleFile } from "vite-plugin-singlefile";
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
|
|
export default defineConfig({
|
|
plugins: [react(), tailwindcss(), viteSingleFile()],
|
|
resolve: {
|
|
dedupe: ["react", "react-dom"],
|
|
},
|
|
build: {
|
|
outDir: "dist",
|
|
emptyOutDir: false,
|
|
rollupOptions: {
|
|
input: "index.html",
|
|
},
|
|
},
|
|
});
|