unplugin / unplugin-auto-import

Auto import APIs on-demand for Vite, Webpack and Rollup
MIT License
3.12k stars 193 forks source link

Auto imports doesn't work in script setup template #470

Open beqacrc opened 6 months ago

beqacrc commented 6 months ago

Note

// src/utils/lodash.ts
export const dummy = () => true;

export const _ = {
   dummy() {
     return true
   }
}
<script setup lang="ts">
console.log(dummy) // this works
</script>

<template>
{{ _.dummy }} this doesn't work
</template>

Describe the bug

When using unplugin-auto-import in a Vite project to automatically import dependencies, the _.isArray function from a file (src/utils/lodash.ts) is working correctly in the script context but fails in the template.

The issue manifests as follows:

In the script section ( Githubissues.

  • Githubissues is a development platform for aggregating issues.