Gathering detailed insights and metrics for babel-plugin-htm
Gathering detailed insights and metrics for babel-plugin-htm
Gathering detailed insights and metrics for babel-plugin-htm
Gathering detailed insights and metrics for babel-plugin-htm
babel-plugin-transform-jsx-to-htm
Babel plugin to compile JSX to Tagged Templates.
babel-plugin-mithril-add-data-attribute
Babel plugin adds attributes to m() components - intended for development - do not used in production. Helps debug - find your components in a large repo. Adds component name and file to component data attributes which will be visible in the generated HTM
npm install babel-plugin-htm
Typescript
Module System
73.5
Supply Chain
99.4
Quality
75.3
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
79,863
Last Day
1
Last Week
1
Last Month
750
Last Year
14,738
8,777 Stars
409 Commits
173 Forks
72 Watching
14 Branches
31 Contributors
Minified
Minified + Gzipped
Latest Version
3.0.0
Package Id
babel-plugin-htm@3.0.0
Size
5.54 kB
Publised On
21 Jan 2020
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
-99.2%
1
Compared to previous week
Last month
29.1%
750
Compared to previous month
Last year
21.1%
14,738
Compared to previous year
1
1
babel-plugin-htm
A Babel plugin that compiles htm syntax to hyperscript, React.createElement, or just plain objects.
In your Babel configuration (.babelrc
, babel.config.js
, "babel"
field in package.json, etc), add the plugin:
1{ 2 "plugins": [ 3 ["htm", { 4 "pragma": "React.createElement" 5 }] 6 ] 7}
1// input:
2html`<div id="foo">hello ${you}</div>`
3
4// output:
5React.createElement("div", { id: "foo" }, "hello ", you)
pragma
The target "hyperscript" function to compile elements to (see Babel docs).
Defaults to: "h"
.
tag=html
By default, babel-plugin-htm
will process all Tagged Templates with a tag function named html
. To use a different name, use the tag
option in your Babel configuration:
1{"plugins":[ 2 ["babel-plugin-htm", { 3 "tag": "myCustomHtmlFunction" 4 }] 5]}
import=false
(experimental)Auto-import the pragma function, off by default.
false
(default)Don't auto-import anything.
String
Import the pragma
like import {<pragma>} from '<import>'
.
With Babel config:
1"plugins": [ 2 ["babel-plugin-htm", { 3 "tag": "$$html", 4 "import": "preact" 5 }] 6]
1import { html as $$html } from 'htm/preact'; 2 3export default $$html`<div id="foo">hello ${you}</div>`
The above will produce files that look like:
1import { h } from 'preact'; 2import { html as $$html } from 'htm/preact'; 3 4export default h("div", { id: "foo" }, "hello ", you)
{module: String, export: String}
Import the pragma
like import {<import.export> as <pragma>} from '<import.module>'
.
With Babel config:
1"plugins": [ 2 ["babel-plugin-htm", { 3 "pragma": "React.createElement", 4 "tag": "$$html", 5 "import": { 6 // the module to import: 7 "module": "react", 8 // a named export to use from that module: 9 "export": "default" 10 } 11 }] 12]
1import { html as $$html } from 'htm/react'; 2 3export default $$html`<div id="foo">hello ${you}</div>`
The above will produce files that look like:
1import React from 'react'; 2import { html as $$html } from 'htm/react'; 3 4export default React.createElement("div", { id: "foo" }, "hello ", you)
useBuiltIns=false
babel-plugin-htm
transforms prop spreads (<a ...${b}>
) into Object.assign()
calls. For browser support reasons, Babel's standard _extends
helper is used by default. To use native Object.assign
directly, pass {useBuiltIns:true}
.
useNativeSpread=false
babel-plugin-htm
transforms prop spreads (<a ...${b} x=y>
) into { ...b, x: 'y' }
object spread syntax. For browser support reasons, Babel's standard _extends
helper is used by default. To use object spread syntax, pass {useNativeSpread:true}
. This option takes precedence over the useBuiltIns
option.
variableArity=true
By default, babel-plugin-htm
transpiles to the same output as JSX would, which assumes a target function of the form h(type, props, ...children)
. If, for the purposes of optimization or simplification, you would like all calls to h()
to be passed exactly 3 arguments, specify {variableArity:false}
in your Babel config:
1html`<div />` // h('div', null, []) 2html`<div a />` // h('div', { a: true }, []) 3html`<div>b</div>` // h('div', null, ['b']) 4html`<div a>b</div>` // h('div', { a: true }, ['b'])
pragma=false
(experimental)Setting pragma
to false
changes the output to be plain objects instead of h()
function calls:
1// input: 2html`<div id="foo">hello ${you}</div>` 3// output: 4{ tag:"div", props:{ id: "foo" }, children:["hello ", you] }
monomorphic
(experimental)Like pragma=false
but converts all inline text to objects, resulting in the same object shape being used:
1// input: 2html`<div id="foo">hello ${you}</div>` 3// output: 4{ type: 1, tag:"div", props:{ id: "foo" }, text: null, children:[ 5 { type: 3, tag: null, props: null, text: "hello ", children: null }, 6 you 7] }
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 7/15 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More