Skip to content

Commit

Permalink
chore(dart/transform): Create targets for serving transformed Dart code
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
Tim Blasi committed Apr 7, 2015
1 parent 1a99090 commit 42c0171
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 37 deletions.
27 changes: 19 additions & 8 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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'));
});



// -----------------
Expand All @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions modules/benchmarks/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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']
35 changes: 8 additions & 27 deletions modules/benchmarks/src/di/di_benchmark.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -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++;
Expand Down
4 changes: 3 additions & 1 deletion tools/build/pubbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
4 changes: 3 additions & 1 deletion tools/build/pubserve.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}));
};
Expand Down

0 comments on commit 42c0171

Please sign in to comment.