Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

react-core npm module #627

Closed
wants to merge 11 commits into from
Prev Previous commit
Next Next commit
muffinification
  • Loading branch information
petehunt committed Dec 6, 2013
commit a167bfd7a1f52747112817dc03f9bf4e20ab6779
11 changes: 9 additions & 2 deletions grunt/config/browserify.js
Original file line number Diff line number Diff line change
@@ -35,6 +35,13 @@ function minify(src) {
return UglifyJS.minify(src, { fromString: true }).code;
}

// Muffinize: replace the word "require" with "muffin" to
// allow browserified libraries to work with requirejs and
// other pacakgers that get confused by these calls.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(packagers)

function muffinize(src) {
return src.replace(/require/g, 'muffin');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels dangerous enough to me that it may be worth using a real JS parser (or lexer) since you don't want to change the word "require" if it appears in a string or as an object key.

'DOMProperty: Cannot use muffin using both attribute and property: %s'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, there's no way I'll accept something that doesn't do this the right way. "Unless muffined by applicable law …"

}

// TODO: move this out to another build step maybe.
function bannerify(src) {
var version = grunt.config.data.pkg.version;
@@ -78,7 +85,7 @@ var transformer = {
outfile: './build/JSXTransformer.js',
debug: false,
standalone: 'JSXTransformer',
after: [simpleBannerify]
after: [simpleBannerify, muffinize]
};

var addons = {
@@ -90,7 +97,7 @@ var addons = {
standalone: 'React',
transforms: [envify({NODE_ENV: 'development'})],
packageName: 'React (with addons)',
after: [simpleBannerify]
after: [simpleBannerify, muffinize]
};

var addonsMin = grunt.util._.merge({}, addons, {