mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #160] [MERGED] fix: register MDX plugin at top level to fix transform ordering #360
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#360
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/160
Author: @NathanDrake2406
Created: 2/27/2026
Status: ✅ Merged
Merged: 3/4/2026
Merged by: @southpolesteve
Base:
main← Head:fix/mdx-plugin-ordering📝 Commits (4)
62c1026fix: register MDX plugin at top level to fix transform ordering740617fMerge remote-tracking branch 'origin/main' into fix/mdx-plugin-orderingb2f6833address review: add config proxy, remove dead resolveId, fix comment separationea0597eadd E2E test for MDX import transform ordering📊 Changes
5 files changed (+78 additions, -8 deletions)
View changed files
📝
packages/vinext/src/index.ts(+29 -8)➕
tests/e2e/app-router/mdx.spec.ts(+21 -0)➕
tests/fixtures/app-basic/app/mdx-test/content.mdx(+6 -0)➕
tests/fixtures/app-basic/app/mdx-test/page.tsx(+9 -0)📝
tests/pages-router.test.ts(+13 -0)📄 Description
Summary
@mdx-js/rolluprunning too late in the Vite plugin pipeline, causing MDX files to fail to compilevinext:mdxproxy plugin in the top-level plugin array withenforce: 'pre'instead of returning the MDX plugin from theconfig()hookresolveIdandtransformto the real@mdx-js/rollupinstance, which is created duringconfig()and stored in a shared variableFixes #77
Details
Root cause: The MDX plugin was returned from
vinext:config'sconfig()hook viaviteConfig.plugins. Plugins merged fromconfig()hooks land late in the pipeline — aftervite:import-analysishas already tried (and failed) to process.mdximports.Fix: Instead of returning the plugin from
config(), avinext:mdxproxy plugin is registered directly in the top-level plugin array returned byvinext(). It hasenforce: 'pre', guaranteeing itsresolveIdandtransformhooks run beforevite:import-analysis. The proxy handles both function-style and object-style Rollup hooks (i.e.{ handler, order }form).Test plan
pnpm run build)pnpm run lint— 0 warnings, 0 errors)pnpm run typecheck)pnpm test— 50 files, 2051 tests passed, 3 skipped)vinext:mdxplugin exists withenforce: 'pre'and is inert when no MDX delegate is set.mdxfiles inapp/🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.