Skip to content

import.meta.glob (and dynamic MDX imports) not transformed in RSC build #611

@keufcp

Description

@keufcp

Environment

  • vinext: 0.0.32
  • vite: 8.0.1
  • @vitejs/plugin-rsc: 0.5.21
  • @cloudflare/vite-plugin: latest
  • React: 19.2.x

Problem

In an App Router project with dynamic routes (e.g. [year]/[month]/[day]/[slug]/page.tsx),
MDX files cannot be loaded dynamically in the RSC build environment.

Attempt 1: Dynamic import with template literal

await import(`@/content/posts/${year}/${month}/${day}/${slug}/index.mdx`)

Error at runtime:

No such module "@/content/posts/..."

Attempt 2: import.meta.glob

// src/lib/mdx-loader.ts
export const mdxModules = import.meta.glob('@/content/posts/**/*.mdx', { eager: true })

Error at runtime:

TypeError: (intermediate value).glob is not a function

import.meta.glob is not being transformed by the RSC build pipeline (rolldown),
and reaches the Workers runtime as-is, causing a runtime error.

Expected behavior

import.meta.glob should be statically transformed at build time in the RSC environment,
as it is in standard Vite builds.

Workaround

None found. The nextra-docs-template example uses static imports only,
which is not viable for blog-style dynamic routing.

Notes

  • @mdx-js/rollup is configured correctly (auto-detected by vinext)
  • Static MDX imports (as in nextra-docs-template) work fine
  • The issue is specific to the RSC build environment; the transformation
    that Vite normally applies to import.meta.glob does not occur there

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