build: use typescript cli for compilation (#2802)

This commit is contained in:
Paul Gschwendtner
2017-01-30 21:08:59 +01:00
committed by Kara
parent 3b6cab01c7
commit 4a4261e141
4 changed files with 10 additions and 34 deletions
-1
View File
@@ -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",
+6 -3
View File
@@ -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",
+3 -29
View File
@@ -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]);
}
+1 -1
View File
@@ -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));