{"bugs":{"url":"https://github.com/vuejs/babel-plugin-transform-vue-jsx/issues"},"dist":{"shasum":"2c8bddce87a6ef09eaa59869ff1bfbeeafc5f88d","tarball":"https://registry.npmjs.org/babel-plugin-transform-vue-jsx/-/babel-plugin-transform-vue-jsx-4.0.1.tgz","fileCount":7,"integrity":"sha512-wbOz7ITB5cloLSjKUU1hWn8zhR+Dwah/RZiTiJY/CQliCwhowmzu6m7NEF+y5EJX/blDzGjRtZvC10Vdb3Q7vw==","signatures":[{"sig":"MEUCIQDycKwyTf5rMODMXYLOtyZ007mV6Z+YwGSlR1FIXLxbNwIgL7CHZXzJQ66y9w8DJaZ92QkuzzZXmblDJTljs/Tzpik=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1512349},"main":"index.js","name":"babel-plugin-transform-vue-jsx","files":["index.js","lib","dist"],"unpkg":"dist/babel-plugin-transform-vue-jsx.min.js","author":{"name":"Evan You"},"readme":"# babel-plugin-transform-vue-jsx [![CircleCI](https://img.shields.io/circleci/project/vuejs/babel-plugin-transform-vue-jsx.svg?maxAge=2592000)](https://circleci.com/gh/vuejs/babel-plugin-transform-vue-jsx)\n\n> Babel plugin for Vue 2.0 JSX\n\n### Babel Compatibility Notes\n\n- If using Babel 7, use 4.x\n- If using Babel 6, use 3.x\n\n### Requirements\n\n- Assumes you are using Babel with a module bundler e.g. Webpack, because the spread merge helper is imported as a module to avoid duplication.\n\n- This is mutually exclusive with `babel-plugin-transform-react-jsx`.\n\n### Usage\n\n``` bash\nnpm install\\\n  babel-plugin-syntax-jsx\\\n  babel-plugin-transform-vue-jsx\\\n  babel-helper-vue-jsx-merge-props\\\n  babel-preset-env\\\n  --save-dev\n```\n\nIn your `.babelrc`:\n\n``` json\n{\n  \"presets\": [\"env\"],\n  \"plugins\": [\"transform-vue-jsx\"]\n}\n```\n\nThe plugin transpiles the following JSX:\n\n``` jsx\n<div id=\"foo\">{this.text}</div>\n```\n\nTo the following JavaScript:\n\n``` js\nh('div', {\n  attrs: {\n    id: 'foo'\n  }\n}, [this.text])\n```\n\nNote the `h` function, which is a shorthand for a Vue instance's `$createElement` method, must be in the scope where the JSX is. Since this method is passed to component render functions as the first argument, in most cases you'd do this:\n\n``` js\nVue.component('jsx-example', {\n  render (h) { // <-- h must be in scope\n    return <div id=\"foo\">bar</div>\n  }\n})\n```\n\n### `h` auto-injection\n\nStarting with version 3.4.0 we automatically inject `const h = this.$createElement` in any method and getter (not functions or arrow functions) declared in ES2015 syntax that has JSX so you can drop the `(h)` parameter.\n\n``` js\n\nVue.component('jsx-example', {\n  render () { // h will be injected\n    return <div id=\"foo\">bar</div>\n  },\n  myMethod: function () { // h will not be injected\n    return <div id=\"foo\">bar</div>\n  },\n  someOtherMethod: () => { // h will not be injected\n    return <div id=\"foo\">bar</div>\n  }\n})\n\n@Component\nclass App extends Vue {\n  get computed () { // h will be injected\n    return <div id=\"foo\">bar</div>\n  }\n}\n```\n\n### Difference from React JSX\n\nFirst, Vue 2.0's vnode format is different from React's. The second argument to the `createElement` call is a \"data object\" that accepts nested objects. Each nested object will be then processed by corresponding modules:\n\n``` js\nrender (h) {\n  return h('div', {\n    // Component props\n    props: {\n      msg: 'hi'\n    },\n    // normal HTML attributes\n    attrs: {\n      id: 'foo'\n    },\n    // DOM props\n    domProps: {\n      innerHTML: 'bar'\n    },\n    // Event handlers are nested under \"on\", though\n    // modifiers such as in v-on:keyup.enter are not\n    // supported. You'll have to manually check the\n    // keyCode in the handler instead.\n    on: {\n      click: this.clickHandler\n    },\n    // For components only. Allows you to listen to\n    // native events, rather than events emitted from\n    // the component using vm.$emit.\n    nativeOn: {\n      click: this.nativeClickHandler\n    },\n    // class is a special module, same API as `v-bind:class`\n    class: {\n      foo: true,\n      bar: false\n    },\n    // style is also same as `v-bind:style`\n    style: {\n      color: 'red',\n      fontSize: '14px'\n    },\n    // other special top-level properties\n    key: 'key',\n    ref: 'ref',\n    // assign the `ref` is used on elements/components with v-for\n    refInFor: true,\n    slot: 'slot'\n  })\n}\n```\n\nThe equivalent of the above in Vue 2.0 JSX is:\n\n``` jsx\nrender (h) {\n  return (\n    <div\n      // normal attributes or component props.\n      id=\"foo\"\n      // DOM properties are prefixed with `domProps`\n      domPropsInnerHTML=\"bar\"\n      // event listeners are prefixed with `on` or `nativeOn`\n      onClick={this.clickHandler}\n      nativeOnClick={this.nativeClickHandler}\n      // other special top-level properties\n      class={{ foo: true, bar: false }}\n      style={{ color: 'red', fontSize: '14px' }}\n      key=\"key\"\n      ref=\"ref\"\n      // assign the `ref` is used on elements/components with v-for\n      refInFor\n      slot=\"slot\">\n    </div>\n  )\n}\n```\n\n### Component Tip\n\nIf a custom element starts with lowercase, it will be treated as a string id and used to lookup a registered component. If it starts with uppercase, it will be treated as an identifier, which allows you to do:\n\n``` js\nimport Todo from './Todo.js'\n\nexport default {\n  render (h) {\n    return <Todo/> // no need to register Todo via components option\n  }\n}\n```\n\n### JSX Spread\n\nJSX spread is supported, and this plugin will intelligently merge nested data properties. For example:\n\n``` jsx\nconst data = {\n  class: ['b', 'c']\n}\nconst vnode = <div class=\"a\" {...data}/>\n```\n\nThe merged data will be:\n\n``` js\n{ class: ['a', 'b', 'c'] }\n```\n\n### Vue directives\n\nNote that almost all built-in Vue directives are not supported when using JSX, the sole exception being `v-show`, which can be used with the `v-show={value}` syntax. In most cases there are obvious programmatic equivalents, for example `v-if` is just a ternary expression, and `v-for` is just an `array.map()` expression, etc.\n\nFor custom directives, you can use the `v-name={value}` syntax. However, note that directive arguments and modifiers are not supported using this syntax. There are two workarounds:\n\n1. Pass everything as an object via `value`, e.g. `v-name={{ value, modifier: true }}`\n\n2. Use the raw vnode directive data format:\n\n``` js\nconst directives = [\n  { name: 'my-dir', value: 123, modifiers: { abc: true } }\n]\n\nreturn <div {...{ directives }}/>\n```\n","gitHead":"3c6dcca1c879d7882449a44fef2536fd787c7ce9","license":"MIT","scripts":{"dev":"cd example && webpack --watch","lint":"eslint index.js","test":"npm run lint && mocha --require @babel/register","build":"webpack -d","prepublishOnly":"npm run build"},"_npmUser":{"name":"yyx990803","email":"yyx990803@gmail.com"},"homepage":"https://github.com/vuejs/babel-plugin-transform-vue-jsx#readme","keywords":["vue","babel","jsx"],"repository":{"url":"git+https://github.com/vuejs/babel-plugin-transform-vue-jsx.git","type":"git"},"_npmVersion":"5.6.0","description":"Babel plugin for Vue 2.0 JSX","directories":{},"maintainers":[{"name":"yyx990803","email":"yyx990803@gmail.com"}],"_nodeVersion":"8.9.1","dependencies":{"esutils":"^2.0.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"vue":"^2.5.13","chai":"^4.1.2","mocha":"^5.0.0","eslint":"^4.16.0","webpack":"^3.11.0","@babel/core":"^7.0.0-beta.40","babel-loader":"8.0.0-beta.0","@babel/register":"^7.0.0-beta.40","@babel/preset-env":"^7.0.0-beta.40","eslint-plugin-vue-libs":"^2.1.0","@babel/plugin-syntax-jsx":"^7.0.0-beta.40","@babel/helper-module-imports":"^7.0.0-beta.40","babel-helper-vue-jsx-merge-props":"^2.0.3"},"peerDependencies":{"babel-helper-vue-jsx-merge-props":"^2.0.0"},"_npmOperationalInternal":{"tmp":"tmp/babel-plugin-transform-vue-jsx_4.0.1_1520291308337_0.7930965584341207","host":"s3://npm-registry-packages"},"_id":"babel-plugin-transform-vue-jsx@4.0.1","version":"4.0.1"}