unplugin-vue-components
unplugin-vue-components copied to clipboard
When the global variable and function definition parameter have the same name, the function parameter will be overwritten by the global variable. After troubleshooting, it is caused by the unplugin vue components plugin. Removing this plugin is normal
Describe the bug
When the global variable and function definition parameter have the same name, the function parameter will be overwritten by the global variable. After troubleshooting, it is caused by the unplugin vue components plugin. Removing this plugin is normal
<script setup lang="ts">
const a = 3
function test(a: Number, b: Number) {
// a的值应该是1才对 实际变成了3 有点离谱, 删掉unplugin-vue-components插件就正常了
console.log(a, b)
}
</script>
<template>
<button @click="test(1, 2)">
点我可复现
</button>
</template>
Reproduction
https://github.com/WormGirl/bug-report-unplugin-vue-components
System Info
System:
OS: Windows 10 10.0.19043
CPU: (16) x64 Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz
Memory: 16.88 GB / 31.79 GB
Binaries:
Node: 16.20.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.19.4 - C:\Program Files\nodejs\npm.CMD
pnpm: 8.6.10 - ~\AppData\Local\pnpm\pnpm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (116.0.1938.62)
Internet Explorer: 11.0.19041.1566
Used Package Manager
pnpm
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.
兄弟,你这个依赖安装不成功啊,确定 package.json 里面没有包含私有仓库的包
兄弟,你这个依赖安装不成功啊,确定 package.json 里面没有包含私有仓库的包
抱歉,是有几个私有的忘了删了,更新了,你重新拉下
兄弟,我这边没问题,你要么删除掉 lock 文件再安装试试?
兄弟,我这边没问题,你要么删除掉 lock 文件再安装试试?
兄弟,我这边没问题,你要么删除掉 lock 文件再安装试试?
兄弟,我上次就是删掉lock文件重装的
我打印的也是1 2 ,你加个debugger看看 ,很离谱的,运行时是3,2
const a = 3
function test(a: Number, b: Number) {
// a的值应该是1才对 实际变成了3 有点离谱
// eslint-disable-next-line no-debugger, no-restricted-syntax
debugger
console.log(a, b)
}
这个应该是 sourcemap 生成或者是 chrome 的问题:
你 debugger 源代码,函数 a 变量实则成为了 a2,所以会指向上面的 a,你自己打印 a2,还是 1,我觉得这个不用过多纠结
但是我删掉这个插件debugger就正常了 这是咋回事
感觉还是和这个插件有点关系
你把vite.config.ts里unplugin-vue-components/vite相关的删掉看下
重新验证了 就是debugger的时候不对 实际运行结果符合预期。。。可以的话还是麻烦看下啥原因 debugger不对也影响开发
提交 pr 了,是 sourceMap 精细度不够,等通过就好了
