-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
script-setup unnecessarily exposes vue api #3249
Comments
I think so. |
We can optimize this for vue's own APIs, but that happens for any import, and it does so by design. in
<template>
<div> {{ capitalize(props.title) }}</div>
</template>
<script setup>
import { defineProps } from 'vue'
import { capitalize } from 'lodash-es'
const props = defineProps()
</script> From a technical perspective we can optimize the compiler to exclude vue's own imports, but that may lead to situations were people get confused that they can do the above, but not this: <template>
<child @someEvent="($event) => emit('re-emitted-some-event', toRaw($event))"></child>
</template>
<script setup>
import { toRaw } from 'vue'
</script> While the above likely doesn't make much sense, and usage of most of the other Vue APIs in the template doesn't either, I'm willing to bet someone can find a scenario that makes sense, and then be confused by this special treatment of Vue's exports compared to others. |
Double <script> <script lang="ts">
import { ref } from 'vue'
</script>
<script setup lang="ts">
const expanded = ref(false)
</script> |
This no longer applies, see this playground's compiled JS output. |
Version
3.0.5
Steps to reproduce
is compiled into
What is expected?
Component's setup should not return vue's api functions such as reactive, watch, etc.
What is actually happening?
Compiler unnecessarily exposes vue's api functions.
The text was updated successfully, but these errors were encountered: