Skip to content

Commit 280243f

Browse files
petehuntzpao
authored andcommitted
response to code review
1 parent 5361a2b commit 280243f

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

grunt/config/browserify.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
var envify = require('envify/custom');
77
var grunt = require('grunt');
8+
var recast = require('recast');
89
var UglifyJS = require('uglify-js');
910

1011
var SIMPLE_TEMPLATE =
@@ -39,7 +40,16 @@ function minify(src) {
3940
// allow browserified libraries to work with requirejs and
4041
// other pacakgers that get confused by these calls.
4142
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+
}
4353
}
4454

4555
// TODO: move this out to another build step maybe.

npm-react-core/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# react-core
22

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
66
`React`.
77

88
## Example Usage

vendor/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function transform(ast, constants) {
5757
// There could in principle be a constant called "hasOwnProperty",
5858
// so be careful always to use Object.prototype.hasOwnProperty.
5959
if (node.name === '__DEV__') {
60-
// replace __DEV__ with process.env.NODE_ENV === 'dev'
60+
// replace __DEV__ with process.env.NODE_ENV !== 'production'
6161
this.replace(DEV_EXPRESSION);
6262
return false;
6363
} else if (hasOwn.call(constants, node.name)) {

0 commit comments

Comments
 (0)