From 42c0171b409f8753d35f20e26f3743a0a7d256db Mon Sep 17 00:00:00 2001 From: Tim Blasi Date: Mon, 6 Apr 2015 14:48:07 -0700 Subject: [PATCH] chore(dart/transform): Create targets for serving transformed Dart code - Allow pub (build|serve) to specify mode - Update pubbuild.js & pubserve.js to allow the caller to provide a `mode` value. - Update settings to allow the di benchmark to be transformed to run statically. --- gulpfile.js | 27 +++++++++++------ modules/benchmarks/pubspec.yaml | 2 ++ modules/benchmarks/src/di/di_benchmark.js | 35 ++++++----------------- tools/build/pubbuild.js | 4 ++- tools/build/pubserve.js | 4 ++- 5 files changed, 35 insertions(+), 37 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 2f29335e1a..d40f700554 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -183,7 +183,7 @@ var CONFIG = { }, dart: { src: [ - 'modules/**/*.md', '!modules/**/*.js.md', 'modules/**/*.png', + 'modules/**/*.md', '!modules/**/*.js.md', 'modules/**/*.png', 'modules/**/*.html', 'modules/**/*.dart', 'modules/*/pubspec.yaml', 'modules/**/*.css', '!modules/**/e2e_test/**' ], pipes: { @@ -608,6 +608,24 @@ gulp.task('serve/benchmarks_external.dart', pubserve(gulp, gulpPlugins, { path: CONFIG.dest.dart + '/benchmarks_external' })); +gulp.task('serve/examples.dart.static', pubserve(gulp, gulpPlugins, { + command: DART_SDK.PUB, + mode: 'ngstatic', + path: CONFIG.dest.dart + '/examples' +})); + +gulp.task('serve/benchmarks.dart.static', pubserve(gulp, gulpPlugins, { + command: DART_SDK.PUB, + mode: 'ngstatic', + path: CONFIG.dest.dart + '/benchmarks' +})); + +gulp.task('serve/benchmarks_external.dart.static', pubserve(gulp, gulpPlugins, { + command: DART_SDK.PUB, + mode: 'ngstatic', + path: CONFIG.dest.dart + '/benchmarks_external' +})); + // -------------- // doc generation var Dgeni = require('dgeni'); @@ -758,12 +776,6 @@ gulp.task('test.transpiler.unittest', function (done) { })) }); -// Copy test resources to dist -gulp.task('tests/transform.dart', function() { - return gulp.src('modules/angular2/test/transform/**') - .pipe(gulp.dest('dist/dart/angular2/test/transform')); -}); - // ----------------- @@ -773,7 +785,6 @@ gulp.task('tests/transform.dart', function() { gulp.task('build/packages.dart', function(done) { runSequence( ['build/transpile.dart.ts2dart', 'build/transpile.dart', 'build/html.dart', 'build/copy.dart', 'build/multicopy.dart'], - 'tests/transform.dart', // the two format steps don't need to be sequential, but we have seen flakiness in // dartstyle:format with connecting to localhost. 'build/format.dart.ts2dart', diff --git a/modules/benchmarks/pubspec.yaml b/modules/benchmarks/pubspec.yaml index 172e093931..e62725198e 100644 --- a/modules/benchmarks/pubspec.yaml +++ b/modules/benchmarks/pubspec.yaml @@ -15,6 +15,8 @@ dependency_overrides: angular2: path: ../angular2 transformers: +- angular2: + entry_point: web/src/di/di_benchmark.dart - $dart2js: minify: false commandLineOptions: ['--dump-info', '--trust-type-annotations', '--trust-primitives'] diff --git a/modules/benchmarks/src/di/di_benchmark.js b/modules/benchmarks/src/di/di_benchmark.js index 5ceadfdb8b..98815eff56 100644 --- a/modules/benchmarks/src/di/di_benchmark.js +++ b/modules/benchmarks/src/di/di_benchmark.js @@ -1,36 +1,13 @@ -import {Injector, Key} from "angular2/di"; +import {Injectable, Injector, Key} from "angular2/di"; import {reflector} from 'angular2/src/reflection/reflection'; +import {ReflectionCapabilities} from 'angular2/src/reflection/reflection_capabilities'; import {getIntParameter, bindAction, microBenchmark} from 'angular2/src/test_lib/benchmark_util'; import {BrowserDomAdapter} from 'angular2/src/dom/browser_adapter'; var count = 0; function setupReflector() { - reflector.registerType(A, { - 'factory': () => new A(), - 'parameters': [], - 'annotations' : [] - }); - reflector.registerType(B, { - 'factory': (a) => new B(a), - 'parameters': [[A]], - 'annotations' : [] - }); - reflector.registerType(C, { - 'factory': (b) => new C(b), - 'parameters': [[B]], - 'annotations' : [] - }); - reflector.registerType(D, { - 'factory': (c,b) => new D(c,b), - 'parameters': [[C],[B]], - 'annotations' : [] - }); - reflector.registerType(E, { - 'factory': (d,c) => new E(d,c), - 'parameters': [[D],[C]], - 'annotations' : [] - }); + reflector.reflectionCapabilities = new ReflectionCapabilities(); } export function main() { @@ -97,31 +74,35 @@ export function main() { - +@Injectable() class A { constructor() { count++; } } +@Injectable() class B { constructor(a:A) { count++; } } +@Injectable() class C { constructor(b:B) { count++; } } +@Injectable() class D { constructor(c:C, b:B) { count++; } } +@Injectable() class E { constructor(d:D, c:C) { count++; diff --git a/tools/build/pubbuild.js b/tools/build/pubbuild.js index 1d4d8b487d..930d4daef4 100644 --- a/tools/build/pubbuild.js +++ b/tools/build/pubbuild.js @@ -17,7 +17,9 @@ module.exports = function(gulp, plugins, config) { } var folder = path.resolve(path.join(webFolders.shift(), '..')); var destFolder = path.resolve(path.join(config.dest, path.basename(folder))); - return util.processToPromise(spawn(config.command, ['build', '-o', destFolder], { + var pubMode = config.mode || 'release'; + var pubArgs = ['build', '--mode', pubMode, '-o', destFolder]; + return util.processToPromise(spawn(config.command, pubArgs, { stdio: 'inherit', cwd: folder })).then(function() { diff --git a/tools/build/pubserve.js b/tools/build/pubserve.js index 8080f91ce2..69857885d3 100644 --- a/tools/build/pubserve.js +++ b/tools/build/pubserve.js @@ -3,7 +3,9 @@ var spawn = require('child_process').spawn; module.exports = function(gulp, plugins, config, module) { return function() { - return util.streamToPromise(spawn(config.command, ['serve'], { + var pubMode = config.mode || 'debug'; + var pubArgs = ['serve', '--mode', pubMode]; + return util.streamToPromise(spawn(config.command, pubArgs, { cwd: config.path, stdio: 'inherit' })); };