chore(ts): duplicate the .es6 files in the facade directory to TypeScript.

Adds a gulp task which builds the .ts files (in the cjs build only).
The new files have extension .ts since they are now valid typescript.
Unfortunately until Typescript can emit System.require, we have to keep the old .es6 version
so traceur works inside the Karma preprocessor. This should be fixed soon.
This commit is contained in:
Alex Eagle
2015-04-01 10:45:56 -07:00
parent abea92af59
commit 894a0f0ee5
10 changed files with 669 additions and 7 deletions

View File

@ -1,3 +1,4 @@
var format = require('gulp-clang-format');
var gulp = require('gulp');
var gulpPlugins = require('gulp-load-plugins')();
var shell = require('gulp-shell');
@ -7,7 +8,6 @@ var merge = require('merge');
var path = require('path');
var gulpTraceur = require('./tools/transpiler/gulp-traceur');
var clean = require('./tools/build/clean');
var transpile = require('./tools/build/transpile');
var html = require('./tools/build/html');
@ -143,7 +143,8 @@ var CONFIG = {
}),
cjs: merge(true, _COMPILER_CONFIG_JS_DEFAULT, {
typeAssertionModule: 'rtts_assert/rtts_assert',
typeAssertions: true,
// Don't use type assertions since this is partly transpiled by typescript
typeAssertions: false,
modules: 'commonjs'
})
},
@ -296,6 +297,26 @@ gulp.task('build/clean.docs', clean(gulp, gulpPlugins, {
// ------------
// transpile
gulp.task('build/transpile.ts.cjs', function() {
var tsResult = gulp.src(CONFIG.transpile.src.ts)
.pipe(sourcemaps.init())
.pipe(tsc({
target: 'ES5',
module: /*system.js*/'commonjs',
allowNonTsExtensions: false,
typescript: require('typescript'),
//declarationFiles: true,
noEmitOnError: true
}));
var dest = gulp.dest(CONFIG.dest.js.cjs);
return merge([
// Write external sourcemap next to the js file
tsResult.js.pipe(sourcemaps.write('.')).pipe(dest),
tsResult.js.pipe(dest),
tsResult.dts.pipe(dest),
]);
});
gulp.task('build/transpile.js.dev.es6', transpile(gulp, gulpPlugins, {
src: CONFIG.transpile.src.js,
dest: CONFIG.dest.js.dev.es6,
@ -314,8 +335,7 @@ gulp.task('build/transpile.ts.dev.es5', function() {
module: 'commonjs',
typescript: require('typescript'),
noEmitOnError: true
}))
.js;
}));
return merge([
tsResult.js.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(CONFIG.dest.js.dev.es5)),
@ -524,7 +544,7 @@ gulp.task('build/pubbuild.dart', pubbuild(gulp, gulpPlugins, {
}));
// ------------
// format dart
// formatting
gulp.task('build/format.dart', rundartpackage(gulp, gulpPlugins, {
pub: DART_SDK.PUB,
@ -532,6 +552,11 @@ gulp.task('build/format.dart', rundartpackage(gulp, gulpPlugins, {
args: CONFIG.formatDart.args
}));
gulp.task('check-format', function() {
return gulp.src(['modules/**/*.ts', '!**/typings/**/*.d.ts'])
.pipe(format.checkFormat('file'));
});
// ------------
// check circular dependencies in Node.js context
gulp.task('build/checkCircularDependencies', function (done) {
@ -786,6 +811,9 @@ gulp.task('build.js.prod', function(done) {
gulp.task('build.js.cjs', function(done) {
runSequence(
['build/transpile.js.cjs', 'build/copy.js.cjs', 'build/multicopy.js.cjs'],
// Overwrite the .js.cjs transpilation with typescript outputs
// We still need traceur outputs everywhere else, for now.
'build/transpile.ts.cjs',
['build/linknodemodules.js.cjs'],
'build/transformCJSTests',
done