Skip to content

Commit cc8f74b

Browse files
feat(NgModule): Supply UIROUTER_STATES DI token
- Prepping for using ROUTES token from @angular/router for beta.5, enabling angular-cli
1 parent b0a672f commit cc8f74b

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

.npmignore

Lines changed: 1 addition & 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

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@
6868
"@types/jasmine": "^2.2.34",
6969
"@types/jquery": "^1.10.31",
7070
"awesome-typescript-loader": "^2.2.4",
71+
"babel-core": "^6.22.1",
72+
"babel-loader": "^6.2.10",
7173
"conventional-changelog": "^1.1.0",
7274
"conventional-changelog-cli": "^1.1.1",
7375
"jasmine-core": "^2.4.1",
@@ -89,8 +91,8 @@
8991
"typedoc-plugin-ui-router": "^1.0.0",
9092
"typescript": "~2.0.3",
9193
"ui-router-typedoc-themes": "^1.0.0",
92-
"webpack": "1.x",
93-
"webpack-dev-server": "1.x",
94+
"webpack": "2.2.0",
95+
"webpack-dev-server": "2.2.0",
9496
"webpack-visualizer-plugin": "^0.1.10",
9597
"zone.js": "^0.6.21"
9698
}

src/uiRouterNgModule.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,25 @@ import { UIView } from "./directives/uiView";
1010
import { UrlRuleHandlerFn, TargetState, TargetStateDef } from "ui-router-core";
1111
import { _UIROUTER_INSTANCE_PROVIDERS, _UIROUTER_SERVICE_PROVIDERS } from "./providers";
1212

13+
// import { ROUTES } from "@angular/router/src/router_config_loader";
14+
/** @hidden */ export const UIROUTER_ROOT_MODULE = new OpaqueToken("UIRouter Root Module");
15+
/** @hidden */ export const UIROUTER_MODULE_TOKEN = new OpaqueToken("UIRouter Module");
16+
/** @hidden */ export const UIROUTER_STATES = new OpaqueToken("UIRouter States");
17+
/** @hidden */ export const ROUTES = UIROUTER_STATES;
18+
1319
export function makeRootProviders(module: StatesModule): Provider[] {
1420
return [
1521
{ provide: UIROUTER_ROOT_MODULE, useValue: module, multi: true},
1622
{ provide: UIROUTER_MODULE_TOKEN, useValue: module, multi: true },
17-
{ provide: UIROUTER_STATES, useValue: module.states || [], multi: true },
23+
{ provide: ROUTES, useValue: module.states || [], multi: true },
1824
{ provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: module.states || [], multi: true },
1925
];
2026
}
2127

2228
export function makeChildProviders(module: StatesModule): Provider[] {
2329
return [
2430
{ provide: UIROUTER_MODULE_TOKEN, useValue: module, multi: true },
25-
{ provide: UIROUTER_STATES, useValue: module.states || [], multi: true },
31+
{ provide: ROUTES, useValue: module.states || [], multi: true },
2632
{ provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: module.states || [], multi: true },
2733
];
2834
}
@@ -223,6 +229,3 @@ export interface StatesModule {
223229
configClass?: Type<any>;
224230
}
225231

226-
/** @hidden */ export const UIROUTER_ROOT_MODULE = new OpaqueToken("UIRouter Root Module");
227-
/** @hidden */ export const UIROUTER_MODULE_TOKEN = new OpaqueToken("UIRouter Module");
228-
/** @hidden */ export const UIROUTER_STATES = new OpaqueToken("UIRouter States");

webpack.config.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ module.exports = {
2424
devtool: 'source-map',
2525

2626
resolve: {
27-
modulesDirectories: ['node_modules'],
28-
extensions: ['', '.js', '.ts']
27+
modules: ['node_modules'],
28+
extensions: ['.js', '.ts']
2929
},
3030

3131
plugins: [
@@ -38,16 +38,11 @@ module.exports = {
3838

3939
module: {
4040
loaders: [
41-
{ test: /\.ts$/, loader: "awesome-typescript-loader" }
41+
{ test: /\.ts$/, loader: "awesome-typescript-loader" },
42+
{ test: /\.js$/, loader: "babel-loader" },
4243
]
4344
},
4445

45-
ts: {
46-
compilerOptions: {
47-
declaration: false
48-
}
49-
},
50-
5146
externals: mkExternals([
5247
'rxjs',
5348
'rxjs/Rx',
@@ -74,7 +69,7 @@ function mkExternals(names) {
7469
}
7570

7671
function mkExternal(name) {
77-
var obj = {}
72+
var obj = {};
7873
obj[name] = { root: name, amd: name, commonjs2: name, commonjs: name };
7974
return obj;
8075
}

0 commit comments

Comments
 (0)