npm

register-jsx

2.0.3 • Public • Published

register-jsx

a simple require hook for jsx transpilation without babel or react

// a.jsx

const tr = (name, options, children) => {
  return { name, options, children }
}

module.exports = <foo>
  <bar a={123} />
</foo>
require('register-jsx')({ factory: 'tr' })

console.log(require('a.jsx'))
/*
  {
    name: 'foo',
    options: undefined,
    children: [{
      name: 'bar',
      options: { a: 123 },
      children: undefined
    }]
  }
*/

install

$ npm i register-jsx

usage

require('register-jsx')(options)

it uses jsx-transform for transpiling and options are just passed onto jsxTransform.fromFile.

it returns the jsxTransform object.

Starting from version 1.0.2, the module ignores everything inside node_modules folders, and can also ignore other files if a .jsxignore file is present in the project's root directory. The .jsxignore file must have one pattern per line, and the lines are first trimmed, and then matched using minimatch.

test

$ npm test

Package Sidebar

Install

npm i register-jsx

Weekly Downloads

1

Version

2.0.3

License

MIT

Unpacked Size

5.65 kB

Total Files

9

Last publish

Collaborators

  • gerhardberger
  • brenca