Skip to content

Conversation

@zhiyuanzmj
Copy link
Member

@zhiyuanzmj zhiyuanzmj commented Dec 8, 2025

const Comp = defineVaporComponent({
  setup() {
    // expose
    return {
      foo: 1
    }
  },
  render() {
    return <div />
  }
})

const comp = new Comp()
comp.exposeProxy.foo === 1

Copilot AI review requested due to automatic review settings December 8, 2025 08:27
@coderabbitai
Copy link

coderabbitai bot commented Dec 8, 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.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

Size Report

Bundles

File Size Gzip Brotli
compiler-dom.global.prod.js 85.2 kB 29.9 kB 26.4 kB
runtime-dom.global.prod.js 108 kB 40.5 kB 36.5 kB
vue.global.prod.js 166 kB 60.5 kB 53.9 kB

Usages

Name Size Gzip Brotli
createApp (CAPI only) 48.2 kB 18.8 kB 17.2 kB
createApp 57.2 kB 22 kB 20.1 kB
createApp + vaporInteropPlugin 96.1 kB (+106 B) 35.5 kB (+46 B) 31.9 kB (+43 B)
createVaporApp 42.4 kB (+391 B) 15.6 kB (+155 B) 14.2 kB (+136 B)
createSSRApp 61.6 kB 23.8 kB 21.7 kB
defineCustomElement 63.3 kB 23.8 kB 21.7 kB
overall 71.9 kB 27.2 kB 24.8 kB

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 8, 2025

Open in StackBlitz

@vue/compiler-core

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

@vue/compiler-dom

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

@vue/compiler-sfc

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

@vue/compiler-ssr

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

@vue/compiler-vapor

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

@vue/reactivity

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

@vue/runtime-core

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

@vue/runtime-dom

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

@vue/runtime-vapor

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

@vue/server-renderer

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

@vue/shared

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

vue

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

@vue/compat

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

commit: f8be210

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enables defineVaporComponent to support concurrent use of both setup and render functions, allowing components to return state from setup that can be consumed by a render function. Previously, the setup function parameter was explicitly checked, but the new implementation uses a more flexible condition based on whether the setup result is a block.

Key changes:

  • Removed the setupFn parameter from handleSetupResult function
  • Modified the production code path to handle setup functions that return non-block state alongside render functions
  • Updated conditional logic from checking !setupFn to checking !isBlock(setupResult) for determining when to call the render function

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ErrorCodes.RENDER_FUNCTION,
)
// support setup fn and render fn co-usage for defineComponent expose
if (!isBlock(setupResult) && component.render) {
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Missing devtoolsRawSetupState assignment for production devtools support.

The dev-only path at lines 965-966 sets instance.devtoolsRawSetupState when __DEV__ || __FEATURE_PROD_DEVTOOLS__ is true. This production code path should have the same assignment to ensure devtools work correctly in production builds with devtools enabled.

Suggestion: Add before line 979:

if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
  instance.devtoolsRawSetupState = setupResult
}
Suggested change
if (!isBlock(setupResult) && component.render) {
if (!isBlock(setupResult) && component.render) {
if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
instance.devtoolsRawSetupState = setupResult
}

Copilot uses AI. Check for mistakes.
Comment on lines 978 to 992
if (!isBlock(setupResult) && component.render) {
instance.setupState = setupResult
instance.block =
callWithErrorHandling(
component.render,
instance,
ErrorCodes.RENDER_FUNCTION,
[
instance.setupState,
instance.props,
instance.emit,
instance.attrs,
instance.slots,
],
) || []
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Missing test coverage for the new setup + render co-usage functionality in production mode.

While there's an existing test at line 420 in component.spec.ts that tests setup + render together, it only verifies dev warnings for non-existent property access. The new production code path (lines 978-992) lacks test coverage for:

  1. Verifying that setupState properties (especially refs) are properly accessible and unwrapped in the render function in production mode
  2. Testing that the render function receives the correct parameters in the expected order
  3. Ensuring devtools integration works correctly with devtoolsRawSetupState

Consider adding a test that:

  • Sets __DEV__ = false
  • Creates a component with both setup (returning refs/reactive state) and render functions
  • Verifies the render function can access and use the setup state correctly

Copilot uses AI. Check for mistakes.
zhiyuanzmj and others added 2 commits December 8, 2025 16:33
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@edison1105 edison1105 added version: minor scope: vapor related to vapor mode labels Dec 8, 2025
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 version: minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants