File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed
Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 55
66var envify = require ( 'envify/custom' ) ;
77var grunt = require ( 'grunt' ) ;
8+ var recast = require ( 'recast' ) ;
89var UglifyJS = require ( 'uglify-js' ) ;
910
1011var 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.
4142function muffinize ( src ) {
42- return src . replace ( / r e q u i r e / 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.
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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 ) ) {
You can’t perform that action at this time.
0 commit comments