Repository navigation
refactor: rewrite the compiler with oxc and magic-string - #2
Merged
Merged
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
The compiler parses with oxc-parser and applies every rewrite as a span
edit over a MagicString, which also gives a hires source map. This drops
@babel/core and @solid-mediakit/shared from the dependencies, and
babel-plugin-tester and @babel/preset-typescript from the tests.
Behavior changes from the Babel version:
- Object property values inside a DynamicImage become arguments. Babel
skipped them, so style={{ color: color() }} left color() unresolved in
the server function.
- A shorthand property keeps its key ({ a } becomes { a: r0 }).
- An optional chain is one argument.
- TypeScript type annotations are skipped instead of being searched for
identifiers.
- Generated server functions follow source order.
- A module without a DynamicImage is returned unchanged (null).
The fixture runner compares prettier-formatted output, and new fixtures
cover object values, optional chains and TypeScript.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
import { createMemo as memo } does not bind createMemo, but the compiler
treated it as present and the generated code threw a ReferenceError.
Generated imports from one source are now one statement, and a fixture
without an output fails unless UPDATE=1 is set.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lxsmnsyc
force-pushed
the
feat/oxc-compiler
branch
from
November 11, 2026 14:14
d603f0a to
e73a387
Compare
davedbase
marked this pull request as ready for review
November 11, 2026 14:21
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.
Depends on #1
Rewrites the
DynamicImagecompiler with oxc-parser and magic-string. This drops Babel from the package's dependencies and gives the unplugin a source map.Changes
oxc-parserand apply each rewrite as a span edit over aMagicString. The output comes with a hires source map.src/compiler/ast.tsskips TypeScript type keys, so types are no longer searched for identifiers.unplugin-utilsinstead of@solid-mediakit/shared, with the same default include and exclude.babel-plugin-tester. It compares prettier-formatted output.UPDATE=1writes the outputs; without it, a fixture with no output fails.object-values,optional-chain,typescript,aliased-import.Behavior changes from the Babel version:
DynamicImagebecome server function arguments. The Babel version skipped them, sostyle={{ color: color() }}leftcolor()unresolved inside the server function.{ a }becomes{ a: r0 }.user?.profile.nameis one argument.DynamicImageis returned unchanged (the transform returns null).import { createMemo as memo }no longer counts as importingcreateMemo, so the compiler adds its own import. Before, the generated code threw a ReferenceError.Proof
object-valueson the parent branch: the server function rendersstyle={{ color: color(), background, [r0]: size }}, wherecolor,backgroundandsizedo not exist on the server.pnpm --filter @solidjs/ogp testpasses, and the fixture rendersstyle={{ color: r0, background: r1, [r2]: r3 }}with all four values passed in.Changeset
patch(compiler-on-oxc.md): the existing compiler behaves differently.Checks
npm pack --dry-runlists the same files.dist/unplugin.jscompiles a sample.tsxroute and returns a source map.Roadmap
Cost
@babel/core,@solid-mediakit/shared. Removed dev dependencies:babel-plugin-tester,@babel/preset-typescript,@types/babel__core.oxc-parser,magic-string,unplugin-utils. New dev dependency:prettier(fixture comparison).Risk
multiple-images.<DynamicImage>nested inside another one stays as a literal element in the generated server function, with no error. This PR does not change that, and it is left for a separate fix.no-unsafe-*lint rules, because it works on an untyped structural AST, as in solid-styled.🤖 Generated with Claude Code