babel-plugin-sandstone-require
v1.0.0
Published
Babel plugin that adds Sandstone.h import declaration if file contains JSX tags.
Downloads
11
Maintainers
Readme
babel-plugin-sandstone-require
Babel plugin that adds Sandstone's h
declaration if file contains JSX tags.
This code was forked from babel-plugin-preact-require. Credit where credit is due
Example
Your component.js
that contains this code:
export default function Component() {
return (
<div />
)
}
will be transpiled into something like this:
import { h } from 'sandstone'
export default function Component() {
/* this part will be transpiled by babel itself as usual */
return (
h('div')
)
}
Usage
- Install
babel-plugin-sandstone-require
.
npm install babel-plugin-sandstone-require --save-dev
- Add
sandstone-require
into.babelrc
. This plugin should be defined before any module transforms plugin because it's using ES2015 modules syntax to import Sandstone'sh
into scope.
{
"plugins": [
"sandstone-require"
]
}