[GH-ISSUE #611] import.meta.glob (and dynamic MDX imports) not transformed in RSC build #131

Closed
opened 2026-05-06 12:37:28 +02:00 by BreizhHardware · 1 comment

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

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
Originally created by @keufcp on GitHub (Mar 20, 2026). Original GitHub issue: https://github.com/cloudflare/vinext/issues/611 ## 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 ```ts await import(`@/content/posts/${year}/${month}/${day}/${slug}/index.mdx`) ``` **Error at runtime:** ``` No such module "@/content/posts/..." ``` ### Attempt 2: `import.meta.glob` ```ts // 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
Author
Owner

@keufcp commented on GitHub (Mar 22, 2026):

Thank you for the quick fix!

<!-- gh-comment-id:4106848763 --> @keufcp commented on GitHub (Mar 22, 2026): Thank you for the quick fix!
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#131
No description provided.