feature(build): Include ts2dart transpile step in the Angular build.

This only transpiles one package to start with: di/
It ensures that package transpiles without errors, so no one can
introduce non-TypeScript syntax.
Next step is to widen the task inputs to cover additional packages.

See design doc for the migration:
https://docs.google.com/document/d/14RJLhu6uuv7NchFkAb6PKzOOO0L7l3Z507eKWzkEUhQ/edit

A convenience task 'ts2dart' is added for developing ts2dart, and
it runs all of the angular code through the transpiler to collect errors.
This commit is contained in:
Alex Eagle 2015-03-18 14:42:18 -07:00
parent 81e6d13241
commit 43f4374944
2 changed files with 28 additions and 3 deletions

View File

@ -25,6 +25,7 @@ var minimist = require('minimist');
var es5build = require('./tools/build/es5build');
var runServerDartTests = require('./tools/build/run_server_dart_tests');
var transformCJSTests = require('./tools/build/transformCJSTests');
var ts2dart = require('gulp-ts2dart');
var util = require('./tools/build/util');
// Note: when DART_SDK is not found, all gulp tasks ending with `.dart` will be skipped.
@ -117,7 +118,9 @@ var CONFIG = {
transpile: {
src: {
js: ['modules/**/*.js', 'modules/**/*.es6'],
dart: ['modules/**/*.js']
dart: ['modules/**/*.js'],
// Migrating to TypeScript, one package at a time. See http://goo.gl/RzzVxn
ts2dart: ['modules/angular2/src/di/*.js', 'modules/angular2/test/di/*.js', 'modules/angular2/src/test_lib/*.js']
},
options: {
js: {
@ -347,6 +350,27 @@ gulp.task('build/transpile.dart', transpile(gulp, gulpPlugins, {
srcFolderInsertion: CONFIG.srcFolderInsertion.dart
}));
gulp.task('build/transpile.dart.ts2dart', function() {
return gulp.src(CONFIG.transpile.src.ts2dart)
.pipe(ts2dart.transpile())
.pipe(gulp.dest('dist/dart.ts2dart'))
});
gulp.task('build/format.dart.ts2dart', rundartpackage(gulp, gulpPlugins, {
pub: DART_SDK.PUB,
packageName: CONFIG.formatDart.packageName,
args: ['dart_style:format', '-w', 'dist/dart.ts2dart']
}));
// Temporary tasks for development on ts2dart. Will likely fail.
gulp.task('build/transpile.dart.ts2dart.all', function() {
return gulp.src(CONFIG.transpile.src.dart)
.pipe(ts2dart.transpile())
.pipe(gulp.dest('dist/dart.ts2dart'));
});
gulp.task('ts2dart', function(done) {
runSequence('build/transpile.dart.ts2dart.all', 'build/format.dart.ts2dart', done);
});
// ------------
// html
@ -690,9 +714,9 @@ gulp.task('tests/transform.dart', function() {
// Builds all Dart packages, but does not compile them
gulp.task('build/packages.dart', function(done) {
runSequence(
['build/transpile.dart', 'build/html.dart', 'build/copy.dart', 'build/multicopy.dart'],
['build/transpile.dart.ts2dart', 'build/transpile.dart', 'build/html.dart', 'build/copy.dart', 'build/multicopy.dart'],
'tests/transform.dart',
'build/format.dart',
['build/format.dart.ts2dart', 'build/format.dart'],
'build/pubspec.dart',
done
);

View File

@ -54,6 +54,7 @@
"gulp-sourcemaps": "1.3.*",
"gulp-template": "^3.0.0",
"gulp-traceur": "0.16.*",
"gulp-ts2dart": "^1.0.0",
"gulp-webserver": "^0.8.7",
"js-yaml": "^3.2.7",
"karma": "^0.12.23",