-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
defineExpose
attributes are not available from options API methods called from first template render in production build, despite it working in Vite dev mode
#6707
Comments
Mixing script setup and options API like this is invalid. We will make this fail in dev in a future release. See a similar discussion in #6677 |
A lint can also help, but might be a bit complex? Oh well, this will make migration difficult for us due to widespread use of mixins that are difficult to convert. Any suggestions on how to ease migration if such dual usage should not be done? |
you can use a normal setup() function, if that helps. |
That will help. Although |
You'll need to convert the mixins sometime, as you can't use mixins in Composition API, yes. I'd likely try and convert one mixin into a composable, then inject that via // use it just for composables from mixins
setup() {
return {
...useMyComposableFromAMixin()
}
},
// rest of existing Options API ... and once all mixins are transformed, then migrate components themselves to composition API - if that make sense for you at all. |
Yeah. And using them via splatting saves from needing to make a mixin shim for the old code that uses them. Thanks! |
I'll close this in favor of #6677 which tracks the underlying issue. |
Vue version
3.2.39
Link to minimal reproduction
https://github.com/segevfiner/vue-define-expose-bug
Steps to reproduce
pnpm dev
, open the page, TheBar: {{ bar() }}
in the components used inHomeView
renders correctly.pnpm build
&pnpm preview
,Bar: {{ bar() }}
throws an exception.What is expected?
It should work. It works in
dev
, so it should work inbuild
as well.What is actually happening?
It throws:
System Info
Any additional comments?
This seems to happen due to the exposed attributes not being exposed/defined on
this
before running the render function/template for the first time in the production build, although they are available properly indev
mode, and they have proper type definitions, which makes it seem like this should work.There is no warning at all about this not working in a production build, and the type checking and linting passes.
The text was updated successfully, but these errors were encountered: