Reproduction
Minimal Reproduction
# 1. Scaffold
bunx create-react-router@latest repro --template remix-run/react-router-templates/minimal --yes
cd repro
# 2. Upgrade to Vite 8
bun add -d vite@^8.0.3
# 3. Enable bundledDev in vite.config.ts
cat > vite.config.ts << 'EOF'
import { reactRouter } from "@react-router/dev/vite";
import { defineConfig } from "vite";
export default defineConfig({
experimental: { bundledDev: true },
plugins: [reactRouter()],
});
EOF
# 4. Run dev
bunx react-router dev
Expected
Dev server starts normally.
Actual
Build fails with parse errors from es-module-lexer. Every .tsx route file triggers failures because the lexer receives untransformed TSX/TypeScript source.
Cause
The react-router:build-client-route plugin calls es-module-lexer in its transform hook to detect route exports (loader, action, default, etc.):
// @react-router/dev — build-client-route plugin
const [, exportSpecifiers] = esModuleLexer(code);
In standard dev mode, Vite's unbundled pipeline transpiles TSX → JS before this hook runs. In experimental.bundledDev, Rolldown feeds raw .tsx source to the plugin before any transpilation, and es-module-lexer cannot parse TypeScript/JSX syntax.
Environment
- React Router: 7.14.0
- Vite: 8.0.x
- No additional plugins required — the default template is enough to reproduce
Possible Fixes
- Replace
es-module-lexer with Oxc parser for export detection (already a Vite 8/Rolldown dependency, handles TS/TSX natively)
- Pre-strip types before lexing (e.g.,
oxc-transform) when bundled dev is detected
- Defer export analysis until after the transform pipeline has transpiled the source
Reproduction
Minimal Reproduction
Expected
Dev server starts normally.
Actual
Build fails with parse errors from
es-module-lexer. Every.tsxroute file triggers failures because the lexer receives untransformed TSX/TypeScript source.Cause
The
react-router:build-client-routeplugin callses-module-lexerin itstransformhook to detect route exports (loader,action,default, etc.):In standard dev mode, Vite's unbundled pipeline transpiles TSX → JS before this hook runs. In
experimental.bundledDev, Rolldown feeds raw.tsxsource to the plugin before any transpilation, andes-module-lexercannot parse TypeScript/JSX syntax.Environment
Possible Fixes
es-module-lexerwith Oxc parser for export detection (already a Vite 8/Rolldown dependency, handles TS/TSX natively)oxc-transform) when bundled dev is detected