ITADN

TanStack Start + Vite dev search crashes on CJS default imports from remark/unified deps

#3262Openmengxi-ream 创建于 2026-05-11
M
mengxi-reamcommented
### To Reproduce I'm seeing the same CJS interop failure discussed in #3056 and #3205, but in a TanStack Start app on Vite 8 rather than the Waku template. 1. Use a TanStack Start app with Fumadocs' TanStack provider: ```tsx import { RootProvider } from "fumadocs-ui/provider/tanstack" ``` 2. Use these relevant dependency versions: ```json { "@tanstack/react-start": "1.167.65", "fumadocs-core": "16.8.8", "fumadocs-ui": "16.8.8", "fumadocs-mdx": "15.0.2", "vite": "8.0.12", "react": "19.2.6", "react-dom": "19.2.6" } ``` Environment: ```text Node: v24.12.0 pnpm: 10.33.4 OS: macOS / darwin arm64 ``` 3. Run the Vite dev server and open a page that mounts `RootProvider` / Fumadocs search. ### Current vs. Expected behavior Current: the browser crashes during hydration with a Vite error overlay: ```text The requested module '/@fs/.../node_modules/.pnpm/debug@4.4.3/node_modules/debug/src/browser.js?v=...' does not provide an export named 'default' ``` The first failing import is from the browser search path through `remark-parse > mdast-util-from-markdown > micromark`, where `micromark/dev/lib/create-tokenizer.js` default-imports `debug`. After forcing that dependency to be pre-bundled, the same pattern appears for other CJS dependencies used by the Fumadocs search/markdown chain: - `unified` default-importing `extend` - `hast-util-to-estree` default-importing `style-to-js` Expected: Fumadocs search should hydrate in Vite dev without every consumer needing to know and pre-bundle these nested CJS dependencies manually. ### Workaround This app-level Vite workaround fixes the dev crash for me: ```ts optimizeDeps: { include: [ "fumadocs-core > remark > remark-parse > mdast-util-from-markdown > micromark > debug", "fumadocs-core > unified > extend", "fumadocs-core > hast-util-to-estree > style-to-js", ], }, ``` This seems related to the note in #3205 that Fumadocs itself has to be excluded from dependency optimization to avoid duplicating React contexts, which also prevents Vite from wrapping nested CJS deps unless users include them explicitly. ### Which area(s) are affected? (Select all that apply) Search, TanStack Start integration, Vite dev ### Additional context This was verified with `pnpm --filter @read-frog/www type-check` and `pnpm --filter @read-frog/www build` passing after applying the workaround. The dev page and search UI also render cleanly after adding the `optimizeDeps.include` entries.
1 条评论