Skip to content

feat: implement defineVaporCustomElement#14017

Merged
edison1105 merged 29 commits intominorfrom
edison/feat/defineVaporCustomElement
Nov 10, 2025
Merged

feat: implement defineVaporCustomElement#14017
edison1105 merged 29 commits intominorfrom
edison/feat/defineVaporCustomElement

Conversation

@edison1105
Copy link
Copy Markdown
Member

No description provided.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Oct 24, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch edison/feat/defineVaporCustomElement

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Oct 24, 2025

Size Report

Bundles

File Size Gzip Brotli
compiler-dom.global.prod.js 84.9 kB 29.8 kB 26.3 kB
runtime-dom.global.prod.js 108 kB (+695 B) 40.4 kB (+222 B) 36.3 kB (+144 B)
vue.global.prod.js 166 kB (+695 B) 60.4 kB (+231 B) 53.7 kB (+162 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 47.9 kB 18.7 kB 17.1 kB
createApp 57 kB 21.9 kB 20 kB
createApp + vaporInteropPlugin 90.9 kB (+237 B) 33.9 kB (+94 B) 30.6 kB (+8 B)
createVaporApp 34.6 kB (+252 B) 13.2 kB (+124 B) 12.1 kB (+117 B)
createSSRApp 61.3 kB 23.7 kB 21.6 kB
defineCustomElement 63.1 kB (+486 B) 23.8 kB (+133 B) 21.7 kB (+126 B)
overall 72.1 kB 27.3 kB 24.9 kB

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Oct 24, 2025

Open in StackBlitz

@vue/compiler-core

npm i https://pkg.pr.new/@vue/compiler-core@14017

@vue/compiler-dom

npm i https://pkg.pr.new/@vue/compiler-dom@14017

@vue/compiler-sfc

npm i https://pkg.pr.new/@vue/compiler-sfc@14017

@vue/compiler-ssr

npm i https://pkg.pr.new/@vue/compiler-ssr@14017

@vue/compiler-vapor

npm i https://pkg.pr.new/@vue/compiler-vapor@14017

@vue/reactivity

npm i https://pkg.pr.new/@vue/reactivity@14017

@vue/runtime-core

npm i https://pkg.pr.new/@vue/runtime-core@14017

@vue/runtime-dom

npm i https://pkg.pr.new/@vue/runtime-dom@14017

@vue/runtime-vapor

npm i https://pkg.pr.new/@vue/runtime-vapor@14017

@vue/server-renderer

npm i https://pkg.pr.new/@vue/server-renderer@14017

@vue/shared

npm i https://pkg.pr.new/@vue/shared@14017

vue

npm i https://pkg.pr.new/vue@14017

@vue/compat

npm i https://pkg.pr.new/@vue/compat@14017

commit: 59ba80c

@edison1105 edison1105 force-pushed the edison/feat/defineVaporCustomElement branch from a819eeb to e808152 Compare October 24, 2025 03:55
@netlify
Copy link
Copy Markdown

netlify bot commented Oct 29, 2025

Deploy Preview for vue-sfc-playground failed. Why did it fail? →

Name Link
🔨 Latest commit c423a43
🔍 Latest deploy log https://app.netlify.com/projects/vue-sfc-playground/deploys/690174ce6fb6fb0008aa81fc

@edison1105 edison1105 force-pushed the edison/feat/defineVaporCustomElement branch from c423a43 to 642e253 Compare October 29, 2025 02:09
@edison1105 edison1105 force-pushed the edison/feat/defineVaporCustomElement branch from 642e253 to 9b5e134 Compare October 29, 2025 02:15
defineSSRCustomElement can only be used with custom elements that have pre-rendered declarative shadow root
await assertInteraction('my-element-async')
})

