Skip to content

fix(vue): preserve runtime props declarations in pages patchProps - #589

Merged
cpojer merged 1 commit into
voidzero-dev:mainfrom
0froq:fix/vue-pages-patchprops
Oct 26, 2026
Merged

cpojer merged 1 commit into
voidzero-dev:mainfrom
0froq:fix/vue-pages-patchprops

Conversation

@0froq

@0froq 0froq commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Fixes #557

Summary

Vue Pages generated patchProps assigned comp.props = Object.keys(props), which replaced components that already declare runtime props and dropped defaults, required flags, validators, and types. The __voidPatched guard then froze that stripped declaration.

Changes

  • Add hasRuntimePropsDeclaration() in generated SSR and client bundles before patching.
  • Skip overwriting comp.props when the component already has a non-empty runtime declaration.
  • Keep registering prop keys from page data only for type-only defineProps<T>() components that lack runtime props metadata.
  • Deduplicate the injected helper via PATCH_PROPS_RUNTIME in plugin-pages.ts.
  • Add unit tests that execute the generated patchProps from renderer and client modules.

Testing

  • pnpm exec vp test run packages/vue/test/unit/plugin-pages.test.ts
  • pnpm exec vp run --filter ./packages/vue typecheck

Fixes voidzero-dev#557

## Summary

Vue Pages generated `patchProps` assigned `comp.props = Object.keys(props)`, which replaced components that already declare runtime props and dropped defaults, required flags, validators, and types. The `__voidPatched` guard then froze that stripped declaration.

## Changes

- Add `hasRuntimePropsDeclaration()` in generated SSR and client bundles before patching.
- Skip overwriting `comp.props` when the component already has a non-empty runtime declaration.
- Keep registering prop keys from page data only for type-only `defineProps<T>()` components that lack runtime props metadata.
- Deduplicate the injected helper via `PATCH_PROPS_RUNTIME` in `plugin-pages.ts`.
- Add unit tests that execute the generated `patchProps` from renderer and client modules.

## Testing

- `pnpm exec vp test run packages/vue/test/unit/plugin-pages.test.ts`
- `pnpm exec vp run --filter ./packages/vue typecheck`

Co-authored-by: froQ <sayhola@froq.me>

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you!

@cpojer
cpojer merged commit 8c311dd into voidzero-dev:main Oct 26, 2026
2 checks passed
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] Page rendering overwrites component props declarations, removing defaults and validation

3 participants