From 8e1d53b5e9ac2e3e080efb46c29d6ed28eafca9c Mon Sep 17 00:00:00 2001 From: Rado Kirov Date: Mon, 4 May 2015 17:57:28 -0700 Subject: [PATCH] feat(router): adds the router to the self-executing bundle. Due to limitation of system build, the router cannot have its own sfx bundle. Fixes an issue with RouteConfig decorator by moving it into its own file. --- gulpfile.js | 10 +++------- modules/angular2/angular2_sfx.es6 | 8 +++++++- modules/angular2/router.js | 3 ++- .../angular2/src/router/route_config_annotation.es6 | 4 ---- .../angular2/src/router/route_config_decorator.dart | 3 +++ modules/angular2/src/router/route_config_decorator.es6 | 5 +++++ 6 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 modules/angular2/src/router/route_config_decorator.dart create mode 100644 modules/angular2/src/router/route_config_decorator.es6 diff --git a/gulpfile.js b/gulpfile.js index 9f0f5046ec..654027ab63 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -616,8 +616,6 @@ gulp.task('bundle.js.dev', ['build.js.dev'], function() { { sourceMaps: true }); }); -// TODO: remove redundancies with router and angular bundles -// development router build gulp.task('router.bundle.js.dev', ['build.js.dev'], function() { var devBundleConfig = merge(true, bundleConfig); devBundleConfig.paths = @@ -626,8 +624,8 @@ gulp.task('router.bundle.js.dev', ['build.js.dev'], function() { }); return bundler.bundle( devBundleConfig, - 'angular2/router', - './dist/build/router.dev.js', + 'angular2/router - angular2/angular2', + './dist/bundle/router.dev.js', { sourceMaps: true }); }); @@ -647,7 +645,7 @@ gulp.task('bundle.js.sfx.dev', ['build.js.dev'], function() { 'angular2/angular2_sfx', './dist/build/angular2.sfx.dev.js', { sourceMaps: true }, - /* self-exectuting */ true); + /* self-executing */ true); }); gulp.task('bundle.js.prod.deps', ['bundle.js.prod'], function() { @@ -669,14 +667,12 @@ var JS_DEV_DEPS = ['node_modules/zone.js/zone.js', gulp.task('bundle.js.dev.deps', ['bundle.js.dev'], function() { return bundler.modify(JS_DEV_DEPS.concat(['dist/build/angular2.dev.js']), 'angular2.dev.js') .pipe(insert.append('\nSystem.config({"paths":{"*":"*.js","angular2/*":"angular2/*"}});\n')) - .pipe(insert.append('\nzone = zone.fork(Zone.longStackTraceZone);\n')) .pipe(gulp.dest('dist/bundle')); }); gulp.task('bundle.js.sfx.dev.deps', ['bundle.js.sfx.dev'], function() { return bundler.modify(JS_DEV_DEPS.concat(['dist/build/angular2.sfx.dev.js']), 'angular2.sfx.dev.js') - .pipe(insert.append('\nzone = zone.fork(Zone.longStackTraceZone);\n')) .pipe(gulp.dest('dist/bundle')); }); diff --git a/modules/angular2/angular2_sfx.es6 b/modules/angular2/angular2_sfx.es6 index 58859f7b7b..f9a8bf972f 100644 --- a/modules/angular2/angular2_sfx.es6 +++ b/modules/angular2/angular2_sfx.es6 @@ -1,10 +1,16 @@ import * as angular from './angular2'; +// the router should have its own SFX bundle +// But currently the module arithemtic 'angular2/router_sfx - angular2/angular2', +// is not support by system builder. +import * as router from './router'; + +angular.router = router; var _prevAngular = window.angular; /** * Calling noConflict will restore window.angular to its pre-angular loading state - * and return the angular module object. + * and return the angular module object. */ angular.noConflict = function() { window.angular = _prevAngular; diff --git a/modules/angular2/router.js b/modules/angular2/router.js index ac734a48e4..1dfaafcbf7 100644 --- a/modules/angular2/router.js +++ b/modules/angular2/router.js @@ -10,7 +10,8 @@ export {Router} from './src/router/router'; export {RouterOutlet} from './src/router/router_outlet'; export {RouterLink} from './src/router/router_link'; export {RouteParams} from './src/router/instruction'; -export {RouteConfig} from './src/router/route_config_annotation'; +export * from './src/router/route_config_annotation'; +export * from './src/router/route_config_decorator'; import {Router, RootRouter} from './src/router/router'; import {RouteRegistry} from './src/router/route_registry'; diff --git a/modules/angular2/src/router/route_config_annotation.es6 b/modules/angular2/src/router/route_config_annotation.es6 index 862711fb39..59f27e9869 100644 --- a/modules/angular2/src/router/route_config_annotation.es6 +++ b/modules/angular2/src/router/route_config_annotation.es6 @@ -1,5 +1 @@ export {RouteConfig as RouteConfigAnnotation} from './route_config_impl'; - -import {makeDecorator} from 'angular2/src/util/decorators'; - -export var RouteConfig = makeDecorator(RouteConfig); diff --git a/modules/angular2/src/router/route_config_decorator.dart b/modules/angular2/src/router/route_config_decorator.dart new file mode 100644 index 0000000000..6065b5aadb --- /dev/null +++ b/modules/angular2/src/router/route_config_decorator.dart @@ -0,0 +1,3 @@ +library angular2.router.route_config_decorator; + +/** This file is intentionally empty, as Dart does not have decorators */ diff --git a/modules/angular2/src/router/route_config_decorator.es6 b/modules/angular2/src/router/route_config_decorator.es6 new file mode 100644 index 0000000000..09e8dd3a28 --- /dev/null +++ b/modules/angular2/src/router/route_config_decorator.es6 @@ -0,0 +1,5 @@ +import {RouteConfig as RouteConfigAnnotation} from './route_config_impl'; +import {makeDecorator} from 'angular2/src/util/decorators'; + +export var RouteConfig = makeDecorator(RouteConfigAnnotation); +