From 4a4261e141c23ad3a14fe5869498dcde2640db6b Mon Sep 17 00:00:00 2001 From: Paul Gschwendtner Date: Mon, 30 Jan 2017 21:08:59 +0100 Subject: [PATCH] build: use typescript cli for compilation (#2802) --- package.json | 1 - src/demo-app/tsconfig.json | 9 ++++++--- tools/gulp/task_helpers.ts | 32 +++----------------------------- tools/gulp/tasks/components.ts | 2 +- 4 files changed, 10 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index a1f88577415..d4b085ad4d7 100644 --- a/package.json +++ b/package.json @@ -72,7 +72,6 @@ "gulp-sass": "^3.1.0", "gulp-sourcemaps": "^2.4.0", "gulp-transform": "^1.1.0", - "gulp-typescript": "^3.1.4", "hammerjs": "^2.0.8", "highlight.js": "^9.9.0", "jasmine-core": "^2.5.2", diff --git a/src/demo-app/tsconfig.json b/src/demo-app/tsconfig.json index 7d14befdc59..21b70e287a2 100644 --- a/src/demo-app/tsconfig.json +++ b/src/demo-app/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "declaration": true, + "declaration": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "lib": ["es6", "es2015", "dom"], @@ -22,8 +22,11 @@ ] } }, - "exclude": [ - "*-aot.ts" + "files": [ + "./demo-app-types.d.ts", + "./demo-app-module.ts", + "./system-config.ts", + "./main.ts" ], "angularCompilerOptions": { "genDir": "../../dist", diff --git a/tools/gulp/task_helpers.ts b/tools/gulp/task_helpers.ts index 5fcaeada180..ffeffc59af1 100644 --- a/tools/gulp/task_helpers.ts +++ b/tools/gulp/task_helpers.ts @@ -1,7 +1,6 @@ import * as child_process from 'child_process'; import * as fs from 'fs'; import * as gulp from 'gulp'; -import * as gulpTs from 'gulp-typescript'; import * as path from 'path'; import {NPM_VENDOR_FILES, PROJECT_ROOT, DIST_ROOT, SASS_AUTOPREFIXER_OPTIONS} from './constants'; @@ -34,34 +33,9 @@ function _globify(maybeGlob: string, suffix = '**/*') { } -/** Create a TS Build Task, based on the options. */ -export function tsBuildTask(tsConfigPath: string, tsConfigName = 'tsconfig.json') { - let tsConfigDir = tsConfigPath; - if (fs.existsSync(path.join(tsConfigDir, tsConfigName))) { - // Append tsconfig.json - tsConfigPath = path.join(tsConfigDir, tsConfigName); - } else { - tsConfigDir = path.dirname(tsConfigDir); - } - - return () => { - const tsConfig: any = JSON.parse(fs.readFileSync(tsConfigPath, 'utf-8')); - const dest: string = path.join(tsConfigDir, tsConfig['compilerOptions']['outDir']); - - const tsProject = gulpTs.createProject(tsConfigPath); - - let pipe = tsProject.src() - .pipe(gulpSourcemaps.init()) - .pipe(tsProject()); - let dts = pipe.dts.pipe(gulp.dest(dest)); - - return gulpMerge([ - dts, - pipe - .pipe(gulpSourcemaps.write('.')) - .pipe(gulp.dest(dest)) - ]); - }; +/** Creates a task that runs the TypeScript compiler */ +export function tsBuildTask(tsConfigPath: string) { + return execNodeTask('typescript', 'tsc', ['-p', tsConfigPath]); } diff --git a/tools/gulp/tasks/components.ts b/tools/gulp/tasks/components.ts index 44c41d74326..bf00567ebef 100644 --- a/tools/gulp/tasks/components.ts +++ b/tools/gulp/tasks/components.ts @@ -37,7 +37,7 @@ task(':watch:components', () => { /** Builds component typescript only (ESM output). */ -task(':build:components:ts', tsBuildTask(COMPONENTS_DIR, 'tsconfig-srcs.json')); +task(':build:components:ts', tsBuildTask(path.join(COMPONENTS_DIR, 'tsconfig-srcs.json'))); /** Builds components typescript for tests (CJS output). */ task(':build:components:spec', tsBuildTask(COMPONENTS_DIR));