mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #668] [MERGED] fix: skip MDX files during RSC scan-build to prevent parse errors #756
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#756
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/668
Author: @Divkix
Created: 3/23/2026
Status: ✅ Merged
Merged: 3/29/2026
Merged by: @james-elicx
Base:
main← Head:fix/issue-659-mdx-scan-strip-parses-mdx📝 Commits (9)
e38d65bfix: skip MDX files during RSC scan-build to prevent parse errors (issue #659)af6f644fix(mdx): return stub module for undetected MDX files during scan-buildf873091fix(mdx): lazily compile globbed mdx importsa0a2b05fix review issues722a144fix: use absolute path for root tsconfig alias to fix import.meta.glob resolutionf5f2bdbrefactor: address review feedback on MDX lazy initialization3ed5fe8refactor: address review feedback on MDX handling49a368fdocs: clarify mdx delegate fallback comment8a90748chore: trigger ci📊 Changes
4 files changed (+309 additions, -134 deletions)
View changed files
📝
packages/vinext/src/index.ts(+87 -39)📝
tests/pages-router.test.ts(+56 -6)📝
tests/tsconfig-path-alias-build.test.ts(+161 -84)📝
tests/tsconfig-paths-vite8.test.ts(+5 -5)📄 Description
Summary
Root cause
When import.meta.glob loads MDX files outside app/ or pages/ directories in an RSC build, rsc:scan-strip (from @vitejs/plugin-rsc) runs on all files including MDX. It uses es-module-lexer.parse() which fails on MDX frontmatter (---) and JSX syntax. The lazy on-demand initialization ensures MDX is compiled before rsc:scan-strip sees it.
Companion fix: tsconfig alias root resolution
Fixed toViteAliasReplacement() to return the normalized absolute path when an alias target resolves to the project root (e.g., @/* -> ./*). Previously it returned "/" which Vite could misinterpret as filesystem root on Linux. This affects all tsconfig alias resolution.
Testing
Regression test verified: fails on main without the fix, passes with the fix.
Closes #659
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.