You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: package.json
+16-12Lines changed: 16 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -6,24 +6,29 @@
6
6
"umd:main": "dist/htm.umd.js",
7
7
"module": "dist/htm.mjs",
8
8
"scripts": {
9
-
"build": "npm run -s build:main && npm run -s build:preact && npm run -s build:babel",
9
+
"build": "npm run -s build:main && npm run -s build:mini && npm run -s build:preact && npm run -s build:babel && npm run -s build:babel-transform-jsx",
This plugin converts JSX into Tagged Templates that work with [htm].
4
+
5
+
```js
6
+
// INPUT:
7
+
constFoo= () =><h1>Hello</h1>
8
+
9
+
// OUTPUT:
10
+
constFoo= () =>html`<h1>Hello</h1>`
11
+
```
12
+
13
+
## Installation
14
+
15
+
Grab it from npm:
16
+
17
+
```sh
18
+
npm i -D babel-plugin-transform-jsx-to-htm
19
+
```
20
+
21
+
... then add it to your Babel config (eg: `.babelrc`):
22
+
23
+
```js
24
+
"plugins": [
25
+
"babel-plugin-transform-jsx-to-htm"
26
+
]
27
+
```
28
+
29
+
## Options
30
+
31
+
The following options are available:
32
+
33
+
| Option | Type | Default | Description
34
+
|--------|---------|----------|------------
35
+
| `tag` | String | `"html"` | The "tag" function to prefix [Tagged Templates] with.
36
+
| `import` | `false`\|String\|Object | `false` | Auto-import a tag function, off by default.<br>_See [Auto-importing a tag function](#auto-importing-the-tag) for an example._
37
+
38
+
Options are passed to a Babel plugin using a nested Array:
39
+
40
+
```js
41
+
"plugins": [
42
+
["babel-plugin-transform-jsx-to-htm", {
43
+
"tag":"$$html"
44
+
}]
45
+
]
46
+
```
47
+
48
+
## Auto-importing the tag
49
+
50
+
Want to automatically import `html` into any file that uses JSX?
0 commit comments