@samitouri / QOS-React-2 / commits / 90e2258791

response to code review

petehunt committed Dec 2, 2013 at 10:50 UTC 90e2258791035789e7a190391d7bfc83b15385a6
3 files changed +15 -5
grunt/config/browserify.js
+11 -1
@@ -5,6 +5,7 @@
5
6 var envify = require('envify/custom');
7 var grunt = require('grunt');
8 +var recast = require('recast');
9 var UglifyJS = require('uglify-js');
10
11 var SIMPLE_TEMPLATE =
@@ -39,7 +40,16 @@ function minify(src) {
40 // allow browserified libraries to work with requirejs and
41 // other pacakgers that get confused by these calls.
42 function muffinize(src) {
42 - return src.replace(/require/g, 'muffin');
43 + return recast.print(
44 + recast.types.traverse(recast.parse(src), muffinizeVisitor)
45 + );
46 +}
47 +
48 +function muffinizeVisitor(node, traverse) {
49 + if (recast.namedTypes.Identifier.check(node) &&
50 + node.name === 'require') {
51 + node.name = 'muffin';
52 + }
53 }
54
55 // TODO: move this out to another build step maybe.
npm-react-core/README.md
+3 -3
@@ -1,8 +1,8 @@
1 # react-core
2
3 -An npm package to get you immediate access to `React`, without also requiring
4 -the JSX transformer. This is especially useful for cases where you want to
5 -[`browserify`](https://github.com/substack/node-browserify) your module using
3 +An npm package to get you immediate access to [React](http://facebook.github.io/react/),
4 +without also requiring the JSX transformer. This is especially useful for cases where you
5 +want to [`browserify`](https://github.com/substack/node-browserify) your module using
6 `React`.
7
8 ## Example Usage
vendor/constants.js
+1 -1
@@ -57,7 +57,7 @@ function transform(ast, constants) {
57 // There could in principle be a constant called "hasOwnProperty",
58 // so be careful always to use Object.prototype.hasOwnProperty.
59 if (node.name === '__DEV__') {
60 - // replace __DEV__ with process.env.NODE_ENV === 'dev'
60 + // replace __DEV__ with process.env.NODE_ENV !== 'production'
61 this.replace(DEV_EXPRESSION);
62 return false;
63 } else if (hasOwn.call(constants, node.name)) {