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

add jsx sync modifier #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
39 changes: 39 additions & 0 deletions README.md
Expand Up @@ -65,6 +65,45 @@ Vue.component('hello-world', {

More information available on [plugin's github page](https://github.com/nickmessing/babel-plugin-jsx-v-model).

### Supports sync modifier

Uses [babel-plugin-vue-jsx-sync](https://github.com/njleonzhang/babel-plugin-vue-jsx-sync) for supporting sync modifier.

Example:
```js
function a() {
return (
<div>
<component visible$sync={ this.test }>I am newbie</component>
</div>
)
}
```
is complied to:

```js
function a() {
return h(
"div",
null,
[h(
"component",
{
attrs: { visible: this.test },
on: {
"update:visible": $$val => {
this.test = $$val;
}
}
},
["I am newbie"]
)]
);
}
```

More information available on [plugin's github page](https://github.com/njleonzhang/babel-plugin-vue-jsx-sync).

## License

MIT &copy; [EGOIST](https://github.com/egoist)
2 changes: 2 additions & 0 deletions index.js
@@ -1,10 +1,12 @@
import VueJSX from 'babel-plugin-transform-vue-jsx'
import JsxEventModifiers from 'babel-plugin-jsx-event-modifiers'
import JsxVModel from 'babel-plugin-jsx-v-model'
import JsxSyncModifier from 'babel-plugin-vue-jsx-sync'

export default {
plugins: [
JsxEventModifiers,
JsxSyncModifier,
JsxVModel,
VueJSX
]
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -34,7 +34,8 @@
"babel-plugin-jsx-event-modifiers": "^2.0.2",
"babel-plugin-jsx-v-model": "^2.0.1",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-vue-jsx": "^3.5.0"
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-plugin-vue-jsx-sync": "^0.0.4"
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems it's still too young and lacks of tests?

Copy link
Author

Choose a reason for hiding this comment

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

@egoist yeah, it's young 😂 . I use it in my own project, and it works currently. I can add some unit tests, if you think it is necessary.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We should give it some time to mature first 😄

Copy link
Author

Choose a reason for hiding this comment

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

@egoist OK, Tnx for your time.

Copy link
Member

Choose a reason for hiding this comment

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

@egoist, maybe we can add sync to event-modifiers, what do you think?

Copy link
Member

Choose a reason for hiding this comment

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

@njleonzhang, if you could make a PR to event-modifiers, I'd be very grateful

Copy link
Author

Choose a reason for hiding this comment

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

@nickmessing, OK, I will try to make one after spring festival

},
"devDependencies": {
"bili": "^0.17.2"
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Expand Up @@ -154,6 +154,10 @@ babel-plugin-transform-vue-jsx@^3.5.0:
dependencies:
esutils "^2.0.2"

babel-plugin-vue-jsx-sync@^0.0.4:
version "0.0.4"
resolved "https://registry.npmjs.org/babel-plugin-vue-jsx-sync/-/babel-plugin-vue-jsx-sync-0.0.4.tgz#2641a13bbe6d6d96c942eb6b7ff5a5d6d52a4307"

babylon@^6.14.0, babylon@^6.15.0:
version "6.16.1"
resolved "https://registry.npmjs.org/babylon/-/babylon-6.16.1.tgz#30c5a22f481978a9e7f8cdfdf496b11d94b404d3"
Expand Down