Skip to content

feat: add vue-vapor compiler for Vue 3.6 Vapor mode - #438

Open
daopk wants to merge 1 commit into
unplugin:mainfrom
daopk:feat/vue-vapor-compiler
Open

feat: add vue-vapor compiler for Vue 3.6 Vapor mode#438
daopk wants to merge 1 commit into
unplugin:mainfrom
daopk:feat/vue-vapor-compiler

Conversation

@daopk

@daopk daopk commented Aug 25, 2026

Copy link
Copy Markdown

Adds a vue-vapor compiler that emits Vapor mode components instead of virtual-DOM ones:

Icons({ compiler: 'vue-vapor' })

The existing vue3 compiler emits a VDOM component, and a VDOM component in a Vapor tree doesn't fail loudly. It renders nothing at all, no error or warning. So a Vapor app currently has no working option short of hand-rolling a CustomCompiler.

Notes:

  • Compiles with @vue/compiler-vapor and wraps the resulting render in defineVaporComponent, mirroring how vue3.ts wraps compileTemplate output.
  • Reuses the existing handleSVGId helper, so per-instance gradient/mask ids behave exactly as with vue3. The one difference: the idMap is injected as a render-function local rather than into setup(), since module scope is shared by every instance of an icon, which is the collision handleSVGId exists to avoid.
  • @vue/compiler-vapor is an optional peer dependency, same treatment as @vue/compiler-sfc.
  • guessCompiler is left alone: Vapor is opted into per SFC and isn't detectable, so this stays explicit.

Linked Issues

fixes #428

Additional context

test/vueVapor.test.ts asserts invariants rather than snapshotting, since Vapor codegen is still churning across 3.6.0-rc.*.

Also verified end-to-end: mounted the generated components with createVaporApp on vue@3.6.0-rc.5 in jsdom. Two instances of a gradient icon got four distinct uicons-* ids, each url(#…) resolving to its own instance's gradient.

The part worth the most scrutiny is the string surgery on the compiled render function. It throws rather than emitting a broken module if the expected shape isn't found, but it's still coupled to pre-release codegen output. Happy to rework it if you'd prefer a different approach.

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

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.

Vue 3 vapor support

1 participant