-
-
Notifications
You must be signed in to change notification settings - Fork 379
Closed as not planned
Labels
enhancementNew feature or requestNew feature or request
Description
Clear and concise description of the problem
<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
Alternative
No response
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request