Skip to content

Commit b93a5a6

Browse files
Merge pull request #31 from ui-router/AoT
Add AoT + lazy loading + Angular-CLI support
2 parents 45c7341 + b88a495 commit b93a5a6

34 files changed

+4773
-460
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ _doc
1616
_bundles
1717
lib
1818
lib-esm
19+
stats.html

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Any hidden files
22
**/.*
3+
.*
34

45
src
56
config
@@ -12,6 +13,8 @@ tslint.json
1213
tsconfig.json
1314
tsconfig.**.json
1415
webpack.config.js
16+
rollup.config.js
17+
yarn.lock
1518

1619
*.iml
1720
*.ipr

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: node_js
22
node_js:
3-
- "4.1"
3+
- "6.6"
44

55
before_script:
66
- export DISPLAY=:99.0

README.md

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
1-
# AngularUI Router  [![Build Status](https://travis-ci.org/angular-ui/ui-router.svg?branch=master)](https://travis-ci.org/angular-ui/ui-router)
1+
# UI-Router for Angular 2  [![Build Status](https://travis-ci.org/ui-router/ng2.svg?branch=master)](https://travis-ci.org/ui-router/ng2)
22

3-
**Note: this is the Angular 1.x source for UI-Router version 1.0. If you are looking for the source for UI-Router
4-
version 0.2.x, it can be found [here](https://github.com/angular-ui/ui-router/tree/legacy)**
3+
### ui-router-ng2: State based routing for Angular (2+)
54

65
---
7-
8-
9-
#### The de-facto solution to flexible routing in angular
10-
---
116
**[Tutorials](https://ui-router.github.io/tutorials/)** |
12-
**[API Docs](https://ui-router.github.io/docs/latest/)** |
13-
**[Download stable](http://unpkg.com/angular-ui-router@latest/release/angular-ui-router.js)** (or **[Minified](http://unpkg.com/angular-ui-router@latest/release/angular-ui-router.min.js)**) **|**
14-
**[Guide](https://github.com/angular-ui/ui-router/wiki) |**
7+
**[API Docs](https://ui-router.github.io/ng2/docs/latest/)** |
8+
**[Guides](https://ui-router.github.io/guide)** |
159
**[Sample App](http://ui-router.github.io/resources/sampleapp/) |**
16-
**[FAQ](https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions) |**
17-
**[Report an Issue](https://github.com/angular-ui/ui-router/blob/master/CONTRIBUTING.md#report-an-issue) |**
18-
**[Contribute](https://github.com/angular-ui/ui-router/blob/master/CONTRIBUTING.md#contribute) |**
19-
**[Help!](http://stackoverflow.com/questions/ask?tags=angularjs,angular-ui-router) |**
10+
**[Report an Issue](https://github.com/ui-router/ng2/blob/master/CONTRIBUTING.md#report-an-issue) |**
11+
**[Contribute](https://github.com/ui-router/ng2/blob/master/CONTRIBUTING.md#contribute) |**
12+
**[Help!](http://stackoverflow.com/questions/ask?tags=ui-router-ng2)**
2013

2114
---
2215

23-
Angular UI-Router is a client-side [Single Page Application](https://en.wikipedia.org/wiki/Single-page_application)
24-
routing framework for [AngularJS](http://angularjs.org).
16+
ui-router-ng2 is a client-side [Single Page Application](https://en.wikipedia.org/wiki/Single-page_application)
17+
routing framework for [Angular](http://angular.io).
2518

2619
Routing frameworks for SPAs update the browser's URL as the user navigates through the app. Conversely, this allows
2720
changes to the browser's URL to drive navigation through the app, thus allowing the user to create a bookmark to a
@@ -33,23 +26,7 @@ application states in a transaction-like manner.
3326

3427
## Get Started
3528

36-
37-
- [UI-Router for Angular 1](https://ui-router.github.io/ng1)
3829
- [UI-Router for Angular 2](https://ui-router.github.io/ng2)
39-
- [UI-Router for React](https://ui-router.github.io/react)
40-
41-
## Resources
42-
43-
* [In-Depth Guide](https://github.com/angular-ui/ui-router/wiki)
44-
* [Slides comparing ngRoute to ui-router](http://slid.es/timkindberg/ui-router#/)
45-
* [UI-Router Extras / Addons for legacy (0.x)](http://christopherthielen.github.io/ui-router-extras/#/home) (@christopherthielen)
46-
47-
### Videos
48-
49-
* [Introduction Video](https://egghead.io/lessons/angularjs-introduction-ui-router) (egghead.io)
50-
* [Tim Kindberg on Angular UI-Router](https://www.youtube.com/watch?v=lBqiZSemrqg)
51-
* [Activating States](https://egghead.io/lessons/angularjs-ui-router-activating-states) (egghead.io)
52-
* [Learn Angular.js using UI-Router](http://youtu.be/QETUuZ27N0w) (LearnCode.academy)
5330

5431
## Reporting issues and Contributing
5532

config/system.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ System.config({
1010
'rxjs': 'node_modules/rxjs/bundles/Rx.js',
1111
'@angular': 'node_modules/@angular',
1212

13-
'ui-router-ng2': 'src/ng2.ts'
13+
'ui-router-ng2': 'src/index.ts'
1414
},
1515
map: {
1616
'ui-router-core': 'node_modules/ui-router-core/lib',

package.json

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,18 @@
33
"description": "State-based routing for Angular 2",
44
"version": "1.0.0-beta.4",
55
"scripts": {
6-
"clean": "shx rm -rf lib lib-esm _bundles _doc",
7-
"build": "npm run clean && node_modules/.bin/ngc && node_modules/.bin/ngc -p tsconfig.esm.json && webpack",
8-
"test": "karma start config/karma.ng2.js",
9-
"docs": "typedoc --tsconfig tsconfig.typedoc.json --readme README.md --name 'ui-router-ng2' --theme node_modules/ui-router-typedoc-themes/bin/default --out _doc --internal-aliases internal,coreapi,ng2api --external-aliases internalapi,external --navigation-label-globals ui-router-ng2"
6+
"clean": "shx rm -rf lib lib-esm _bundles _dec",
7+
"compile": "npm run clean && ngc",
8+
"bundle": "rollup -c && rollup -c --environment MINIFY",
9+
"build": "npm run compile && npm run bundle",
10+
"docs": "typedoc --tsconfig tsconfig.typedoc.json --readme README.md --name 'ui-router-ng2' --theme node_modules/ui-router-typedoc-themes/bin/default --out _doc --internal-aliases internal,coreapi,ng2api --external-aliases internalapi,external --navigation-label-globals ui-router-ng2",
11+
"prepublish": "npm run build"
1012
},
1113
"homepage": "https://ui-router.github.io/ng2",
1214
"contributors": [
13-
{
14-
"name": "Nate Abele",
15-
"email": "[email protected]",
16-
"web": "https://radify.io"
17-
},
1815
{
1916
"name": "Chris Thielen",
2017
"web": "https://github.com/christopherthielen"
21-
},
22-
{
23-
"name": "Tim Kindberg",
24-
"web": "https://github.com/timkindberg"
25-
},
26-
{
27-
"name": "Karsten Sperling",
28-
"web": "https://github.com/ksperling"
2918
}
3019
],
3120
"maintainers": [
@@ -42,18 +31,20 @@
4231
"url": "https://github.com/ui-router/ng2/issues"
4332
},
4433
"engines": {
45-
"node": ">4"
34+
"node": ">6"
4635
},
4736
"license": "MIT",
48-
"jsnext:main": "lib-esm/ng2.js",
49-
"main": "lib/ng2.js",
50-
"typings": "lib/ng2.d.ts",
37+
"main": "_bundles/ui-router-ng2.js",
38+
"module": "lib/index.js",
39+
"typings": "lib/index.d.ts",
5140
"dependencies": {
52-
"ui-router-core": "=1.0.1"
41+
"ui-router-core": "=4.0.0",
42+
"ui-router-rx": "=0.2.1"
5343
},
5444
"peerDependencies": {
55-
"@angular/core": "^2.0.0",
56-
"@angular/common": "^2.0.0"
45+
"@angular/common": "^2.3.1",
46+
"@angular/core": "^2.3.1",
47+
"@angular/router": "^3.3.1"
5748
},
5849
"devDependencies": {
5950
"@angular/common": "^2.3.1",
@@ -63,9 +54,12 @@
6354
"@angular/platform-browser": "^2.3.1",
6455
"@angular/platform-browser-dynamic": "^2.3.1",
6556
"@angular/platform-server": "^2.3.1",
57+
"@angular/router": "^3.3.1",
6658
"@types/jasmine": "^2.2.34",
6759
"@types/jquery": "^1.10.31",
6860
"awesome-typescript-loader": "^2.2.4",
61+
"babel-core": "^6.22.1",
62+
"babel-loader": "^6.2.10",
6963
"conventional-changelog": "^1.1.0",
7064
"conventional-changelog-cli": "^1.1.1",
7165
"jasmine-core": "^2.4.1",
@@ -76,6 +70,13 @@
7670
"karma-phantomjs-launcher": "^1.0.2",
7771
"karma-script-launcher": "~0.1.0",
7872
"karma-systemjs": "^0.7.2",
73+
"rollup": "^0.41.4",
74+
"rollup-plugin-commonjs": "^7.0.0",
75+
"rollup-plugin-node-resolve": "^2.0.0",
76+
"rollup-plugin-progress": "^0.2.1",
77+
"rollup-plugin-sourcemaps": "^0.4.1",
78+
"rollup-plugin-uglify": "^1.0.1",
79+
"rollup-plugin-visualizer": "^0.2.0",
7980
"rxjs": "5.0.0-beta.12",
8081
"shelljs": "^0.7.0",
8182
"shx": "^0.1.4",
@@ -87,8 +88,9 @@
8788
"typedoc-plugin-ui-router": "^1.0.0",
8889
"typescript": "~2.0.3",
8990
"ui-router-typedoc-themes": "^1.0.0",
90-
"webpack": "1.x",
91-
"webpack-dev-server": "1.x",
91+
"webpack": "2.2.0",
92+
"webpack-dev-server": "2.2.0",
93+
"webpack-visualizer-plugin": "^0.1.10",
9294
"zone.js": "^0.6.21"
9395
}
9496
}

rollup.config.js

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import nodeResolve from 'rollup-plugin-node-resolve';
2+
import uglify from 'rollup-plugin-uglify';
3+
import progress from 'rollup-plugin-progress';
4+
import sourcemaps from 'rollup-plugin-sourcemaps';
5+
import visualizer from 'rollup-plugin-visualizer';
6+
import commonjs from 'rollup-plugin-commonjs';
7+
8+
let MINIFY = process.env.MINIFY;
9+
10+
let pkg = require('./package.json');
11+
let banner =
12+
`/**
13+
* ${pkg.description}
14+
* @version v${pkg.version}
15+
* @link ${pkg.homepage}
16+
* @license MIT License, http://www.opensource.org/licenses/MIT
17+
*/`;
18+
19+
let uglifyOpts = { output: {} };
20+
// retain multiline comment with @license
21+
uglifyOpts.output.comments = (node, comment) =>
22+
comment.type === 'comment2' && /@license/i.test(comment.value);
23+
24+
let plugins = [
25+
nodeResolve({jsnext: true}),
26+
progress(),
27+
sourcemaps(),
28+
commonjs(),
29+
];
30+
31+
if (MINIFY) plugins.push(uglify(uglifyOpts));
32+
if (MINIFY) plugins.push(visualizer({ sourcemap: true }));
33+
34+
let extension = MINIFY ? '.min.js' : '.js';
35+
36+
// Suppress this error message... there are hundreds of them. Angular team says to ignore it.
37+
// https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
38+
function onwarn(warning) {
39+
if (warning.code === 'THIS_IS_UNDEFINED') return;
40+
console.error(warning.message);
41+
}
42+
43+
function isExternal(id) {
44+
// All rxjs and @angular/* should be external
45+
// except for @angular/router/src/router_config_loader
46+
let externals = [ /^rxjs/, /^@angular\/(?!router\/src\/router_config_loader)/, ];
47+
return externals.map(regex => regex.exec(id)).reduce((acc, val) => acc || !!val, false);
48+
}
49+
50+
const CONFIG = {
51+
moduleName: 'ui-router-ng2',
52+
entry: 'lib/index.js',
53+
dest: '_bundles/ui-router-ng2' + extension,
54+
55+
sourceMap: true,
56+
format: 'umd',
57+
exports: 'named',
58+
plugins: plugins,
59+
banner: banner,
60+
61+
onwarn: onwarn,
62+
external: isExternal,
63+
64+
globals: {
65+
'rxjs/ReplaySubject': 'Rx',
66+
67+
// Copied these from @angular/router rollup config
68+
'rxjs/BehaviorSubject': 'Rx',
69+
'rxjs/Observable': 'Rx',
70+
'rxjs/Subject': 'Rx',
71+
'rxjs/Subscription': 'Rx',
72+
'rxjs/util/EmptyError': 'Rx',
73+
74+
'rxjs/observable/from': 'Rx.Observable',
75+
'rxjs/observable/fromPromise': 'Rx.Observable',
76+
'rxjs/observable/forkJoin': 'Rx.Observable',
77+
'rxjs/observable/of': 'Rx.Observable',
78+
79+
'rxjs/operator/toPromise': 'Rx.Observable.prototype',
80+
'rxjs/operator/map': 'Rx.Observable.prototype',
81+
'rxjs/operator/mergeAll': 'Rx.Observable.prototype',
82+
'rxjs/operator/concatAll': 'Rx.Observable.prototype',
83+
'rxjs/operator/mergeMap': 'Rx.Observable.prototype',
84+
'rxjs/operator/reduce': 'Rx.Observable.prototype',
85+
'rxjs/operator/every': 'Rx.Observable.prototype',
86+
'rxjs/operator/first': 'Rx.Observable.prototype',
87+
'rxjs/operator/catch': 'Rx.Observable.prototype',
88+
'rxjs/operator/last': 'Rx.Observable.prototype',
89+
'rxjs/operator/filter': 'Rx.Observable.prototype',
90+
'rxjs/operator/concatMap': 'Rx.Observable.prototype',
91+
92+
'@angular/core': 'ng.core',
93+
'@angular/common': 'ng.common',
94+
}
95+
};
96+
97+
export default CONFIG;

scripts/release.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
#!env node
22
"use strict";
33

4+
let version = require('../package.json').version;
5+
46
require('shelljs/global');
57
let readlineSync = require('readline-sync');
8+
let fs = require('fs');
9+
let path = require('path');
610
let util = require('./util');
711
let _exec = util._exec;
812

9-
let version = require('../package.json').version;
13+
cd(path.join(__dirname, '..'));
1014

1115
if (!readlineSync.keyInYN('Did you bump the version number in package.json?')) {
1216
process.exit(1);
@@ -16,12 +20,24 @@ if (!readlineSync.keyInYN('Did you update CHANGELOG.md using scripts/update_chan
1620
process.exit(1);
1721
}
1822

19-
if (!readlineSync.keyInYN('Did you commit/push all changes back to origin?')) {
23+
if (!readlineSync.keyInYN('Did you push all changes back to origin?')) {
24+
process.exit(1);
25+
}
26+
27+
if (!readlineSync.keyInYN('Ready to publish?')) {
2028
process.exit(1);
2129
}
2230

2331
util.ensureCleanMaster('master');
32+
33+
_exec('npm run package');
34+
_exec(`npm run docs`);
35+
36+
// publish to npm first
2437
_exec(`npm publish`);
38+
39+
// then tag and push tag
2540
_exec(`git tag ${version}`);
2641
_exec(`git push origin ${version}`);
2742

43+
console.log("\n\nAPI docs generated (but not deployed) at ./_docs");

0 commit comments

Comments
 (0)