feat: add vue-vapor compiler for Vue 3.6 Vapor mode - #438
Open
daopk wants to merge 1 commit into
Open
Conversation
|
|
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.
Adds a
vue-vaporcompiler that emits Vapor mode components instead of virtual-DOM ones:The existing
vue3compiler 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 aCustomCompiler.Notes:
@vue/compiler-vaporand wraps the resultingrenderindefineVaporComponent, mirroring howvue3.tswrapscompileTemplateoutput.handleSVGIdhelper, so per-instance gradient/mask ids behave exactly as withvue3. The one difference: theidMapis injected as a render-function local rather than intosetup(), since module scope is shared by every instance of an icon, which is the collisionhandleSVGIdexists to avoid.@vue/compiler-vaporis an optional peer dependency, same treatment as@vue/compiler-sfc.guessCompileris 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.tsasserts invariants rather than snapshotting, since Vapor codegen is still churning across3.6.0-rc.*.Also verified end-to-end: mounted the generated components with
createVaporApponvue@3.6.0-rc.5in jsdom. Two instances of a gradient icon got four distinctuicons-*ids, eachurl(#…)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.