chore(router): changes the router setup to align with other modules

This commit is contained in:
vsavkin 2016-06-21 10:35:42 -07:00
parent c9d28492b7
commit 8dd3f59c81
24 changed files with 202 additions and 190 deletions

View File

@ -49,6 +49,7 @@ for PACKAGE in \
platform-browser-dynamic \
platform-server \
http \
router \
router-deprecated \
upgrade \
compiler-cli
@ -93,25 +94,27 @@ do
echo "====== BUNDLING: ${SRCDIR} ====="
mkdir ${DESTDIR}/bundles
(
cd ${SRCDIR}
echo "..." # here just to have grep match something and not exit with 1
../../../node_modules/.bin/rollup -c rollup.config.js
) 2>&1 | grep -v "as external dependency"
if [[ ${PACKAGE} != router ]]; then
(
cd ${SRCDIR}
echo "..." # here just to have grep match something and not exit with 1
../../../node_modules/.bin/rollup -c rollup.config.js
) 2>&1 | grep -v "as external dependency"
$(npm bin)/tsc \
--out ${UMD_ES5_PATH} \
--target es5 \
--lib "es6,dom" \
--allowJs \
${UMD_ES6_PATH}
$(npm bin)/tsc \
--out ${UMD_ES5_PATH} \
--target es5 \
--lib "es6,dom" \
--allowJs \
${UMD_ES6_PATH}
rm ${UMD_ES6_PATH}
rm ${UMD_ES6_PATH}
cat ./modules/@angular/license-banner.txt > ${UMD_ES5_PATH}.tmp
cat ${UMD_ES5_PATH} >> ${UMD_ES5_PATH}.tmp
mv ${UMD_ES5_PATH}.tmp ${UMD_ES5_PATH}
cat ./modules/@angular/license-banner.txt > ${UMD_ES5_PATH}.tmp
cat ${UMD_ES5_PATH} >> ${UMD_ES5_PATH}.tmp
mv ${UMD_ES5_PATH}.tmp ${UMD_ES5_PATH}
$(npm bin)/uglifyjs -c --screw-ie8 -o ${UMD_ES5_MIN_PATH} ${UMD_ES5_PATH}
$(npm bin)/uglifyjs -c --screw-ie8 -o ${UMD_ES5_MIN_PATH} ${UMD_ES5_PATH}
fi
fi
done

View File

@ -1 +0,0 @@
module.exports = require('src/index');

View File

@ -0,0 +1,16 @@
import {RouterLink} from './src/directives/router_link';
import {RouterLinkActive} from './src/directives/router_link_active';
import {RouterOutlet} from './src/directives/router_outlet';
export {ExtraOptions} from './src/common_router_providers';
export {Route, RouterConfig} from './src/config';
export {CanActivate, CanDeactivate} from './src/interfaces';
export {Event, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, Router, RoutesRecognized} from './src/router';
export {RouterOutletMap} from './src/router_outlet_map';
export {provideRouter} from './src/router_providers';
export {ActivatedRoute, ActivatedRouteSnapshot, RouterState, RouterStateSnapshot} from './src/router_state';
export {PRIMARY_OUTLET, Params} from './src/shared';
export {DefaultUrlSerializer, UrlSerializer} from './src/url_serializer';
export {UrlPathWithParams, UrlTree} from './src/url_tree';
export const ROUTER_DIRECTIVES = [RouterOutlet, RouterLink, RouterLinkActive];

View File

