<template>
<component :is="ElInput"/>
</template>
<script setup lang="ts">
import { resolveComponent as _resolveComponent } from "vue";
const ElInput = _resolveComponent('el-input')
</script>
since I have read the source code, I have found that writing this way can meet my expectations, but I need to rename the resolveComponent to _ resolveComponent.
Suggested solution
function resolveVue3(code: string, s: MagicString) {
const results: ResolveResult[] = []
/**
* when using some plugin like plugin-vue-jsx, resolveComponent will be imported as resolveComponent1 to avoid duplicate import
*/
for (const match of code.matchAll(/_resolveComponent[0-9]*\("(.+?)"\)/g)) {
const matchedName = match[1]
if (match.index != null && matchedName && !matchedName.startsWith('_')) {
const start = match.index
const end = start + match[0].length
results.push({
rawName: matchedName,
replace: resolved => s.overwrite(start, end, resolved),
})
}
}
return results
}
I hope this rule is Match 0 or 1 times_, such as /_?resolveComponent[0-9]*\("(.+?)"\)/g
Clear and concise description of the problem
since I have read the source code, I have found that writing this way can meet my expectations, but I need to rename the resolveComponent to _ resolveComponent.
Suggested solution
I hope this rule is Match 0 or 1 times
_
, such as/_?resolveComponent[0-9]*\("(.+?)"\)/g
Alternative
No response
Additional context
No response
Validations