Merge pull request #2425 from zertosh/browserify-shrink

Use source-map@^0.5.0 and optimize bundle builds
This commit is contained in:
Sebastian McKenzie 2015-09-24 15:34:30 +01:00
commit 55989d1c34
4 changed files with 42 additions and 10 deletions

View File

@ -3,8 +3,10 @@
"devDependencies": {
"babel": "5.8.19",
"babel-eslint": "^4.0.6",
"browserify": "^11.0.0",
"browserify": "^11.2.0",
"bundle-collapser": "^1.2.1",
"chai": "^2.2.0",
"derequire": "^2.0.2",
"es5-shim": "^4.1.7",
"eslint": "^1.1.0",
"fs-readdir-recursive": "^0.1.2",

View File

@ -18,7 +18,7 @@
"output-file-sync": "^1.1.0",
"path-exists": "^1.0.0",
"path-is-absolute": "^1.0.0",
"source-map": "^0.4.0",
"source-map": "^0.5.0",
"slash": "^1.0.0"
},
"bin": {

View File

@ -69,7 +69,7 @@
"resolve": "^1.1.6",
"shebang-regex": "^1.0.0",
"slash": "^1.0.0",
"source-map": "^0.4.0",
"source-map": "^0.5.0",
"source-map-support": "^0.2.10",
"to-fast-properties": "^1.0.0",
"trim-right": "^1.0.0",

View File

@ -3,24 +3,54 @@ set -e
BROWSERIFY_CMD="../../node_modules/browserify/bin/cmd.js"
UGLIFY_CMD="../../node_modules/uglify-js/bin/uglifyjs"
BROWSERIFY_IGNORE="-i esprima-fb"
BROWSERIFY_IGNORE="-i esprima-fb -i through"
set -x
mkdir -p dist
node scripts/cache-templates
node $BROWSERIFY_CMD -e lib/polyfill.js >dist/polyfill.js
node $UGLIFY_CMD dist/polyfill.js >dist/polyfill.min.js
node $BROWSERIFY_CMD lib/polyfill.js \
--insert-global-vars 'global' \
--plugin bundle-collapser/plugin \
--plugin derequire/plugin \
>dist/polyfill.js
node $UGLIFY_CMD dist/polyfill.js \
--compress warnings=false \
--mangle \
>dist/polyfill.min.js
# Add a Unicode BOM so browsers will interpret the file as UTF-8
node -p '"\uFEFF"' > dist/browser.js
node $BROWSERIFY_CMD lib/api/browser.js -s babel $BROWSERIFY_IGNORE >>dist/browser.js
node $BROWSERIFY_CMD lib/api/browser.js \
--standalone babel \
--plugin bundle-collapser/plugin \
--plugin derequire/plugin \
$BROWSERIFY_IGNORE \
>>dist/browser.js
node -p '"\uFEFF"' > dist/browser.min.js
node $UGLIFY_CMD dist/browser.js >>dist/browser.min.js
node $UGLIFY_CMD dist/browser.js \
--compress warnings=false \
--mangle \
>>dist/browser.min.js
node $BROWSERIFY_CMD lib/api/node.js --node $BROWSERIFY_IGNORE >dist/node.js
node $BROWSERIFY_CMD lib/api/node.js \
--standalone babel \
--node \
--plugin bundle-collapser/plugin \
--plugin derequire/plugin \
$BROWSERIFY_IGNORE \
>dist/node.js
node $UGLIFY_CMD dist/node.js \
--compress warnings=false \
--mangle \
>dist/node.min.js
node ../babel-cli/lib/babel-external-helpers >dist/external-helpers.js
node $UGLIFY_CMD dist/external-helpers.js >dist/external-helpers.min.js
node $UGLIFY_CMD dist/external-helpers.js \
--compress warnings=false \
--mangle \
>dist/external-helpers.min.js
rm -rf templates.json