Skip to content

A Webpack loader that transforms JSX decoupled from React using jsx-transformer v2

Notifications You must be signed in to change notification settings

gfmio/jsx-transform-2-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsx-transform-2-loader

jsx-transform-2-loader is a Webpack loader that transforms JSX decoupled from React (or any specific framework) using v2 of the jsx-transformer package. It is based on jsx-transform-loader which however uses an old version of jsx-transform.

Install

npm install --save-dev jsx-transform-2-loader

Usage

Include the package as a loader in your Webpack config. You may specify all options that jsx-transform accepts. The most important option is the factory option (default: h), which determines the name of the factory function used to construct the Virtual DOM objects.

...
  {
    loaders: [{
      test: /\.(js|jsx)$/,
      exclude: /node_modules/,
      options: {
        factory: 'h'
        // Other jsx-transform options may go here.
      },
      loader: 'jsx-transform-2-loader'
    }]
  }
...

Example

Input:

var h = require('virtual-dom/h');

var profile = <div>
  <img src="avatar.png" class="profile" />
  <h3>{[user.firstName, user.lastName].join(' ')}</h3>
</div>;

Output (with default options):

var h = require('virtual-dom/h');

var profile = h('div', null, [
  h('img', { src: "avatar.png", class: "profile" }),
  h('h3', null, [[user.firstName, user.lastName].join(' ')])
]);

License: MIT

About

A Webpack loader that transforms JSX decoupled from React using jsx-transformer v2

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published