[bug]在electron-vite打包的时候报错Cannot find name 'reactive'
Describe the bug
在electron-vite开发环境下正常使用,但是打包的时候报错Cannot find name 'reactive'
Reproduction
https://codesandbox.io/p/devbox/cool-bassi-qk7hd7?file=%2Faaaa%2Felectron-app%2Fsrc%2Frenderer%2Fsrc%2FApp.vue%3A8%2C1
System Info
在electron-vite开发环境下正常使用,但是打包的时候报错Cannot find name 'reactive'
Used Package Manager
npm
Validations
- [X] Follow our Code of Conduct
- [X] Read the Contributing Guide.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
- [X] The provided reproduction is a minimal reproducible of the bug.
复现环境打包的时候报错Cannot find name 'ref'
复现步骤: 1、cd aaaaa/electron-app 2、npm run build
https://codesandbox.io/p/devbox/cool-bassi-qk7hd7?file=%2Faaaa%2Felectron-app%2Fsrc%2Frenderer%2Fsrc%2FApp.vue%3A8%2C1 这个案例无法在线运行; 可在本地运行,具体步骤: 1、npm create @quick-start/electron@latest
2、选vue框架,其他全部选择yes 3、pnpm install 4、pnpm install unplugin-auto-import 5、在app.vue内容修改为
<script setup lang="ts">
const num = ref(1)
</script>
<template>
<div>{{ num }}</div>
</template>
6、配置unplugin-auto-import 7、可正常运行[npm run dev],但是不能正常打包[npm run build]
报错的原因是:直接运行build,此时还未生成auto-imports.d.ts,类型检查报错。 如果先运行dev,再运行build就可成功。原因是dev时,生成了类型文件。
It failed during typecheck because it could not detect the type of ref. So, you need to generate auto-imports.d.ts before checking.
When build is run, it will generate the auto-imports.d.ts file.