test('work with Teleport (shadowRoot: false)', async () => {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defineSSRCustomElement can only be used with custom elements that have pre-rendered declarative shadow root. It requires shadowRoot: true.

@edison1105 edison1105 marked this pull request as ready for review October 29, 2025 09:48
@edison1105 edison1105 added ✨ feature request New feature or request version: minor scope: vapor related to vapor mode labels Oct 29, 2025
@edison1105 edison1105 moved this to Vapor in Next Minor Nov 3, 2025
@edison1105 edison1105 merged commit 615db5e into minor Nov 10, 2025
17 checks passed
@edison1105 edison1105 deleted the edison/feat/defineVaporCustomElement branch November 10, 2025 03:49
@github-project-automation github-project-automation bot moved this from Vapor to Done in Next Minor Nov 10, 2025
@hamedniroomand
Copy link
Copy Markdown

Hi @edison1105
I’ve created a web component using the Vapor build as shown below:

import { defineVaporCustomElement, type VaporComponent } from 'vue';
import { PrimaryButton } from '@/features/shared';

const element = defineVaporCustomElement(PrimaryButton as unknown as VaporComponent);
customElements.define('primary-button', element);

However, I’m not seeing any difference in the bundle size between the Vapor and non-Vapor builds.
Additionally, the following packages are still present in shared-hash.js:
• @vue/shared v3.6.0-beta.1
• @vue/runtime-core v3.6.0-beta.1
• @vue/runtime-vapor v3.6.0-beta.1

Is this the expected behavior, or am I missing something in my setup / using Vapor incorrectly?

vue version is 3.6.0-beta.1 and vite is 8.0.0-beta.4

@edison1105
Copy link
Copy Markdown
Member Author

edison1105 commented Dec 23, 2025

Could you please provide a minimal repro?

@pixeloution
Copy link
Copy Markdown

@hamedniroomand @edison1105

I was looking at this, and put together a stackblitz to illustrate the issue It contains a minimal component, and the ability to build vapor or normal mode by the vite --mode flag:

vite build --mode vapor
vite build --mode default

Output was verified to contain the expected component. Output bundle sizes are similar, with vapor-mode being larger:

dist/default-component.ce.js  59.90 kB │ gzip: 22.46 kB
dist/vapor-component.ce.js  67.00 kB │ gzip: 22.79 kB

I added a custom one-off plugin to see what's being bundled (path starts partially clipped for readability):

// default mode
[
  'node_modules/@vue/reactivity/node_modules/@vue/shared/dist/shared.esm-bundler.js',
  'node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js',
  'node_modules/@vue/runtime-core/node_modules/@vue/shared/dist/shared.esm-bundler.js',
  'node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js',
  'node_modules/@vue/runtime-dom/node_modules/@vue/shared/dist/shared.esm-bundler.js',
  'node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js',
  'src/default/component.vue?vue&type=script&setup=true&lang.ts'
]
// vapor mode
[
  'node_modules/@vue/reactivity/node_modules/@vue/shared/dist/shared.esm-bundler.js',
  'node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js',
  'node_modules/@vue/runtime-core/node_modules/@vue/shared/dist/shared.esm-bundler.js',
  'node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js',
  'node_modules/@vue/runtime-dom/node_modules/@vue/shared/dist/shared.esm-bundler.js',
  'node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js',
  'node_modules/@vue/runtime-vapor/node_modules/@vue/shared/dist/shared.esm-bundler.js',
  'node_modules/@vue/runtime-vapor/dist/runtime-vapor.esm-bundler.js',
  'src/vapor/vapor-component.vue?vue&type=script&vapor=true&setup=true&lang.ts'
]

I hope this is helpful to you. I'm not entirely sure what the expected result is but reading about it, I thought vapor mode would produce a smaller bundle size.

@edison1105
Copy link
Copy Markdown
Member Author

@pixeloution
Thank you for providing the reproduction. I carefully examined the packaged dist output, and these modules are not fully imported; only the necessary code is being introduced. However, there are indeed some issues in the vapor build output where certain code is not being tree-shaken, but these problems have already been fixed and will be released in beta.2 soon. You can test with https://pkg.pr.new/vue@d62d86d first.
Below is a comparison of the output packaged using https://pkg.pr.new/vue@d62d86d.

dist/default-component.ce.js  58.60 kB │ gzip: 22.07 kB
dist/vapor-component.ce.js  51.09 kB │ gzip: 17.93 kB

zhiyuanzmj added a commit to vuejs/vue-jsx-vapor that referenced this pull request Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: vapor related to vapor mode ✨ feature request New feature or request version: minor

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants