From bb066b86fa6795164bcd5b7b6385e57c0186e277 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Mon, 21 Jul 2014 15:56:25 -0700 Subject: [PATCH] [added] Browser build script There is currently no way to NOT use Browserify's "process" shim since the code we're requiring in react/lib uses the process object, so the build is slightly larger than it needs to be. If React core would expose the stuff in react/lib as modules, we could avoid it. Fixes #73 --- package.json | 26 +++++++++++++++++++------- script/build | 6 ++++++ 2 files changed, 25 insertions(+), 7 deletions(-) create mode 100755 script/build diff --git a/package.json b/package.json index a3128ba220..f12e19f2b0 100644 --- a/package.json +++ b/package.json @@ -24,24 +24,36 @@ ], "license": "MIT", "devDependencies": { - "webpack": "^1.2.0-beta5", - "jsx-loader": "^0.10.2", + "browserify": "^4.2.3", + "browserify-shim": "^3.6.0", "bundle-loader": "^0.5.0", + "envify": "~1.2.0", "expect": "^0.1.1", - "mocha": "^1.20.1", + "jsx-loader": "^0.10.2", "karma": "^0.12.16", - "webpack-dev-server": "^1.4.2", - "karma-webpack": "^1.2.1", - "karma-mocha": "^0.1.3", "karma-chrome-launcher": "^0.1.4", "karma-cli": "0.0.4", + "karma-firefox-launcher": "^0.1.3", + "karma-mocha": "^0.1.3", + "karma-webpack": "^1.2.1", + "mocha": "^1.20.1", "rf-release": "^0.1.2", - "karma-firefox-launcher": "^0.1.3" + "uglify-js": "^2.4.15", + "webpack": "^1.2.0-beta5", + "webpack-dev-server": "^1.4.2" }, "dependencies": { "react": "^0.10.0", "es6-promise": "^1.0.0", "event-emitter": "^0.3.1", "querystring": "^0.2.0" + }, + "browserify": { + "transform": [ + "browserify-shim" + ] + }, + "browserify-shim": { + "react": "global:React" } } diff --git a/script/build b/script/build new file mode 100755 index 0000000000..ce7700ceaa --- /dev/null +++ b/script/build @@ -0,0 +1,6 @@ +#!/bin/sh +BROWSERIFY="node_modules/.bin/browserify" +VERSION=`node -p "require('./package').version"` + +NODE_ENV=production $BROWSERIFY modules/main.js --detect-globals false -t envify > build/react-nested-router-$VERSION.js +NODE_ENV=production $BROWSERIFY modules/main.js --detect-globals false -t envify | uglifyjs --compress warnings=false > build/react-nested-router-$VERSION.min.js