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

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

merged 4 commits into from Dec 1, 2022

Conversation

windsonR
Copy link
Contributor

Description

When use @vitejs/plugin-vue2-jsx to transform jsx code, this plugin will not generate tag code in jsx file.

For example:

export default {
  render(){
    return (
       <some-tag/>
    )
  }
}

@vitejs/plugin-vue2-jsx will generate this code into

export default {
render(){
return h("some-tag")
}
}

unplugin's resolveVue2 function's RegExp
will not generate h function which generated by @vitejs/plugin-vue2-jsx.

This PR change the resolveVue2's RegExp to make sure unplugin will read the h function.

Linked Issues

Additional context

This RegExp looks have a problem.
It will match c not _c. and i don't know how to make the new RegExp match _c.but in my project, i test it(_c or c) has no difference.

@windsonR windsonR requested a review from antfu as a code owner November 23, 2022 08:32
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

@antfu antfu merged commit 383b11a into unplugin:main Dec 1, 2022
MaloLebrin added a commit to MaloLebrin/naturopathe-camion-nuxt3 that referenced this pull request Jan 29, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[unplugin-vue-components](https://togithub.com/antfu/unplugin-vue-components)
| [`^0.22.9` ->
`^0.23.0`](https://renovatebot.com/diffs/npm/unplugin-vue-components/0.22.9/0.23.0)
|
[![age](https://badges.renovateapi.com/packages/npm/unplugin-vue-components/0.23.0/age-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://badges.renovateapi.com/packages/npm/unplugin-vue-components/0.23.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://badges.renovateapi.com/packages/npm/unplugin-vue-components/0.23.0/compatibility-slim/0.22.9)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://badges.renovateapi.com/packages/npm/unplugin-vue-components/0.23.0/confidence-slim/0.22.9)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>antfu/unplugin-vue-components</summary>

###
[`v0.23.0`](https://togithub.com/antfu/unplugin-vue-components/releases/tag/v0.23.0)

[Compare
Source](https://togithub.com/antfu/unplugin-vue-components/compare/v0.22.12...v0.23.0)

#####    🚀 Features

- Support nuxt@3.0.0  -  by
[@&#8203;NexZhu](https://togithub.com/NexZhu) in
[unplugin/unplugin-vue-components#569
[<samp>(05196)</samp>](https://togithub.com/antfu/unplugin-vue-components/commit/05196ec)
- Add types fields  -  by [@&#8203;sxzz](https://togithub.com/sxzz) in
[unplugin/unplugin-vue-components#592
[<samp>(d8a54)</samp>](https://togithub.com/antfu/unplugin-vue-components/commit/d8a54a5)

#####    🐞 Bug Fixes

- Generator dts (no such file or directory)  -  by
[@&#8203;lishaobos](https://togithub.com/lishaobos) in
[unplugin/unplugin-vue-components#585
[<samp>(5db2b)</samp>](https://togithub.com/antfu/unplugin-vue-components/commit/5db2b6e)
- **collapseSamePrefixes**: Missing collapse when prefix did not match
from beginning  -  by [@&#8203;DrJume](https://togithub.com/DrJume) in
[unplugin/unplugin-vue-components#563
[<samp>(a6e70)</samp>](https://togithub.com/antfu/unplugin-vue-components/commit/a6e700c)
- **tdesign**: Add pagination-mini resolver  -  by
[@&#8203;uyarn](https://togithub.com/uyarn) in
[unplugin/unplugin-vue-components#575
[<samp>(d997e)</samp>](https://togithub.com/antfu/unplugin-vue-components/commit/d997e55)
- **varlet-ui**: Side effects use full path  -  by
[@&#8203;haoziqaq](https://togithub.com/haoziqaq) in
[unplugin/unplugin-vue-components#581
[<samp>(74c11)</samp>](https://togithub.com/antfu/unplugin-vue-components/commit/74c1118)

#####     [View changes on
GitHub](https://togithub.com/antfu/unplugin-vue-components/compare/v0.22.12...v0.23.0)

###
[`v0.22.12`](https://togithub.com/antfu/unplugin-vue-components/releases/tag/v0.22.12)

[Compare
Source](https://togithub.com/antfu/unplugin-vue-components/compare/v0.22.11...v0.22.12)

#####    🚀 Features

- Compatible with
[@&#8203;vitejs/plugin-vue2-jsx](https://togithub.com/vitejs/plugin-vue2-jsx)
 -  by [@&#8203;windsonR](https://togithub.com/windsonR) and
[@&#8203;antfu](https://togithub.com/antfu) in
[unplugin/unplugin-vue-components#557
[<samp>(383b1)</samp>](https://togithub.com/antfu/unplugin-vue-components/commit/383b11a)
- **tdesign**: Add exclude option  -  by
[@&#8203;Sight-wcg](https://togithub.com/Sight-wcg) in
[unplugin/unplugin-vue-components#554
[<samp>(48c33)</samp>](https://togithub.com/antfu/unplugin-vue-components/commit/48c3374)
- **varlet-ui**: Support loading-bar  -  by
[@&#8203;haoziqaq](https://togithub.com/haoziqaq) in
[unplugin/unplugin-vue-components#566
[<samp>(1735b)</samp>](https://togithub.com/antfu/unplugin-vue-components/commit/1735b6f)

#####    🐞 Bug Fixes

- Use `globs` option cannot resolve index.vue  -  by
[@&#8203;satrong](https://togithub.com/satrong) and
[@&#8203;antfu](https://togithub.com/antfu) in
[unplugin/unplugin-vue-components#536
[<samp>(f8918)</samp>](https://togithub.com/antfu/unplugin-vue-components/commit/f891820)

#####     [View changes on
GitHub](https://togithub.com/antfu/unplugin-vue-components/compare/v0.22.11...v0.22.12)

###
[`v0.22.11`](https://togithub.com/antfu/unplugin-vue-components/releases/tag/v0.22.11)

[Compare
Source](https://togithub.com/antfu/unplugin-vue-components/compare/v0.22.9...v0.22.11)

*No significant changes*

#####     [View changes on
GitHub](https://togithub.com/antfu/unplugin-vue-components/compare/v0.22.10...v0.22.11)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://app.renovatebot.com/dashboard#github/MaloLebrin/naturopathe-camion-nuxt3).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xMTEuMSIsInVwZGF0ZWRJblZlciI6IjM0LjExMS4xIn0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants