Repository navigation
fix(plugins): extract MDX after the MDX compiler - #960
Merged
Merged
Conversation
The engine rejected `.mdx` filenames as an unknown extension. It now reads an `.mdx` path as what an MDX compiler (`@mdx-js/loader`, `@mdx-js/rollup`, `@next/mdx`) makes of it: an ES module of JavaScript that may keep JSX. Every place that took a source type from a path goes through the same function. The plugins extract MDX in a phase after the MDX plugin runs: - Vite: a `devup-ui:mdx` plugin with `enforce: 'post'`, sharing the source transform's extraction - webpack (and Next.js with webpack): a `.mdx` rule with `enforce: 'post'` and the source rule's loader - Rsbuild: a `.mdx` transform with `order: 'post'` and the source transform's handler Next.js with Turbopack, the Bun plugin and the pre-build class reservation scan still skip MDX; the limitations page says so. Refs #686 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
… probe The MDX post rule runs the source loader a second time, so the relocated install probe now sees three loaders that must all resolve to the installed plugin and share its plugin-utils. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Conflicts: - rsbuild-plugin/src/plugin.ts: kept this branch's shared extractModule handler for the source and MDX post transforms, using main's hoisted excludeRegex (#914) in it. - vite-plugin/src/plugin.ts: kept both extractModule (this branch) and main's removeSource (#951); extractModule uses main's excludeRegex, and the pre transform stays a SOURCE_FILE_RE check plus extractModule. - webpack-plugin/src/__tests__/plugin.test.ts (no textual conflict): the MDX post-rule test now expects #914's exact package exclude regex. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
owjs3901
added a commit
that referenced
this pull request
Nov 17, 2026
Resolve the conflicts with #924 and #960. The Bun plugin keeps bunConditions, withDependencyImports and sourceLoader and takes main's writeDataFiles, which rejects a theme error on the first load. In Vite, webpack and Rsbuild main moved the source transform into one handler shared with the MDX post transform; that handler now matches SOURCE_FILE_REGEX, so .mts/.cts/.cjs modules are extracted, and Rsbuild's handler still sets the environment's module resolver. Main's Rsbuild MDX test now looks the source transform up by SOURCE_FILE_REGEX. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
owjs3901
added a commit
that referenced
this pull request
Nov 17, 2026
Resolve the conflict with #960 in Rsbuild: main moved the source transform into one handler shared with the MDX post transform. That handler now also registers devup.json and the configs it extends, existing ones with addDependency and missing ones with addMissingDependency, so MDX modules reload the theme too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
owjs3901
added a commit
that referenced
this pull request
Nov 17, 2026
Resolve the conflict with #960 in webpack: main builds the source loader rule once and reuses it for the MDX post loader. That rule now passes the project `root` to the loader, so MDX modules get root-relative extraction ids and dependencies as well. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4 of 6 tasks
owjs3901
added a commit
that referenced
this pull request
Nov 17, 2026
…rent merges (#990) * test(rsbuild-plugin): expect the MDX post transform in the hook order #957 recorded the hook order before #960 added an order: post transform for .mdx modules. Both landed, so main registers two source transforms and the test failed. Label the MDX transform and expect it last. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * test(wasm): count removeFile in the documented argument positions #952 counted 45 validated argument positions; #951, merged alongside it, added removeFile.filename, so main validates 46 and the ABI gate failed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PLG-06(MDX 부분)과 NXT-19(#686):
.mdx파일의 Devup 컴포넌트가 추출되지 않고 런타임 placeholder("Cannot run on the runtime")에 닿던 문제를, MDX 컴파일러가 만든 JavaScript를 추출하도록 해서 고칩니다. 안전하게 할 수 있는 부분만 구현하고 나머지는 문서화했습니다.재검증 (origin/main
1160bf646)SourceType::from_path가 모르는.mdx를Unknown extension으로 거부했습니다.ts/tsx/js/mjs/jsx만 받습니다. 게다가 Vite 플러그인은enforce: 'pre'라.mdx를 넣으면 raw MDX를 받게 됩니다.변경
parsing::path_source_type가.mdx(대소문자 무시)를 JSX를 허용하는 JavaScript ES module(SourceType::jsx())로 읽습니다. MDX 컴파일러 출력은 JSX runtime 호출(_jsx/_jsxs/_jsxDEV)이고,jsx옵션을 쓰면 JSX가 남습니다. 둘 다 이미 지원하는 형태입니다. path에서 source type을 정하던 곳(barrel, imported styled, pragma, module reference, stylesheet dispatch, dead properties)도 이 함수를 씁니다.enforce: 'post'인devup-ui:mdx플러그인을 반환 배열 끝에 추가했습니다.@mdx-js/rollup이 normal이든pre이든(landing처럼) 그 뒤에 실행됩니다. 추출 본문은extractModule로 꺼내 기존pretransform과 같이 씁니다. 기존 transform 동작은 바뀌지 않습니다..mdxrule을enforce: 'post'로 추가했습니다. normal loader(@mdx-js/loader,@next/mdx의[babel, mdx])가 다 끝난 뒤 실행됩니다.{ test: /\.mdx$/i, order: 'post' }transform을 추가했습니다.하지 않은 것 (문서화)
@next/mdx는turbopack.rules['{*,next-mdx-rule}']에as: '*.tsx'로 규칙을 넣고, 기존 rules를 spread로 합칩니다. 그래서 Devup의Object.assign과 키가 겹치지 않아 서로 덮어쓰지는 않습니다. 하지만as뒤의 모듈이 Devup의*.{tsx,...}규칙을 어떤 경로/순서로 다시 타는지는 실제 Next 빌드 없이 확인할 수 없습니다. 기존의.mdx.[tj]sx?$제외(9813476 "Fix loader issue")가 바로 그 경로를 막고 있어서 이번에는 손대지 않았습니다. extractor가 이제.mdx를 받으므로, 후속 작업은 이 제외를 풀고 Next+@next/mdxe2e로 순서를 확인하는 것입니다..mdx를 읽을 수 없으므로 계속 제외합니다. 문서 자신의 클래스는 컴파일될 때 이름이 정해집니다. Vite/webpack/Rsbuild의 단일 프로세스 빌드에서는 문제가 없습니다.겹치는 open PR
/\.(tsx|ts|js|mjs|jsx)$/)를.mts/.cts/.cjs로 넓힙니다. 이 PR은 origin/main 기준이고 MDX용 rule/transform을 따로 추가하므로 내용은 겹치지 않지만, Vite transform filter 줄과 webpack/Rsbuild rule 블록에서 텍스트 충돌이 날 수 있습니다. 이 PR은 Vite transform 본문을extractModule로 옮겼으니 rebase할 때 그 점을 보세요.Test plan
reads_mdx_as_compiled_javascript(.mdx/.MDX)와extracts_compiled_mdx(JSX runtime 출력, dev runtime 출력, JSX가 남은 출력 세 가지: Box 추출,has_devup_uitrue)cargo test -p extractor --tests -j 2,cargo clippy -p extractor --all-targets -- -D warnings,cargo fmt --all -- --checkdevup-ui:mdx가post이고.mdx(쿼리 포함)만 추출하는지,pretransform은.mdx를 건너뛰는지 확인 (bun --config=./bunfig.vite.toml test packages/vite-plugin/src/__tests__/plugin.test.ts, 621 pass).mdxpost rule이 source rule의 loader를 쓰는지 확인, rule 수 2에서 3으로 (3513 pass).mdxpost transform이 source handler와 같은지 확인 (564 pass,plugin.ts100%)bunx tsc --noEmit(vite/webpack/rsbuild 플러그인),bunx prettier --check@mdx-js/rollup/@mdx-js/loadere2e는 CI에 맡깁니다Refs #686
🤖 Generated with Claude Code