require-jsx
An AMD loader plugin for JMX
Last updated 7 years ago by ericclemmons .
Original npm · Tarball · package.json
$ cnpm install require-jsx 
SYNC missed versions from official npm registry.

require-jsx

A RequireJS plugin for JavaScript files containing JSX.

It can be used to load JS source file that contain JSX code. This is helpful when using React with RequireJS.

Install

Download the plugin here

Place this in the directory that is your baseUrl for your project, or set up a paths config for it for the module ID jsx.

Usage <a name="usage".

First, you need to configure RequireJS to use Facebook's JSXTransformer which also is in React:

require.config({
    deps: ["main"],
    
    paths: {
        jsx: "../lib/jsx",
        JSXTransformer: '../lib/JSXTransformer'
    },
    
    shim: {
        JSXTransformer: {
            exports: "JSXTransformer"
        }
    }
});

Then, you can reference JSX files via the jsx! plugin syntax. For example, to load the router.js file that is in your app directory:

require(['jsx!app/router'], function (Router) {
    
});

The Plugin is then going to load the JavaScript source file app/router.js, parse it with Facebook's JSXTransformer and execute the resulting JavaScript source.

Current Tags

  • 0.1.0                                ...           latest (7 years ago)

1 Versions

  • 0.1.0                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (2)

Copyright 2014 - 2016 © taobao.org |