UNPKG

babel-plugin-react-hyperscript-require

Version:

Babel plugin that adds react-hyperscript import declaration

72 lines (44 loc) 1.49 kB
### babel-plugin-react-hyperscript-require [![Build Status](https://api.travis-ci.org/siddharthkp/babel-plugin-react-hyperscript-require.svg?branch=master)](https://travis-ci.org/siddharthkp/babel-plugin-react-hyperscript-require) [![npm](https://img.shields.io/npm/v/babel-plugin-react-hyperscript-require.svg?maxAge=3600)](https://www.npmjs.com/package/babel-plugin-react-hyperscript-require)   Babel plugin that adds react-hyperscript import declaration _(this repo was cloned from [styled-components-require](https://github.com/siddharthkp/babel-plugin-styled-components-require) and modified to be used with [react-hyperscript](https://github.com/mlmorg/react-hyperscript))_   #### Example Your `component.js` that contains this code: ```js const Component = h('div', 'hello world'); export default Component; ``` will be transpiled to: ```js import h from 'react-hyperscript'; const Component = h('div', 'hello world'); export default Component; ```   #### Usage `npm install babel-plugin-react-hyperscript-require --save-dev` Add `react-hyperscript-require` into `.babelrc` ```json { "plugins": [ "react-hyperscript-require" ] } ```   #### Tests ✓ add import statement if `h()` is present ✓ do not add when no h in use ✓ do not add import react-hyperscript twice ✓ do not add if it already imported   #### You like? :star: this repo   #### License MIT © [mciparelli](https://github.com/mciparelli)