All Projects β†’ infernojs β†’ Babel Plugin Inferno

infernojs / Babel Plugin Inferno

Licence: mit
Transforms JSX to InfernoJS vNodes

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Babel Plugin Inferno

Inferno Most Fp Demo
A demo for the ReactJS Tampa Bay meetup showing how to build a React+Redux-like architecture from scratch using Inferno, Most.js, reactive programmning, and various functional programming tools & techniques
Stars: ✭ 45 (-36.62%)
Mutual labels:  jsx, inferno
Inferno
πŸ”₯ An extremely fast, React-like JavaScript library for building modern user interfaces
Stars: ✭ 15,206 (+21316.9%)
Mutual labels:  jsx, inferno
Nerv
A blazing fast React alternative, compatible with IE8 and React 16.
Stars: ✭ 5,409 (+7518.31%)
Mutual labels:  jsx, inferno
Jsx Lite
Write components once, run everywhere. Compiles to Vue, React, Solid, Angular, Svelte, and Liquid.
Stars: ✭ 1,015 (+1329.58%)
Mutual labels:  jsx
React Es6 Padawan To Jedi Book
Uma introdução simples e completa para React usando ES6 e Babel.
Stars: ✭ 46 (-35.21%)
Mutual labels:  jsx
Calendar Graph
Calendar graph like github using jsx support SVG, Canvas and SSR
Stars: ✭ 58 (-18.31%)
Mutual labels:  jsx
Component Playground
A component for rendering React components with editable source and live preview
Stars: ✭ 1,148 (+1516.9%)
Mutual labels:  jsx
Cattous
CSS in JSX for lazy developers, built using styled-components and styled-system
Stars: ✭ 38 (-46.48%)
Mutual labels:  jsx
Svg2jsx
πŸƒ Transform SVG to valid JSX.
Stars: ✭ 1,116 (+1471.83%)
Mutual labels:  jsx
Cascade
A modern library for creating user interfaces.
Stars: ✭ 50 (-29.58%)
Mutual labels:  jsx
Universal React Demo
ES6 demo of a simple but scalable React app with react-router, code splitting, server side rendering, and tree shaking.
Stars: ✭ 50 (-29.58%)
Mutual labels:  jsx
Chatblocks
Declarative Messenger chatbot framework
Stars: ✭ 48 (-32.39%)
Mutual labels:  jsx
Markdown To Jsx
🏭 The most lightweight, customizable React markdown component.
Stars: ✭ 1,079 (+1419.72%)
Mutual labels:  jsx
Instrinsicreactjsx
example for kontraktor react/jsx SPA without nodejs (java implementation of jsx, npm and bundling)
Stars: ✭ 61 (-14.08%)
Mutual labels:  jsx
React Native Hotels App
⛺️ Hotels App: A simple react-native App exercise with nodeJS API consumption
Stars: ✭ 50 (-29.58%)
Mutual labels:  jsx
Sowing Machine
🌱A React UI toolchain & JSX alternative
Stars: ✭ 64 (-9.86%)
Mutual labels:  jsx
Rich Text To Jsx
πŸ“„ Opinionated JSX renderer for the Contentful rich text field type.
Stars: ✭ 39 (-45.07%)
Mutual labels:  jsx
Gatsby Plugin Mdx
gatsby v1 mdx plugin, for gatsby v2 see https://github.com/ChristopherBiscardi/gatsby-mdx
Stars: ✭ 50 (-29.58%)
Mutual labels:  jsx
Js Toolbox
CLI tool to simplify the development of JavaScript apps/libraries with little to no configuration. (WORK IN PROGRESS/PACKAGE NOT PUBLISHED).
Stars: ✭ 53 (-25.35%)
Mutual labels:  jsx
Ppx bsx
OCaml JSX for ReasonReact
Stars: ✭ 69 (-2.82%)
Mutual labels:  jsx

Inferno

Downloads Version License

InfernoJS Babel Plugin

Plugin for babel 6+ to enable JSX for Inferno

This plugin transforms JSX code in your projects to Inferno compatible virtual DOM. It is recommended to use this plugin for compiling JSX for inferno. It is different to other JSX plugins, because it outputs highly optimized inferno specific createVNode calls. This plugin also checks children shape during compilation stage to reduce overhead from runtime application.

How to install

npm i --save-dev babel-plugin-inferno

How to use

Add the plugin to your package.json and update the plugin section in your .babelrc file. Or if your Babel settings are located inside the package.json - update the plugin section there.

It's important that you also include the babel-plugin-syntax-jsxplugin.

Example on a .babelrc file that will work with Inferno:

Make sure inferno plugin is added before babel module transformers

{   
    "presets": [ "es2015" ],
    "plugins": [["babel-plugin-inferno", {"imports": true}]]
}

Examples

// Render a simple div
Inferno.render(<div></div>, container);

// Render a div with text
Inferno.render(<div>Hello world</div>, container);

// Render a div with a boolean attribute
Inferno.render(<div autoFocus='true' />, container);

Fragments

All of the following syntaxes are reserved for createFragment call

<>
    <div>Foo</div>
    <div>Bar</div>
</>


<Fragment>
    <div>Foo</div>
    <div>Bar</div>
</Fragment>

<Inferno.Fragment>
    <div>Foo</div>
    <div>Bar</div>
</Inferno.Fragment>

Special flags

This plugin provides few special compile time flags that can be used to optimize an inferno application.

// ChildFlags:
<div $HasVNodeChildren /> - Children is another vNode (Element or Component)
<div $HasNonKeyedChildren /> - Children is always array without keys
<div $HasKeyedChildren /> - Children is array of vNodes having unique keys
<div $ChildFlag={expression} /> - This attribute is used for defining children shpae runtime. See inferno-vnode-flags (ChildFlags) for possibe values

// Functional flags
<div $ReCreate /> - This flag tells inferno to always remove and add the node. It can be used to replace key={Math.random()}

Flag called noNormalize has been removed in v4, and is replaced by $HasVNodeChildren

Options

Change in v4:

Imports (boolean)

By default babel-plugin-inferno uses imports. That means you no longer need to import inferno globally. Just import the inferno specific code YOUR code uses.

example:

import {render} from 'inferno'; // Just import what you need, (render in this case)

// The plugin will automatically import, createVNode
render(<div>1</div>, document.getElementById('root'));

You need to have support for ES6 modules for this to work. If you are using legacy build system or outdated version of webpack, you can revert this change by using imports: false

{
    "presets": [ "es2015" ],
    "plugins": [["inferno", {
        "imports": false
    }]]
}

Pragma

Each method that is used from inferno can be replaced by custom name.

pragma (string) defaults to createVNode.

pragmaCreateComponentVNode (string) defaults to createComponentVNode.

pragmaNormalizeProps (string) defaults to normalizeProps.

pragmaTextVNode (string) defaults to createTextVNode.

pragmaFragmentVNode (string) defaults to createFragment.

{
    "presets": [ "es2015" ],
    "plugins": [["inferno", {
        "imports": true,
        "pragma": "",
        "pragmaCreateComponentVNode": "",
        "pragmaNormalizeProps": "",
        "pragmaTextVNode": ""
    }]]
}

Troubleshoot

You can verify babel-plugin-inferno is used by looking at the compiled output. This plugin does not generate calls to createElement or h, but instead it uses low level InfernoJS API createVNode, createComponentVNode, createFragment etc. If you see your JSX being transpiled into createElement calls its good indication that your babel configuration is not correct.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].