babel-plugin-html-attributes-to-jsx

Coerce HTML attributes into something JSX and React friendly

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
babel-plugin-html-attributes-to-jsx
16,828151.6.223 years ago5 years agoMinified + gzip package size for babel-plugin-html-attributes-to-jsx in KB

Readme

babel-plugin-html-attributes-to-jsx
Coerce HTML attributes into something JSX and React friendly. Used by MDX.

Installation

yarn add babel-plugin-html-attributes-to-jsx

Usage

const babel = require('@babel/core')

const plugin = require('babel-plugin-html-attributes-to-jsx')

const jsx = `
export const Foo = () => (
  <div srcset="foo">
    <Button />
  </div>
)
`

const plugin = new BabelPluginHtmlAttributesToJsx()

const result = babel.transform(jsx, {
  configFile: false,
  plugins: ['@babel/plugin-syntax-jsx', plugin]
})

console.log(result.code)

Input

export const Foo = () => (
  <div srcset="foo">
    <Button />
  </div>
)

Output

const Foo = () => (
  <div srcSet="foo">
    <Button />
  </div>
)

License

MIT