Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: compatible with @vitejs/plugin-vue2-jsx #557

Merged
merged 4 commits into from Dec 1, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/core/transforms/component.ts
Expand Up @@ -10,15 +10,15 @@ const debug = Debug('unplugin-vue-components:transform:component')
const resolveVue2 = (code: string, s: MagicString) => {
const results: ResolveResult[] = []

for (const match of code.matchAll(/_c\([\s\n\t]*['"](.+?)["']([,)])/g)) {
for (const match of code.matchAll(/[(_c)h]\([\s\n\t]*['"](.+?)["']([,)])/g)) {
const [full, matchedName, append] = match

if (match.index != null && matchedName && !matchedName.startsWith('_')) {
const start = match.index
const end = start + full.length
results.push({
rawName: matchedName,
replace: resolved => s.overwrite(start, end, `_c(${resolved}${append}`),
replace: resolved => s.overwrite(start, end, `${full.split('(')[0]}(${resolved}${append}`),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use group to capture it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have change it to group.
And I add a test for it.
please review it when you have time.
thanks

})
}
}
Expand Down