[PR #357] [MERGED] fix(mdx): skip ?raw and other query imports in vinext:mdx transform #506

Closed
opened 2026-05-06 13:08:26 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/cloudflare/vinext/pull/357
Author: @james-elicx
Created: 3/8/2026
Status: Merged
Merged: 3/8/2026
Merged by: @james-elicx

Base: mainHead: fix/mdx-skip-query-imports


📝 Commits (1)

  • 44a5d84 fix(mdx): skip ?raw and other query imports in vinext:mdx transform

📊 Changes

2 files changed (+55 additions, -0 deletions)

View changed files

📝 packages/vinext/src/index.ts (+3 -0)
📝 tests/pages-router.test.ts (+52 -0)

📄 Description

Summary

  • @mdx-js/rollup strips the query string before matching file extensions, so without a guard it compiles foo.mdx?raw as MDX and returns compiled JSX instead of raw text
  • The vinext:mdx proxy's transform hook now returns early when id.includes('?'), matching Vite's own convention for query imports

Changes

packages/vinext/src/index.ts

  • Added if (id.includes('?')) return; as the first line of the vinext:mdx transform hook

tests/pages-router.test.ts

  • Added "vinext:mdx transform skips ids that contain a query string (regression: ?raw)" — asserts the real proxy plugin returns undefined for ?raw, ?url, and ?inline ids
  • Added "vinext:mdx proxy logic — ?raw guard prevents delegate from compiling query imports" — self-contained unit test with a mock delegate that demonstrates both the broken behavior (without guard) and the fixed behavior (with guard)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/cloudflare/vinext/pull/357 **Author:** [@james-elicx](https://github.com/james-elicx) **Created:** 3/8/2026 **Status:** ✅ Merged **Merged:** 3/8/2026 **Merged by:** [@james-elicx](https://github.com/james-elicx) **Base:** `main` ← **Head:** `fix/mdx-skip-query-imports` --- ### 📝 Commits (1) - [`44a5d84`](https://github.com/cloudflare/vinext/commit/44a5d84aea3deea707d9112ea4fafe87e8b09097) fix(mdx): skip ?raw and other query imports in vinext:mdx transform ### 📊 Changes **2 files changed** (+55 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/vinext/src/index.ts` (+3 -0) 📝 `tests/pages-router.test.ts` (+52 -0) </details> ### 📄 Description ## Summary - `@mdx-js/rollup` strips the query string before matching file extensions, so without a guard it compiles `foo.mdx?raw` as MDX and returns compiled JSX instead of raw text - The `vinext:mdx` proxy's `transform` hook now returns early when `id.includes('?')`, matching Vite's own convention for query imports ## Changes **`packages/vinext/src/index.ts`** - Added `if (id.includes('?')) return;` as the first line of the `vinext:mdx` `transform` hook **`tests/pages-router.test.ts`** - Added `"vinext:mdx transform skips ids that contain a query string (regression: ?raw)"` — asserts the real proxy plugin returns `undefined` for `?raw`, `?url`, and `?inline` ids - Added `"vinext:mdx proxy logic — ?raw guard prevents delegate from compiling query imports"` — self-contained unit test with a mock delegate that demonstrates both the broken behavior (without guard) and the fixed behavior (with guard) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 13:08:26 +02:00
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#506
No description provided.