react app

This commit is contained in:
Mario Romano
2016-04-06 17:52:19 +01:00
parent f7e6ef55a2
commit 29df96a085
4425 changed files with 446323 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
node_modules
*.log
src
test

View File

@@ -0,0 +1,44 @@
# babel-plugin-transform-react-jsx
Turn JSX into React function calls
## Installation
```sh
$ npm install babel-plugin-transform-react-jsx
```
## Usage
### Via `.babelrc` (Recommended)
**.babelrc**
```js
// without options
{
"plugins": ["transform-react-jsx"]
}
// with options
{
"plugins": [
["transform-react-jsx", {
"pragma": "dom" // default pragma is React.createElement
}]
]
}
```
### Via CLI
```sh
$ babel --plugins transform-react-jsx script.js
```
### Via Node API
```javascript
require("babel-core").transform("code", {
plugins: ["transform-react-jsx"]
});
```

View File

@@ -0,0 +1,62 @@
/* eslint max-len: 0 */
"use strict";
exports.__esModule = true;
exports["default"] = function (_ref) {
var t = _ref.types;
var JSX_ANNOTATION_REGEX = /\*?\s*@jsx\s+([^\s]+)/;
var visitor = require("babel-helper-builder-react-jsx")({
pre: function pre(state) {
var tagName = state.tagName;
var args = state.args;
if (t.react.isCompatTag(tagName)) {
args.push(t.stringLiteral(tagName));
} else {
args.push(state.tagExpr);
}
},
post: function post(state, pass) {
state.callee = pass.get("jsxIdentifier")();
}
});
visitor.Program = function (path, state) {
var file = state.file;
var id = state.opts.pragma || "React.createElement";
var _arr = file.ast.comments;
for (var _i = 0; _i < _arr.length; _i++) {
var comment = _arr[_i];
var matches = JSX_ANNOTATION_REGEX.exec(comment.value);
if (matches) {
id = matches[1];
if (id === "React.DOM") {
throw file.buildCodeFrameError(comment, "The @jsx React.DOM pragma has been deprecated as of React 0.12");
} else {
break;
}
}
}
state.set("jsxIdentifier", function () {
return id.split(".").map(function (name) {
return t.identifier(name);
}).reduce(function (object, property) {
return t.memberExpression(object, property);
});
});
};
return {
inherits: require("babel-plugin-syntax-jsx"),
visitor: visitor
};
};
module.exports = exports["default"];

View File

@@ -0,0 +1,94 @@
{
"_args": [
[
"babel-plugin-transform-react-jsx@^6.3.13",
"/Users/mromano/dev/react-sfs/node_modules/babel-preset-react"
]
],
"_from": "babel-plugin-transform-react-jsx@>=6.3.13 <7.0.0",
"_id": "babel-plugin-transform-react-jsx@6.7.4",
"_inCache": true,
"_installable": true,
"_location": "/babel-plugin-transform-react-jsx",
"_nodeVersion": "5.9.0",
"_npmOperationalInternal": {
"host": "packages-13-west.internal.npmjs.com",
"tmp": "tmp/babel-plugin-transform-react-jsx-6.7.4.tgz_1458704269957_0.6471593875903636"
},
"_npmUser": {
"email": "loganfsmyth@gmail.com",
"name": "loganfsmyth"
},
"_npmVersion": "3.7.3",
"_phantomChildren": {},
"_requested": {
"name": "babel-plugin-transform-react-jsx",
"raw": "babel-plugin-transform-react-jsx@^6.3.13",
"rawSpec": "^6.3.13",
"scope": null,
"spec": ">=6.3.13 <7.0.0",
"type": "range"
},
"_requiredBy": [
"/babel-preset-react"
],
"_resolved": "https://registry.npmjs.org/babel-plugin-transform-react-jsx/-/babel-plugin-transform-react-jsx-6.7.4.tgz",
"_shasum": "a372b7e55f3da0973c171eb7e6a82d53f473e6b1",
"_shrinkwrap": null,
"_spec": "babel-plugin-transform-react-jsx@^6.3.13",
"_where": "/Users/mromano/dev/react-sfs/node_modules/babel-preset-react",
"dependencies": {
"babel-helper-builder-react-jsx": "^6.6.5",
"babel-plugin-syntax-jsx": "^6.3.13",
"babel-runtime": "^5.0.0"
},
"description": "Turn JSX into React function calls",
"devDependencies": {
"babel-helper-plugin-test-runner": "^6.3.13"
},
"directories": {},
"dist": {
"shasum": "a372b7e55f3da0973c171eb7e6a82d53f473e6b1",
"tarball": "https://registry.npmjs.org/babel-plugin-transform-react-jsx/-/babel-plugin-transform-react-jsx-6.7.4.tgz"
},
"keywords": [
"babel-plugin"
],
"license": "MIT",
"main": "lib/index.js",
"maintainers": [
{
"email": "amjad.masad@gmail.com",
"name": "amasad"
},
{
"email": "hi@henryzoo.com",
"name": "hzoo"
},
{
"email": "npm-public@jessemccarthy.net",
"name": "jmm"
},
{
"email": "loganfsmyth@gmail.com",
"name": "loganfsmyth"
},
{
"email": "sebmck@gmail.com",
"name": "sebmck"
},
{
"email": "me@thejameskyle.com",
"name": "thejameskyle"
}
],
"name": "babel-plugin-transform-react-jsx",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-jsx"
},
"scripts": {},
"version": "6.7.4"
}