Skip to content

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

@keufcp

Description

@keufcp

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions