mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 20:33:32 +08:00
chore(build): only typecheck on release
This commit is contained in:
81
gulpfile.js
81
gulpfile.js
@ -23,27 +23,23 @@ var flags = minimist(process.argv.slice(2), flagConfig);
|
|||||||
|
|
||||||
var IS_RELEASE = false;
|
var IS_RELEASE = false;
|
||||||
|
|
||||||
var tscOptions = {
|
function getTscOptions(name) {
|
||||||
emitDecoratorMetadata: true,
|
var opts = {
|
||||||
experimentalDecorators: true,
|
emitDecoratorMetadata: true,
|
||||||
target: "es5",
|
experimentalDecorators: true,
|
||||||
module: "commonjs",
|
target: "es5",
|
||||||
declaration: true
|
module: "commonjs",
|
||||||
}
|
isolatedModules: true
|
||||||
|
}
|
||||||
|
|
||||||
var tscOptionsNoTypeCheck = {
|
if (name === "typecheck") {
|
||||||
emitDecoratorMetadata: true,
|
opts.declaration = true;
|
||||||
experimentalDecorators: true,
|
delete opts.isolatedModules;
|
||||||
target: "es5",
|
} else if (name === "es6") {
|
||||||
module: "commonjs",
|
opts.target = "es6";
|
||||||
isolatedModules: true
|
delete opts.module;
|
||||||
}
|
}
|
||||||
|
return opts;
|
||||||
var tscOptionsEs6 = {
|
|
||||||
emitDecoratorMetadata: true,
|
|
||||||
experimentalDecorators: true,
|
|
||||||
target: 'ES6',
|
|
||||||
isolatedModules: true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var tscReporter = {
|
var tscReporter = {
|
||||||
@ -150,33 +146,24 @@ function tsCompile(options, cacheName){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
gulp.task('transpile.no-typecheck', function(){
|
gulp.task('transpile', function(){
|
||||||
var gulpif = require('gulp-if');
|
var gulpif = require('gulp-if');
|
||||||
var stripDebug = require('gulp-strip-debug');
|
var stripDebug = require('gulp-strip-debug');
|
||||||
|
|
||||||
return tsCompile(tscOptionsNoTypeCheck, 'no-typecheck')
|
var tscOpts = getTscOptions(IS_RELEASE ? 'typecheck' : undefined);
|
||||||
.pipe(gulpif(IS_RELEASE, stripDebug()))
|
var tsResult = tsCompile(tscOpts, 'transpile')
|
||||||
.pipe(gulp.dest('dist'));
|
|
||||||
});
|
|
||||||
|
|
||||||
gulp.task('typecheck', ['transpile.typecheck']);
|
|
||||||
|
|
||||||
gulp.task('transpile.typecheck', function(){
|
|
||||||
var merge = require('merge2');
|
|
||||||
var stripDebug = require('gulp-strip-debug');
|
|
||||||
|
|
||||||
var result = tsCompile(tscOptions, 'typecheck');
|
|
||||||
|
|
||||||
var js = result.js;
|
|
||||||
var dts = result.dts;
|
|
||||||
if (IS_RELEASE) {
|
if (IS_RELEASE) {
|
||||||
js = js.pipe(stripDebug());
|
var merge = require('merge2');
|
||||||
|
var js = tsResult.js.pipe(stripDebug());
|
||||||
|
var dts = tsResult.dts;
|
||||||
|
// merge definition and source streams
|
||||||
|
return merge([js, dts])
|
||||||
|
.pipe(gulp.dest('dist'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// merge definition and source streams
|
return tsResult.pipe(gulp.dest('dist'));
|
||||||
return merge([js, dts])
|
});
|
||||||
.pipe(gulp.dest('dist'));
|
|
||||||
})
|
|
||||||
|
|
||||||
gulp.task('bundle.system', function(){
|
gulp.task('bundle.system', function(){
|
||||||
var babel = require('gulp-babel');
|
var babel = require('gulp-babel');
|
||||||
@ -185,7 +172,7 @@ gulp.task('bundle.system', function(){
|
|||||||
var stripDebug = require('gulp-strip-debug');
|
var stripDebug = require('gulp-strip-debug');
|
||||||
var merge = require('merge2');
|
var merge = require('merge2');
|
||||||
|
|
||||||
var tsResult = tsCompile(tscOptionsEs6, 'system')
|
var tsResult = tsCompile(getTscOptions('es6'), 'system')
|
||||||
.pipe(babel(babelOptions));
|
.pipe(babel(babelOptions));
|
||||||
|
|
||||||
var swiper = gulp.src('ionic/components/slides/swiper-widget.system.js');
|
var swiper = gulp.src('ionic/components/slides/swiper-widget.system.js');
|
||||||
@ -198,8 +185,6 @@ gulp.task('bundle.system', function(){
|
|||||||
.pipe(connect.reload())
|
.pipe(connect.reload())
|
||||||
})
|
})
|
||||||
|
|
||||||
gulp.task('transpile', ['transpile.no-typecheck']);
|
|
||||||
|
|
||||||
gulp.task('bundle', ['bundle.cjs', 'bundle.system']);
|
gulp.task('bundle', ['bundle.cjs', 'bundle.system']);
|
||||||
|
|
||||||
gulp.task('bundle.cjs', ['transpile'], function(done){
|
gulp.task('bundle.cjs', ['transpile'], function(done){
|
||||||
@ -249,7 +234,7 @@ function bundle(args) {
|
|||||||
|
|
||||||
gulp.task('tests', function() {
|
gulp.task('tests', function() {
|
||||||
return gulp.src('ionic/**/test/**/*.spec.ts')
|
return gulp.src('ionic/**/test/**/*.spec.ts')
|
||||||
.pipe(tsc(tscOptionsNoTypeCheck, undefined, tscReporter))
|
.pipe(tsc(getTscOptions(), undefined, tscReporter))
|
||||||
.pipe(rename(function(file) {
|
.pipe(rename(function(file) {
|
||||||
var regex = new RegExp(path.sep + 'test(' + path.sep + '|$)');
|
var regex = new RegExp(path.sep + 'test(' + path.sep + '|$)');
|
||||||
file.dirname = file.dirname.replace(regex, path.sep);
|
file.dirname = file.dirname.replace(regex, path.sep);
|
||||||
@ -282,7 +267,7 @@ gulp.task('e2e.build', function() {
|
|||||||
'!ionic/components/*/test/*/**/*.spec.ts'
|
'!ionic/components/*/test/*/**/*.spec.ts'
|
||||||
])
|
])
|
||||||
.pipe(cache('e2e.ts'))
|
.pipe(cache('e2e.ts'))
|
||||||
.pipe(tsc(tscOptionsNoTypeCheck, undefined, tscReporter))
|
.pipe(tsc(getTscOptions(), undefined, tscReporter))
|
||||||
.on('error', function(error) {
|
.on('error', function(error) {
|
||||||
console.log(error.message);
|
console.log(error.message);
|
||||||
this.emit('end');
|
this.emit('end');
|
||||||
@ -443,7 +428,6 @@ gulp.task('src', function(done){
|
|||||||
'clean',
|
'clean',
|
||||||
'copy.libs',
|
'copy.libs',
|
||||||
['bundle', 'sass', 'fonts', 'copy.scss'],
|
['bundle', 'sass', 'fonts', 'copy.scss'],
|
||||||
'transpile.typecheck',
|
|
||||||
done
|
done
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -454,7 +438,6 @@ gulp.task('src.release', function(done) {
|
|||||||
'clean',
|
'clean',
|
||||||
'copy.libs',
|
'copy.libs',
|
||||||
['bundle', 'sass', 'fonts', 'copy.scss'],
|
['bundle', 'sass', 'fonts', 'copy.scss'],
|
||||||
'transpile.typecheck',
|
|
||||||
done
|
done
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -595,7 +578,7 @@ gulp.task('build.demos', function(){
|
|||||||
|
|
||||||
var tsResult = gulp.src(['demos/**/*.ts'])
|
var tsResult = gulp.src(['demos/**/*.ts'])
|
||||||
.pipe(cache('demos.ts'))
|
.pipe(cache('demos.ts'))
|
||||||
.pipe(tsc(tscOptionsNoTypeCheck, undefined, tscReporter))
|
.pipe(tsc(getTscOptions(), undefined, tscReporter))
|
||||||
.on('error', function(error) {
|
.on('error', function(error) {
|
||||||
console.log(error.message);
|
console.log(error.message);
|
||||||
this.emit('end');
|
this.emit('end');
|
||||||
@ -632,7 +615,7 @@ gulp.task('build.demos', function(){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('bundle.demos', ['build.demos', 'transpile.no-typecheck', 'copy.libs', 'sass', 'fonts'], function(done) {
|
gulp.task('bundle.demos', ['build.demos', 'transpile', 'copy.libs', 'sass', 'fonts'], function(done) {
|
||||||
buildDemoBundle(done);
|
buildDemoBundle(done);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user