@ -1,11 +1,10 @@
/*global jasmine, __karma__, window*/
Error.stackTraceLimit = Infinity;
Error.stackTraceLimit = 10;
jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
__karma__.loaded = function () {
};
function isJsFile(path) {
return path.slice(-3) == '.js';
}
@ -32,14 +31,9 @@ System.config(
{
map: {
'rxjs': 'node_modules/rxjs',
'@angular': 'node_modules/@angular',
'app': 'dist'
'@angular': 'dist/all/@angular'
},
packages: {
'app': {
main: 'main.js',
defaultExtension: 'js'
},
'@angular/core': {
main: 'index.js',
defaultExtension: 'js'
@ -60,6 +54,10 @@ System.config(
main: 'index.js',
defaultExtension: 'js'
},
'@angular/router': {
main: 'index.js',
defaultExtension: 'js'
},
'rxjs': {
main: 'Rx.js',
defaultExtension: 'js'

View File

@ -1,15 +1,16 @@
var browserProvidersConf = require('../../../browser-providers.conf.js');
// Karma configuration
module.exports = function(config) {
config.set({
basePath: '',
basePath: '../../../',
frameworks: ['jasmine'],
files: [
// Polyfills.
'node_modules/es6-shim/es6-shim.js',
'node_modules/reflect-metadata/Reflect.js',
// System.js for module loading
@ -27,17 +28,42 @@ module.exports = function(config) {
{ pattern: 'node_modules/rxjs/**/*.js', included: false, watched: false },
{ pattern: 'node_modules/rxjs/**/*.js.map', included: false, watched: false },
// shim
{pattern: 'modules/@angular/router/karma-test-shim.js', included: true, watched: true },
{pattern: 'karma-test-shim.js', included: true, watched: true},
{pattern: 'built/test/matchers.js', included: true, watched: true},
// Angular modules
{pattern: 'dist/all/@angular/core/*.js', included: false, watched: false},
{pattern: 'dist/all/@angular/core/src/**/*.js', included: false, watched: false},
{pattern: 'dist/all/@angular/core/testing/**/*.js', included: false, watched: false},
// paths loaded via module imports
// Angular itself
{pattern: 'node_modules/@angular/**/*.js', included: false, watched: true},
{pattern: 'node_modules/@angular/**/*.js.map', included: false, watched: true},
{pattern: 'dist/all/@angular/common/*.js', included: false, watched: false},
{pattern: 'dist/all/@angular/common/src/**/*.js', included: false, watched: false},
{pattern: 'dist/all/@angular/common/testing/**/*.js', included: false, watched: false},
{pattern: 'dist/**/*.js', included: false, watched: true},
{pattern: 'dist/**/*.js.map', included: false, watched: false}
{pattern: 'dist/all/@angular/compiler/*.js', included: false, watched: false},
{pattern: 'dist/all/@angular/compiler/src/**/*.js', included: false, watched: false},
{pattern: 'dist/all/@angular/compiler/testing/**/*.js', included: false, watched: false},
{pattern: 'dist/all/@angular/platform-browser/*.js', included: false, watched: false},
{pattern: 'dist/all/@angular/platform-browser/src/**/*.js', included: false, watched: false},
{pattern: 'dist/all/@angular/platform-browser/testing/**/*.js', included: false, watched: false},
{pattern: 'dist/all/@angular/platform-browser-dynamic/*.js', included: false, watched: false},
{pattern: 'dist/all/@angular/platform-browser-dynamic/src/**/*.js', included: false, watched: false},
{pattern: 'dist/all/@angular/platform-browser-dynamic/testing/**/*.js', included: false, watched: false},
// Router
{pattern: 'dist/all/@angular/router/**/*.js', included: false, watched: false}
],
customLaunchers: browserProvidersConf.customLaunchers,
plugins: [
'karma-jasmine',
'karma-browserstack-launcher',
'karma-sauce-launcher',
'karma-chrome-launcher',
'karma-sourcemap-loader'
],
preprocessors: {

View File

@ -2,19 +2,8 @@
"name": "@angular/router",
"version": "3.0.0-alpha.7",
"description": "",
"main": "./dist/index.js",
"jsnext:main": "./dist/esm/index.js",
"scripts": {
"karma": "karma start",
"test": "npm run build; karma start",
"build_watch": "rm -rf dist; tsc -w",
"build": "rm -rf dist; tsc",
"build_npm": "rm -rf dist && tsc -p tsconfig.publish.es5.json && tsc -p tsconfig.publish.esm.json",
"postbuild_npm": "cp package.json README.md dist/ && npm run rewrite_npm_package",
"devsetup": "typings install",
"rewrite_npm_package": "node --harmony_destructuring tools/rewrite-published-package.js",
"build_bundle": "cp -r src router && tsc typings/index.d.ts src/router.ts --rootDir . --module system -t es5 --outFile dist/bundles/router.js --moduleResolution node --emitDecoratorMetadata --experimentalDecorators",
},
"main": "index.js",
"jsnext:main": "esm/index.js",
"keywords": [
"angular2",
"angular",
@ -24,49 +13,19 @@
"type": "git",
"url": "git+https://github.com/angular/angular.git"
},
"author": "vsavkin",
"author": "angular",
"license": "MIT",
"bugs": {
"url": "https://github.com/angular/angular/issues"
},
"homepage": "https://github.com/angular/angular#readme",
"dependencies": {
"@angular/common": "^2.0.0-rc.2",
"@angular/compiler": "^2.0.0-rc.2",
"@angular/core": "^2.0.0-rc.2",
"@angular/platform-browser": "^2.0.0-rc.2",
"@angular/platform-browser-dynamic": "^2.0.0-rc.2",
"peerDependencies": {
"@angular/core": "0.0.0-PLACEHOLDER",
"@angular/compiler": "0.0.0-PLACEHOLDER",
"@angular/common": "0.0.0-PLACEHOLDER",
"@angular/platform-browser": "0.0.0-PLACEHOLDER",
"@angular/platform-browser-dynamic": "0.0.0-PLACEHOLDER",
"rxjs": "5.0.0-beta.6"
},
"devDependencies": {
"es6-module-loader": "^0.17.10",
"es6-shim": "^0.35.0",
"gulp": "^3.9.0",
"gulp-jasmine": "^2.2.1",
"gulp-typescript": "^2.10.0",
"http-server": "^0.8.5",
"jasmine": "^2.4.1",
"jasmine-core": "^2.4.1",
"json": "^9.0.3",
"karma": "^0.13.19",
"karma-chrome-launcher": "^0.2.2",
"karma-firefox-launcher": "^0.1.7",
"karma-jasmine": "^0.3.6",
"karma-systemjs": "^0.10.0",
"karma-sourcemap-loader": "~0.3",
"parse5": "^1.3.2",
"protractor": "3.0.0",
"reflect-metadata": "0.1.2",
"systemjs": "^0.19.16",
"systemjs-builder": "^0.15.7",
"traceur": "0.0.96",
"tsd": "^0.6.5",
"typescript": "^1.8.10",
"typings": "^1.0.4",
"zone.js": "^0.6.6",
"clang-format": "^1.0.35",
"tslint": "^3.6.0",
"codelyzer": "0.0.14"
},
"typings": "dist/index.d.ts"
"typings": "index.d.ts"
}

View File

@ -0,0 +1,29 @@
export default {
entry: '../../../dist/packages-dist/router/esm/index.js',
dest: '../../../dist/packages-dist/router/esm/router.umd.js',
format: 'umd',
moduleName: 'ng.router',
globals: {
'@angular/core': 'ng.core',
'@angular/common': 'ng.common',
'@angular/compiler': 'ng.compiler',
'@angular/platform-browser': 'ng.platformBrowser',
'@angular/platform-browser-dynamic': 'ng.platformBrowserDynamic',
'rxjs/Observable': 'Rx',
'rxjs/Subject': 'Rx',
'rxjs/BehaviorSubject': 'Rx',
'rxjs/Observer': 'Rx',
'rxjs/Subscription': 'Rx',
'rxjs/observable/PromiseObservable': 'Rx', // this is wrong, but this stuff has changed in rxjs b.6 so we need to fix it when we update.
'rxjs/operator/toPromise': 'Rx.Observable.prototype',
'rxjs/operator/map': 'Rx.Observable.prototype',
'rxjs/operator/mergeMap': 'Rx.Observable.prototype',
'rxjs/operator/mergeAll': 'Rx.Observable.prototype',
'rxjs/operator/every': 'Rx.Observable.prototype',
},
plugins: [
// nodeResolve({ jsnext: true, main: true }),
]
}

View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -e -o pipefail
../../../node_modules/.bin/tsc -w

View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
../../../node_modules/.bin/karma start

View File

@ -1,16 +0,0 @@
import {RouterLink} from './directives/router_link';
import {RouterLinkActive} from './directives/router_link_active';
import {RouterOutlet} from './directives/router_outlet';
export {ExtraOptions} from './common_router_providers';
export {Route, RouterConfig} from './config';
export {CanActivate, CanDeactivate} from './interfaces';
export {Event, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, Router, RoutesRecognized} from './router';
export {RouterOutletMap} from './router_outlet_map';
export {provideRouter} from './router_providers';
export {ActivatedRoute, ActivatedRouteSnapshot, RouterState, RouterStateSnapshot} from './router_state';
export {PRIMARY_OUTLET, Params} from './shared';
export {DefaultUrlSerializer, UrlSerializer} from './url_serializer';
export {UrlPathWithParams, UrlTree} from './url_tree';
export const ROUTER_DIRECTIVES = [RouterOutlet, RouterLink, RouterLinkActive];

View File

@ -1,10 +1,7 @@
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/scan';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/concat';
import 'rxjs/add/operator/concatMap';
import 'rxjs/add/operator/every';
import 'rxjs/add/operator/mergeAll';
import 'rxjs/add/operator/every';
import 'rxjs/add/observable/from';
import {Location} from '@angular/common';

View File

@ -1,8 +1,5 @@
import {RouterOutlet} from './directives/router_outlet';
/**
* @internal
*/
export class RouterOutletMap {
/** @internal */
_outlets: {[name: string]: RouterOutlet} = {};

View File

@ -9,7 +9,7 @@ import {beforeEach, beforeEachProviders, ddescribe, describe, expect, fakeAsync,
import {Observable} from 'rxjs/Observable';
import {of } from 'rxjs/observable/of';
import {ActivatedRoute, ActivatedRouteSnapshot, CanActivate, CanDeactivate, DefaultUrlSerializer, Event, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, Params, ROUTER_DIRECTIVES, Router, RouterConfig, RouterOutletMap, RouterStateSnapshot, RoutesRecognized, UrlSerializer} from '../src/index';
import {ActivatedRoute, ActivatedRouteSnapshot, CanActivate, CanDeactivate, DefaultUrlSerializer, Event, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, Params, ROUTER_DIRECTIVES, Router, RouterConfig, RouterOutletMap, RouterStateSnapshot, RoutesRecognized, UrlSerializer} from '../index';
describe('Integration', () => {

View File

@ -1,17 +0,0 @@
/**
* Rewrite the package.json that gets published to npm.
* * Change main to point to router.js instead of dist/router.js
* * Change angular2 to be a peer dependency
*/
var fs = require('fs');
var srcPackage = require('../package.json');
var [MAIN, JSNEXT_MAIN] = ['main', 'jsnext:main'].map(k => srcPackage[k].replace('/dist/', '/'));
var outPackage = Object.assign({}, srcPackage, {
peerDependencies: srcPackage.dependencies,
main: MAIN,
typings: "index.d.ts",
"jsnext:main": JSNEXT_MAIN,
dependencies: undefined
});
fs.writeFileSync('./dist/package.json', JSON.stringify(outPackage, null, 2));

View File

@ -0,0 +1,26 @@
{
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
"stripInternal": true,
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"outDir": "../../../dist/packages-dist/router/esm",
"paths": {
"@angular/core": ["../../../dist/packages-dist/core"],
"@angular/common": ["../../../dist/packages-dist/common"],
"@angular/compiler": ["../../../dist/packages-dist/compiler"],
"@angular/platform-browser": ["../../../dist/packages-dist/platform-browser"],
"@angular/platform-browser-dynamic": ["../../../dist/packages-dist/platform-browser-dynamic"]
},
"rootDir": ".",
"sourceMap": true,
"inlineSources": true,
"lib": ["es6", "dom"],
"target": "es6"
},
"files": [
"index.ts"
]
}

View File

@ -0,0 +1,28 @@
{
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
"stripInternal": true,
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"outDir": "../../../dist/packages-dist/router/",
"paths": {
"@angular/core": ["../../../dist/packages-dist/core"],
"@angular/common": ["../../../dist/packages-dist/common"],
"@angular/compiler": ["../../../dist/packages-dist/compiler"],
"@angular/platform-browser": ["../../../dist/packages-dist/platform-browser"],
"@angular/platform-browser-dynamic": ["../../../dist/packages-dist/platform-browser-dynamic"]
},
"rootDir": ".",
"sourceMap": true,
"inlineSources": true,
"lib": ["es6", "dom"],
"target": "es5"
},
"files": [
"index.ts"
]
}

View File

@ -1,21 +1,24 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitOnError": false,
"module": "commonjs",
"target": "es5",
"noImplicitAny": true,
"noImplicitReturns": true,
"outDir": "dist",
"rootDir": ".",
"inlineSourceMap": true,
"inlineSources": true,
"baseUrl": ".",
"declaration": true,
"removeComments": true
"stripInternal": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"module": "commonjs",
"moduleResolution": "node",
"outDir": "../../../dist/all/@angular/router/",
"paths": {
"@angular/*": ["../../../dist/all/@angular/*"]
},
"rootDir": ".",
"sourceMap": true,
"inlineSources": true,
"lib": ["es6", "dom"],
"target": "es5"
},
"files": [
"src/index.ts",
"index.ts",
"src/router.ts",
"src/apply_redirects.ts",
"src/recognize.ts",
@ -46,7 +49,7 @@
"test/create_url_tree.spec.ts",
"test/config.spec.ts",
"test/router.spec.ts",
"typings/index.d.ts"
"../../../node_modules/@types/jasmine/index.d.ts"
]
}

View File

@ -1,20 +0,0 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"module": "commonjs",
"target": "es5",
"noImplicitAny": true,
"noImplicitReturns": true,
"outDir": "dist",
"rootDir": "src",
"inlineSourceMap": true,
"inlineSources": true,
"declaration": true,
"removeComments": true
},
"files": [
"src/index.ts",
"typings/index.d.ts"
]
}

View File

@ -1,19 +0,0 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"target": "es6",
"noImplicitAny": true,
"noImplicitReturns": true,
"outDir": "dist/esm",
"rootDir": "src",
"inlineSourceMap": true,
"inlineSources": true,
"declaration": true,
"removeComments": true,
"moduleResolution": "node"
},
"files": [
"src/index.ts"
]
}

View File

@ -1,8 +0,0 @@
{
"name": "@angular/router",
"version": false,
"globalDependencies": {
"jasmine": "registry:dt/jasmine#2.2.0+20160505161446",
"es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#6697d6f7dadbf5773cb40ecda35a76027e0783b2"
}
}

View File

@ -28,6 +28,7 @@
"rollup-test",
"upgrade-ts2dart.d.ts",
"zone-ts2dart.d.ts",
"@angular/compiler-cli/integrationtest"
"@angular/compiler-cli/integrationtest",
"@angular/router"
]
}

View File

@ -13,5 +13,6 @@ $(npm bin)/tsc -v
$(npm bin)/tsc -p tools
cp tools/@angular/tsc-wrapped/package.json dist/tools/@angular/tsc-wrapped
node dist/tools/@angular/tsc-wrapped/src/main -p modules
node dist/tools/@angular/tsc-wrapped/src/main -p modules/@angular/router
echo 'travis_fold:end:BUILD'

View File

@ -43,6 +43,9 @@ if [[ ${TRAVIS} ]]; then
fi
$(npm bin)/karma start ./karma-js.conf.js --single-run --browsers=${KARMA_JS_BROWSERS}
$(npm bin)/karma start ./modules/@angular/router/karma.conf.js --single-run --browsers=${KARMA_JS_BROWSERS}
echo 'travis_fold:end:test.unit.localChrome'

View File

@ -3,7 +3,7 @@ set -ex -o pipefail
# These ones can be `npm link`ed for fast development
LINKABLE_PKGS=(
$(pwd)/dist/packages-dist/{common,core,compiler,compiler-cli,http,router-deprecated,upgrade,platform-{browser,browser-dynamic,server}}
$(pwd)/dist/packages-dist/{common,core,compiler,compiler-cli,http,router,router-deprecated,upgrade,platform-{browser,browser-dynamic,server}}
)
TMPDIR=${TMPDIR:-/tmp/angular-build/}