babel-plugin-react-transform
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -175,2 +175,17 @@ 'use strict'; | ||
function isSameAsFileBeingProcessed(importPath) { | ||
var _path$parse = _path2['default'].parse(resolvePath(importPath, filename)); | ||
var dir = _path$parse.dir; | ||
var base = _path$parse.base; | ||
var ext = _path$parse.ext; | ||
var name = _path$parse.name; | ||
return dir === '.' && name === _path2['default'].parse(filename).name; | ||
} | ||
if (imports.some(isSameAsFileBeingProcessed)) { | ||
return; | ||
} | ||
return [id, t.variableDeclaration('var', [t.variableDeclarator(id, t.callExpression(file.addImport(resolvePath(target, filename)), [t.objectExpression([t.property('init', t.identifier('filename'), t.literal(filename)), t.property('init', t.identifier('components'), recordsId), t.property('init', t.identifier('locals'), t.arrayExpression(locals.map(function (local) { | ||
@@ -255,3 +270,3 @@ return t.identifier(local); | ||
return defineInitTransformCall(scope, file, recordsId, transformOptions); | ||
}); | ||
}).filter(Boolean); | ||
var initTransformIds = initTransformCalls.map(function (c) { | ||
@@ -258,0 +273,0 @@ return c[0]; |
{ | ||
"name": "babel-plugin-react-transform", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Babel plugin to instrument React components with custom transforms", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -8,6 +8,6 @@ # babel-plugin-react-transform | ||
* catch errors inside `render()` and render them in a [red screen of death](https://github.com/KeywordBrain/redbox-react); | ||
* enable hot reloading a la [React Hot Loader](https://github.com/gaearon/react-hot-loader); | ||
* render an inline prop inspector a la [React DevTools](https://github.com/facebook/react-devtools); | ||
* highlight parts of the screen when components update, | ||
* catch errors inside `render()` like **[react-transform-catch-errors](https://github.com/gaearon/react-transform-catch-errors)**; | ||
* enable hot reloading like **[react-transform-webpack-hmr](https://github.com/gaearon/react-transform-webpack-hmr)**; | ||
* render an inline prop inspector like **[react-transform-debug-inspector](https://github.com/alexkuz/react-transform-debug-inspector)**; | ||
* highlight parts of the screen when components update (want to write this one?), | ||
* etc. | ||
@@ -18,2 +18,8 @@ | ||
## Demo | ||
Check out **[react-transform-boilerplate](https://github.com/gaearon/react-transform-boilerplate)** for a demo showing a combination of transforms. | ||
![](http://i.imgur.com/AhGY28T.gif) | ||
## Installation | ||
@@ -30,3 +36,2 @@ | ||
``` | ||
# Okay, these don't actually exist yet but I'll publish them soon | ||
npm install --save-dev react-transform-webpack-hmr | ||
@@ -50,10 +55,8 @@ npm install --save-dev react-transform-catch-errors | ||
"target": "react-transform-webpack-hmr", | ||
// will be available as options.imports to the transform | ||
// see specific transform's docs for "imports" and "locals" it needs | ||
"imports": ["react"], | ||
// will be available as options.locals to the transform | ||
"locals": ["module"] | ||
}, { | ||
// can be an NPM module name or a local path | ||
// you can have many transforms, not just one | ||
"target": "react-transform-catch-errors", | ||
// will be available as options.imports to the transform | ||
"imports": ["react", "redbox-react"] | ||
@@ -182,4 +185,25 @@ }, { | ||
## Ecosystem | ||
* **https://github.com/gaearon/react-transform-boilerplate** | ||
* **https://github.com/gaearon/react-transform-webpack-hmr** | ||
* **https://github.com/gaearon/react-transform-catch-errors** | ||
* **https://github.com/alexkuz/react-transform-debug-inspector** | ||
* Feeling inspired? Send a PR! | ||
## Limitations | ||
Currently, it can only locate components of two types: ES6 classes with `render` method and explicit `React.createClass()` calls. I’m open to adding more heuristics for other common patterns, given enough interest. | ||
## Patrons | ||
The work on React Transform, [React Hot Loader](https://github.com/gaearon/react-hot-loader), [Redux](https://github.com/rackt/redux), and related projects was [funded by the community](https://www.patreon.com/reactdx). Meet some of the outstanding companies that made it possible: | ||
* [Webflow](http://webflow.com/) | ||
* [Chess iX](http://www.chess-ix.com/) | ||
[See the full list of React Transform patrons.](PATRONS.md) | ||
## License | ||
MIT |
35890
14
630
205