From 656567aed0d9b1683def80b38b50b55b87220631 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sun, 27 May 2018 07:30:37 -0700 Subject: [PATCH] Use incremental tsc builds --- gulpfile.js | 56 ++------------------------- package.json | 7 ++-- src/addons/attach/tsconfig.json | 3 +- src/addons/fit/tsconfig.json | 3 +- src/addons/fullscreen/tsconfig.json | 3 +- src/addons/search/tsconfig.json | 3 +- src/addons/terminado/tsconfig.json | 3 +- src/addons/webLinks/tsconfig.json | 3 +- src/addons/winptyCompat/tsconfig.json | 3 +- src/addons/zmodem/tsconfig.json | 3 +- tsconfig.json | 3 +- 11 files changed, 26 insertions(+), 64 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index af4fdce0e..3b44f1fd9 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -20,7 +20,6 @@ const webpack = require('webpack-stream'); const buildDir = process.env.BUILD_DIR || 'build'; const tsProject = ts.createProject('tsconfig.json'); -const srcDir = tsProject.config.compilerOptions.rootDir; let outDir = tsProject.config.compilerOptions.outDir; const addons = fs.readdirSync(`${__dirname}/src/addons`); @@ -31,58 +30,11 @@ if (path.normalize(outDir).indexOf(__dirname) !== 0) { outDir = `${__dirname}/${path.normalize(outDir)}`; } -/** - * Compile TypeScript sources to JavaScript files and create a source map file for each TypeScript - * file compiled. - */ -gulp.task('tsc', function () { - // Remove the ${outDir}/ directory to prevent confusion if files were deleted in ${srcDir}/ - fs.emptyDirSync(`${outDir}`); - - // Build all TypeScript files (including tests) to ${outDir}/, based on the configuration defined in - // `tsconfig.json`. - let tsResult = tsProject.src().pipe(sourcemaps.init()).pipe(tsProject()); - let tsc = merge( - tsResult.js.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''})).pipe(gulp.dest(outDir)), - tsResult.dts.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''})).pipe(gulp.dest(outDir)) - ); - - let addonStreams = addons.map(function(addon) { - fs.emptyDirSync(`${outDir}/addons/${addon}`); - - let tsProjectAddon = ts.createProject(`./src/addons/${addon}/tsconfig.json`); - let tsResultAddon = tsProjectAddon.src().pipe(sourcemaps.init()).pipe(tsProjectAddon()); - let tscAddon = merge( - tsResultAddon.js - .pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''})) - .pipe(gulp.dest(`${outDir}/addons/${addon}`)), - tsResultAddon.dts - .pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: ''})) - .pipe(gulp.dest(`${outDir}/addons/${addon}`)) - ) - - return tscAddon; - }); - - // Copy all addons from ${srcDir}/ to ${outDir}/ - let copyAddons = gulp.src([ - `${srcDir}/addons/**/**` - ]).pipe(gulp.dest(`${outDir}/addons`)); - - // Copy stylesheets from ${srcDir}/ to ${outDir}/ - let copyStylesheets = gulp.src(`${srcDir}/**/*.css`).pipe(gulp.dest(outDir)); - - // Join all streams into a single array - let streams = [tsc].concat(addonStreams).concat([copyAddons, copyStylesheets]); - - return merge.apply(this, streams); -}); - /** * Bundle JavaScript files produced by the `tsc` task, into a single file named `xterm.js` with * Browserify. */ -gulp.task('browserify', ['tsc'], function() { +gulp.task('browserify', [], function() { // Ensure that the build directory exists fs.ensureDirSync(buildDir); @@ -108,7 +60,7 @@ gulp.task('browserify', ['tsc'], function() { return merge(bundleStream, copyStylesheets); }); -gulp.task('browserify-addons', ['tsc'], function() { +gulp.task('browserify-addons', [], function() { const bundles = addons.map((addon) => { const addonOptions = { basedir: `${buildDir}/addons/${addon}`, @@ -192,8 +144,8 @@ gulp.task('webpack', ['build'], function() { .pipe(gulp.dest('demo/dist/')); }); -gulp.task('watch', ['webpack'], () => { - gulp.watch(['./src/*', './src/**/*'], ['webpack']); +gulp.task('watch-demo', ['webpack'], () => { + gulp.watch(['./lib/*', './lib/**/*'], ['webpack']); }); /** diff --git a/package.json b/package.json index 44cc2e88d..e1acafa51 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,9 @@ "@types/jsdom": "^11.0.1", "@types/mocha": "^2.2.33", "@types/node": "6.0.108", - "@types/text-encoding": "0.0.32", "browserify": "^13.3.0", "chai": "3.5.0", + "concurrently": "^3.5.1", "express": "4.13.4", "express-ws": "2.0.0-rc.1", "fs-extra": "^1.0.0", @@ -36,7 +36,7 @@ "sorcery": "^0.10.0", "tslint": "^5.9.1", "tslint-consistent-codestyle": "^1.13.0", - "typescript": "~2.7.1", + "typescript": "2.8.3", "vinyl-buffer": "^1.0.0", "vinyl-source-stream": "^1.1.0", "webpack": "^3.10.0", @@ -51,10 +51,11 @@ "mocha": "gulp test", "build:docs": "jsdoc -c jsdoc.json", "tsc": "tsc", + "prebuild": "concurrently --names 'lib,attach,fit,fullscreen,search,terminado,webLinks,winptyCompat,zmodem' 'tsc' 'tsc -p ./src/addons/attach' 'tsc -p ./src/addons/fit' 'tsc -p ./src/addons/fullscreen' 'tsc -p ./src/addons/search' 'tsc -p ./src/addons/terminado' 'tsc -p ./src/addons/webLinks' 'tsc -p ./src/addons/winptyCompat' 'tsc -p ./src/addons/zmodem'", "build": "gulp build", "prepublish": "npm run build", "coveralls": "gulp coveralls", "webpack": "gulp webpack", - "watch": "gulp watch" + "watch": "concurrently --names 'lib,attach,fit,fullscreen,search,terminado,webLinks,winptyCompat,zmodem,demo' 'tsc -w' 'tsc -w -p ./src/addons/attach' 'tsc -w -p ./src/addons/fit' 'tsc -w -p ./src/addons/fullscreen' 'tsc -w -p ./src/addons/search' 'tsc -w -p ./src/addons/terminado' 'tsc -w -p ./src/addons/webLinks' 'tsc -w -p ./src/addons/winptyCompat' 'tsc -w -p ./src/addons/zmodem' 'gulp watch-demo'" } } diff --git a/src/addons/attach/tsconfig.json b/src/addons/attach/tsconfig.json index a4e8e78b3..3773f5086 100644 --- a/src/addons/attach/tsconfig.json +++ b/src/addons/attach/tsconfig.json @@ -6,6 +6,7 @@ "outDir": "../../../lib/addons/attach/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true } } diff --git a/src/addons/fit/tsconfig.json b/src/addons/fit/tsconfig.json index 78b3c4109..7a5b64511 100644 --- a/src/addons/fit/tsconfig.json +++ b/src/addons/fit/tsconfig.json @@ -6,6 +6,7 @@ "outDir": "../../../lib/addons/fit/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true } } diff --git a/src/addons/fullscreen/tsconfig.json b/src/addons/fullscreen/tsconfig.json index 35ecb7cef..917ce152d 100644 --- a/src/addons/fullscreen/tsconfig.json +++ b/src/addons/fullscreen/tsconfig.json @@ -6,6 +6,7 @@ "outDir": "../../../lib/addons/fullscreen/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true } } diff --git a/src/addons/search/tsconfig.json b/src/addons/search/tsconfig.json index d1c3d7e02..a60c85885 100644 --- a/src/addons/search/tsconfig.json +++ b/src/addons/search/tsconfig.json @@ -6,6 +6,7 @@ "outDir": "../../../lib/addons/search/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true } } diff --git a/src/addons/terminado/tsconfig.json b/src/addons/terminado/tsconfig.json index 84e3ac32d..c716e0538 100644 --- a/src/addons/terminado/tsconfig.json +++ b/src/addons/terminado/tsconfig.json @@ -6,6 +6,7 @@ "outDir": "../../../lib/addons/terminado/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true } } diff --git a/src/addons/webLinks/tsconfig.json b/src/addons/webLinks/tsconfig.json index 7549370b3..bdbafaf60 100644 --- a/src/addons/webLinks/tsconfig.json +++ b/src/addons/webLinks/tsconfig.json @@ -6,6 +6,7 @@ "outDir": "../../../lib/addons/webLinks/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true } } diff --git a/src/addons/winptyCompat/tsconfig.json b/src/addons/winptyCompat/tsconfig.json index a51f73322..3249a6c1b 100644 --- a/src/addons/winptyCompat/tsconfig.json +++ b/src/addons/winptyCompat/tsconfig.json @@ -6,6 +6,7 @@ "outDir": "../../../lib/addons/winptyCompat/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true } } diff --git a/src/addons/zmodem/tsconfig.json b/src/addons/zmodem/tsconfig.json index abae12381..a4b2d3a11 100644 --- a/src/addons/zmodem/tsconfig.json +++ b/src/addons/zmodem/tsconfig.json @@ -6,6 +6,7 @@ "outDir": "../../../lib/addons/zmodem/", "sourceMap": true, "removeComments": true, - "declaration": true + "declaration": true, + "preserveWatchOutput": true } } diff --git a/tsconfig.json b/tsconfig.json index e56930e63..c2a21628f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,7 +12,8 @@ "outDir": "lib", "sourceMap": true, "removeComments": true, - "noUnusedLocals": true + "noUnusedLocals": true, + "preserveWatchOutput": true }, "include": [ "src/**/*"