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

include browserified and browserified+uglified version in dist #476

Merged
merged 1 commit into from Dec 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
experiments/
node_modules/
build/when.js
dist/
test/browser/*.js
bower_components/
1 change: 1 addition & 0 deletions .jshintignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ test/browser/
es6-shim/
build/when.js
bower_components/
dist/
32 changes: 12 additions & 20 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,32 +66,24 @@ If you're already using [RaveJS](https://github.com/RaveJS/rave), just install w

#### Browser environments (via browserify)

Since when.js primarily targets modular environments, it doesn't export to the global object (`window` in browsers) by default. You can create your own build of when.js using browserify, if you prefer not to use an AMD or CommonJS loader in your project.
If you prefer not to use an AMD or CommonJS loader in your project, you can use a pre-built UMD module available in `dist/browser/when[.min|.debug].js` to have a global `when` available.

1. `git clone https://github.com/cujojs/when`
1. `npm install`
1. `npm run browserify` to generate `build/when.js`
1. Or `npm run browserify-debug` to build with [when/monitor/console](api.md#debugging-promises) enabled
1. `<script src="path/to/when/build/when.js"></script>`
1. `when` will be available as `window.when`
1. `npm install --save when`
1. `<script src="path/to/when/dist/browser/when.js"></script>`
1. Or `<script src="path/to/when/dist/browser/when.min.js"></script>` for minified version
1. Or `<script src="path/to/when/dist/browser/when.debug.js"></script>` with [when/monitor/console](api.md#debugging-promises) enabled
1. `when` will be available as `window.when`
1. Other modules will be available as sub-objects/functions, e.g. `window.when.fn.lift`, `window.when.sequence`. See the [full sub-namespace list in the browserify build file](../build/when.browserify.js)

If you would prefer to install the source via npm. Note that this will install the full when.js source, including tests, etc., into `node_modules` rather than the smaller, published when.js npm package.

1. `npm install --save cujojs/when`
1. `npm install --save-dev browserify`
1. Add `cd node_modules/when && npm run browserify` to your `postinstall` script in your project's package.json
1. `<script src="path/to/when/build/when.js"></script>`
1. See above for usage, `window.when`, etc.
If you expose the whole `dist/browser` folder in your application (or make sure that `when[.min|.debug].js` has its corresponding `*.map` file available next to it), you will have the [source maps](https://developer.chrome.com/devtools/docs/javascript-debugging#source-maps) available for debugging in the browser.

#### Web Worker (via browserify)

Similarly to browser global environments:

1. `git clone https://github.com/cujojs/when`
1. `npm install`
1. `npm run browserify` to generate `build/when.js`
1. Or `npm run browserify-debug` to build with [when/monitor/console](api.md#debugging-promises) enabled
1. `importScripts('path/to/when/build/when.js');`
1. `when` will be available as `self.when`
1. `npm install --save when`
1. `importScripts('path/to/when/dist/browser/when.js');`
1. Or `importScripts('path/to/when/dist/browser/when.min.js');` for minified version
1. Or `importScripts('path/to/when/dist/browser/when.debug.js');` with [when/monitor/console](api.md#debugging-promises) enabled
1. `when` will be available as `self.when`
1. Other modules will be available as sub-objects/functions, e.g. `self.when.fn.lift`, `self.when.sequence`. See the [full sub-namespace list in the browserify build file](../build/when.browserify.js)
1 change: 1 addition & 0 deletions es6-shim/Promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,7 @@ define(function() {
}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));

},{}]},{},[1])
//# sourceMappingURL=Promise.js.map
(1)
});
;
25 changes: 25 additions & 0 deletions es6-shim/Promise.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions es6-shim/Promise.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions es6-shim/Promise.min.js.map

Large diffs are not rendered by default.

27 changes: 17 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,20 @@
}
],
"devDependencies": {
"promises-aplus-tests": "~2",
"benchmark": "~1",
"microtime": "~0",
"browserify": "~2",
"buster": "~0.7",
"exorcist": "~0.4",
"jshint": "~2",
"rest": "1.1.x",
"json5": "~0.2",
"microtime": "~0",
"optimist": "~0.6",
"poly": "^0.6.1",
"promises-aplus-tests": "~2",
"rest": "1.1.x",
"sauce-connect-launcher": "~0.4",
"wd": "~0.2",
"json5": "~0.2"
"uglify-js": "~2",
"wd": "~0.2"
},
"main": "when",
"ender": {
Expand All @@ -71,6 +73,7 @@
]
},
"browser": {
"when": "./dist/browser/when.js",
"vertx": false
},
"directories": {
Expand All @@ -84,10 +87,14 @@
"tunnel": "node test/sauce.js -m",
"start": "buster-static -e browser",
"benchmark": "node benchmark/promise && node benchmark/map",
"prepublish": "npm run browserify-es6",
"preversion": "npm run browserify-es6",
"browserify-es6": "browserify -s Promise es6-shim/Promise.browserify-es6.js --no-detect-globals -o es6-shim/Promise.js",
"browserify": "browserify -s when build/when.browserify.js --no-detect-globals -o build/when.js",
"browserify-debug": "browserify -s when build/when.browserify-debug.js --no-detect-globals -o build/when.js"
"prepublish": "npm run browserify && npm run uglify",
"preversion": "npm run browserify && npm run uglify",
"browserify": "npm run browserify-es6 && npm run browserify-when && npm run browserify-debug",
"browserify-es6": "browserify -s Promise es6-shim/Promise.browserify-es6.js --no-detect-globals --debug | exorcist -b . -r https://raw.githubusercontent.com/cujojs/when/`git rev-parse HEAD` es6-shim/Promise.js.map >es6-shim/Promise.js",
"browserify-when": "mkdir -p dist/browser && browserify -s when build/when.browserify.js --no-detect-globals --debug | exorcist -b . -r https://raw.githubusercontent.com/cujojs/when/`git rev-parse HEAD` dist/browser/when.js.map >dist/browser/when.js",
"browserify-debug": "mkdir -p dist/browser && browserify -s when build/when.browserify-debug.js --no-detect-globals --debug | exorcist -b . -r https://raw.githubusercontent.com/cujojs/when/`git rev-parse HEAD` dist/browser/when.debug.js.map >dist/browser/when.debug.js",
"uglify": "npm run uglify-es6 && npm run uglify-when",
"uglify-es6": "cd es6-shim; uglifyjs Promise.js --compress --mangle --in-source-map Promise.js.map --source-map Promise.min.js.map -o Promise.min.js; cd ../..",
"uglify-when": "cd dist/browser; uglifyjs when.js --compress --mangle --in-source-map when.js.map --source-map when.min.js.map -o when.min.js; cd ../.."
}
}