[GH-ISSUE #659] rsc:scan-strip parses MDX files as JS before @mdx-js/rollup transforms them, causing parse errors #138

Closed
opened 2026-05-06 12:37:34 +02:00 by BreizhHardware · 0 comments

Originally created by @keufcp on GitHub (Mar 22, 2026).
Original GitHub issue: https://github.com/cloudflare/vinext/issues/659

Environment

  • vinext: 0.0.34
  • @vitejs/plugin-rsc: 0.5.21
  • @mdx-js/rollup: (installed, auto-detected by vinext)

Problem

When using import.meta.glob to dynamically load MDX files in an RSC page,
the rsc:scan-strip plugin attempts to parse .mdx files as JavaScript
before @mdx-js/rollup has a chance to transform them. This causes a parse error.

Error

[plugin rsc:scan-strip] src/content/posts/2025/08/20/second-post/index.mdx
Error: Parse error @:1:1

The MDX files contain standard frontmatter (YAML between ---) and JSX syntax
(e.g. <span className='text-red-500'>), which are valid MDX but invalid JavaScript.

Root cause

rsc:scan-strip runs before @mdx-js/rollup in the plugin pipeline,
so it sees raw MDX instead of the transformed JS output.

Reproduction

  1. Create an App Router project with MDX content files containing frontmatter
  2. Use import.meta.glob('/src/content/posts/**/*.mdx') in a lib file
  3. Run vite build

Expected behavior

@mdx-js/rollup should transform MDX files to JS before rsc:scan-strip processes them,
or rsc:scan-strip should skip non-JS files that will be handled by other plugins.

Workaround

None found without changing the content file structure.

Originally created by @keufcp on GitHub (Mar 22, 2026). Original GitHub issue: https://github.com/cloudflare/vinext/issues/659 ## Environment - vinext: 0.0.34 - @vitejs/plugin-rsc: 0.5.21 - @mdx-js/rollup: (installed, auto-detected by vinext) ## Problem When using `import.meta.glob` to dynamically load MDX files in an RSC page, the `rsc:scan-strip` plugin attempts to parse `.mdx` files as JavaScript before `@mdx-js/rollup` has a chance to transform them. This causes a parse error. ## Error ``` [plugin rsc:scan-strip] src/content/posts/2025/08/20/second-post/index.mdx Error: Parse error @:1:1 ``` The MDX files contain standard frontmatter (YAML between `---`) and JSX syntax (e.g. `<span className='text-red-500'>`), which are valid MDX but invalid JavaScript. ## Root cause `rsc:scan-strip` runs before `@mdx-js/rollup` in the plugin pipeline, so it sees raw MDX instead of the transformed JS output. ## Reproduction 1. Create an App Router project with MDX content files containing frontmatter 2. Use `import.meta.glob('/src/content/posts/**/*.mdx')` in a lib file 3. Run `vite build` ## Expected behavior `@mdx-js/rollup` should transform MDX files to JS before `rsc:scan-strip` processes them, or `rsc:scan-strip` should skip non-JS files that will be handled by other plugins. ## Workaround None found without changing the content file structure.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/vinext#138
No description provided.