-
Notifications
You must be signed in to change notification settings - Fork 27.1k
docs(bundles): document existing bundles and their usage #5878
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
Closed
pkozlowski-opensource
wants to merge
1
commit into
angular:master
from
pkozlowski-opensource:bundles_doc
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| # TL;DR; | ||
|
|
||
| * If you write ES5 use _one_ of the `UMD` bundles. | ||
| * If you experiment with Angular2 using online prototyping tools like [plnkr](http://plnkr.co/) or similar use `System.register` bundles with SystemJS loader. | ||
| * If you use build tools like Browserify or WebPack - bundle Angular2 as part of your build. | ||
| * For all the above cases you must use `angular2-polyfills.js` in a `script` tag to easily include polyfills and external dependencies. | ||
|
|
||
| # Modules, barrels and bundles | ||
|
|
||
| Angular2 source code is authored using the ES2015 standardized module format where one module corresponds to exactly one file. Multiple modules (files) can be logically grouped into so-called "barrels". | ||
| A bundle is a file the contains all the code for one or more barrels. | ||
|
|
||
| Most bundles come in several flavors: | ||
| * regular and minified (got `.min` in their name); | ||
| * regular and "development" (have `.dev` in their name) - "development" bundles contain in-line source maps and don't have minified flavor (minification removes in-lined source maps). | ||
|
|
||
| # Bundles, their content and usage scenarios | ||
|
|
||
| Angular 2 distributes several types of bundles targeted at specific usages: | ||
| * users writing ES5 code without any transpilation steps | ||
| * users experimenting with Angular 2 and TypeScript/ES2015 using online tools like plunker, jsbin or similar | ||
|
|
||
| Since each identified scenario has slightly different requirements and constraints there are specific bundles for each use-case. | ||
|
|
||
| ## ES5 and ngUpgrade users | ||
|
|
||
| ES5 users and AngularJS 1.x users interested in the `ngUpgrade` path can take advantage of the bundles in the [UMD format](https://github.com/umdjs/umd). | ||
| Those are coarse-grained bundles that combine many barrels in one final file. | ||
|
|
||
| filename | list of barrels | dev/prod | minified? | ||
| ------------|-------------------|----------|-------------|--------------|------------- | ||
| `angular2.umd.js` | `RxJS`, `angular2/core`, `angular2/common`, `angular2/compiler`, `angular2/platform/browser`, `angular2/platform/common_dom`, `angular2/http`, `angular2/router`, `angular2/instrumentation`, `angular2/upgrade`| prod | no | ||
| `angular2.umd.min.js` | `RxJS`, `angular2/core`, `angular2/common`, `angular2/compiler`, `angular2/platform/browser`, `angular2/platform/common_dom`, `angular2/http`, `angular2/router`, `angular2/instrumentation`, `angular2/upgrade` | prod | yes | ||
| `angular2.umd.dev.js` | `RxJS`, `angular2/core`, `angular2/common`, `angular2/compiler`, `angular2/platform/browser`, `angular2/platform/common_dom`, `angular2/http`, `angular2/router`, `angular2/instrumentation`, `angular2/upgrade` | dev | no | ||
| `angular2-testing.umd.dev.js` | `RxJS`, `angular2/core`, `angular2/common`, `angular2/compiler`, `angular2/platform/browser`, `angular2/platform/common_dom`, `angular2/http`, `angular2/router`, `angular2/instrumentation`, `angular2/upgrade`, `angular2/testing`, `angular2/http/testing`, `angular2/router/testing` | dev | no | ||
|
|
||
| **Warning**: bundles in the `UMD` format are _not_ "additive". A single application should use only one bundle from the above list. | ||
|
|
||
| ## SystemJS loader users | ||
|
|
||
| [SystemJS loader](https://github.com/systemjs/systemjs) with on-the-fly (in a browser) transpilations support is very useful for quick experiments using tools like plunker, jsbin or similar. | ||
| For this scenario Angular 2 is distributed with bundles in the [System.register format](https://github.com/ModuleLoader/es6-module-loader/wiki/System.register-Explained): | ||
|
|
||
| filename | list of barrels | dev/prod | minified? | ||
| ------------|-------------------|----------|-------------|--------------|------------- | ||
| `angular2.js` | `RxJS`, `angular2/core`, `angular2/common`, `angular2/compiler`, `angular2/platform/browser`, `angular2/platform/common_dom`, `angular2/instrumentation`| prod | no | ||
| `angular2.min.js` | `RxJS`, `angular2/core`, `angular2/common`, `angular2/compiler`, `angular2/platform/browser`, `angular2/platform/common_dom`, `angular2/instrumentation`| prod | yes | ||
| `angular2.dev.js` | `RxJS`, `angular2/core`, `angular2/common`, `angular2/compiler`, `angular2/platform/browser`, `angular2/platform/common_dom`, `angular2/instrumentation`| dev | no | ||
| `http.js` | `angular2/http` | prod | no | ||
| `http.min.js` | `angular2/http` | prod | yes | ||
| `http.dev.js` | `angular2/http` | dev | no | ||
| `router.js` | `angular2/router` | prod | no | ||
| `router.min.js` | `angular2/router` | prod | yes | ||
| `router.dev.js` | `angular2/router` | dev | no | ||
| `upgrade.js` | `angular2/upgrade` | prod | no | ||
| `upgrade.min.js` | `angular2/upgrade` | prod | yes | ||
| `upgrade.dev.js` | `angular2/upgrade` | dev | no | ||
| `testing.dev.js` | `angular2/testing`, `angular2/http/testing`, `angular2/router/testing` | dev | no | ||
|
|
||
| **Note**: bundles in the `System.register` format are "additive" - it is quite common to include several bundles in one application. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing info:
|
||
| For example people using Angular 2 with `http` and `router` would include: `angular2.js`, `http.js` and `router.js`. | ||
|
|
||
| ## Browserify / JSPM / Rollup / WebPack users | ||
|
|
||
| Angular 2 doesn't provide any bundles for use with packaging tools Browserify or WebPack. Those tools are sophisticated enough to build optimal bundles for production use from individual Angular 2 files distributed in the npm package. | ||
| An example of an Angular 2 project built with WebPack can be found in the [angular2-seed](https://github.com/angular/angular2-seed) repository. | ||
|
|
||
| # Polyfills and external dependencies | ||
|
|
||
| Polyfills are required for Angular 2 to function properly (the exact list depends on the browser used) and external dependencies ([zone.js](https://github.com/angular/zone.js)). | ||
| To ease setup of Angular 2 applications there is one file - `angular2-polyfills.js` - that combines: | ||
| * a pollyfill mandatory for all browsers: [reflect-metadata](https://www.npmjs.com/package/reflect-metadata) | ||
| * [zone.js](https://github.com/angular/zone.js) | ||
|
|
||
| **Note**: `angular2-polyfills.js` contains code that should be loaded into the browser as the very first code of the web application even before the module loader. The preferred solution is to load the mentioned file in a `script` tag as early as possible. | ||
|
|
||
| Users of pre-ES6 browsers might need to add an ES6 shim (e.g. [es6-shim](https://github.com/paulmillr/es6-shim)) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ngUpgrade users can still use whatever type of bundle suits their 1.x app best, right?
I.e. if using Browserify/Webpack/SystemJS, no reason to use UMD just because of ngUpgrade.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. This is more about ng 1 users not using any build tools and writing ES5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding: "These are detailed below"