fix: custom extensions work with the native compiler - #301
Conversation
… JSX transform received the raw module id while only the lazy/refresh passes used the borrowed-extension filename built for unknown extensions, so @dom-expressions/compiler rejected e.g. .mdx files with "Unknown file extension" (solidjs#297); the JSX transform now gets the same borrowed filename Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: df05dcf The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
ryansolid
left a comment
There was a problem hiding this comment.
Verified against #297: reproduced the "Unknown file extension" failure on next.24 with a .mdx build under compiler: 'native', and confirmed this branch fixes it (compiled template present in the output). The analysis is right — nativeFilename was built for exactly this case and the lazy/refresh passes already consumed it; the JSX transform was the one holdout. For standard extensions nativeFilename === id, and the ssr example suite passes 12/12, so no behavior change there. Approving. Non-blocking: none of our suites exercise options.extensions, so this has no regression coverage — I'll take that as a follow-up on our side (it needs a new fixture, which is beyond the scope of this fix). Thanks!
Fixes #297.
Problem
solidPlugin({ compiler: 'native', extensions: ['.mdx'] })fails on every custom-extension file with:The native compiler picks its parser dialect from the file extension, which is why the transform already builds a borrowed-extension filename for ids it doesn't recognize (
foo.mdx→foo.mdx.jsx, or.tsxwhen the extension is registered withtypescript: true). The lazy and refresh passes use it — but the native JSX transform itself still passed the rawid, so@dom-expressions/compilerrejected the file.compiler: 'babel'was unaffected because that path names its parser plugins explicitly, so the filename never matters.Fix
Pass the same borrowed
nativeFilenameto the JSX transform that the lazy and refresh passes already receive. For standard extensionsnativeFilename === id, so nothing changes there (sourcemapsourcesincluded).Verification
Reproduced with a minimal Vite build of an
.mdxentry containing JSX undercompiler: 'native',extensions: ['.mdx']:🤖 Generated with Claude Code