Skip to content

refactor(core): share the target compile pipeline behind createTargetCompiler - #107

Closed
jonkwheeler wants to merge 1 commit into
mainfrom
jon/create-target-compiler
Closed

jonkwheeler wants to merge 1 commit into
mainfrom
jon/create-target-compiler

Conversation

@jonkwheeler

@jonkwheeler jonkwheeler commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add createTargetCompiler(descriptor) in @tsrx/core, owning the shared parse → specialize → analyze → transform pipeline plus the Volar/editor variant (typeOnly, preserveParens/keywordTokens, moduleScopedHookComponents: false, withPlatformTypes)
  • React, Preact, Solid, and Vue index.js files collapse to export const { parse, compile, compile_to_volar_mappings } = createTargetCompiler(platform) — each transform.js now exports its JsxPlatform descriptor instead of an instantiated transform
  • The two test helpers that hand-built the pipeline (and had already drifted: to_ts vs typeOnly) now go through the same seam; inspect-origins asserts on the Volar mappings the language server consumes instead of decoding raw VLQ
  • New focused suite at the seam: cross-stage diagnostic aggregation, ast stripping, platform specialization, and Volar flag-forcing
  • Drops the pipeline's dedupeMappings call (currently a no-op); the export remains for external consumers
  • Adds CONTEXT.md domain glossary (compile pipeline, platform descriptor, target vs consumer compiler, Volar compile)

Test plan

  • pnpm test --project tsrx-utils (645 tests, incl. both collapsed helpers + new suite)
  • pnpm test — tsrx-react / tsrx-preact / tsrx-solid / tsrx-vue (2,137 tests via the shared compile harness)
  • pnpm test — language-server, typescript-plugin, vite-plugin-react, vite-plugin-solid (275 consumer-side tests)
  • pnpm typecheck (all 30 package configs)
  • pnpm format:check

Generated with Devin


Note

Medium Risk
Unifies compile and Volar behavior across all framework targets; React/Preact editor output now follows the same forced Volar hook-scoping as Solid/Vue, so regressions would show up in language tooling rather than runtime bundles.

Overview
Introduces createTargetCompiler(platform) in @tsrx/core, which owns the shared parse → specialize platform → analyze → transform flow and the editor compile_to_volar_mappings path (type-only transform, Volar-grade parse options, moduleScopedHookComponents: false, optional withPlatformTypes).

React, Preact, Solid, and Vue drop ~100 lines of duplicated entry-point code; each package now export const { parse, compile, compile_to_volar_mappings } = createTargetCompiler(platform), with transform.js exporting the JsxPlatform descriptor instead of a pre-built transform.

Adds TargetCompiler / factory typings, a changeset, CONTEXT.md glossary, and focused tests at the factory seam (diagnostic aggregation, ast stripping, platform specialization, Volar vs client hook-helper shaping). Internal test helpers route through the same factory; inspect-origins asserts on Volar mappings instead of hand-decoded source maps. The shared Volar path no longer wraps dedupeMappings (already a no-op).

Reviewed by Cursor Bugbot for commit dacb634. Bugbot is set up for automated code reviews on this repo. Configure here.

…Compiler

Every target package re-implemented the same
parse → specialize → analyze → transform pipeline (plus the Volar
variant), and two test helpers hand-built copies that had already
drifted. createTargetCompiler(descriptor) owns the orchestration in
@tsrx/core; each target now contributes only its platform descriptor.

The Volar path forces moduleScopedHookComponents off for every target,
matching what Solid and Vue already did locally. The pipeline no longer
calls the no-op dedupeMappings; its export remains for external
consumers.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@vercel

vercel Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
tsrx-website Ready Ready Preview Sep 13, 2026 11:46pm UTC
tsrx-website-mcp Ready Ready Preview Sep 13, 2026 11:46pm UTC

Request Review

@leonidaz

Copy link
Copy Markdown
Contributor

Let's hold off with these changes. As I mentioned before we don't wanna do compiler work now. Plus this doesn't work with Ripple as Ripple transformers live in the ripple repo.

We're also about to do somewhat big changes.

So, let's keep it open for now. But I wanna make the changes first and then come back to this and put up a pr for Ripple before we go ahead.

I'm assuming Octane may be affected too actually, so may need a pr there too.

@jonkwheeler

Copy link
Copy Markdown
Contributor Author

Sounds good — closing this out.

Fair point on Ripple: the factory assumes the shared createJsxTransform machinery, which Ripple doesn't go through since its transformers live in the ripple repo — as shaped, this seam doesn't reach it. Same presumably for Octane.

The branch (jon/create-target-compiler) stays put. Once your changes land it'll be clearer what a seam that works for the external targets needs to look like — happy to revisit then.

This branch was successfully deployed

2 active deployments
Preview – tsrx-website-mcp — dacb6349 Deployed Sep 13, 2026 by vercel[bot]
Preview – tsrx-website — dacb6349 Deployed Sep 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants