mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
build: use typescript cli for compilation (#2802)
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user