build(broccoli): make broccoli-typescript consume tsconfig style option
Previously it supported a weird mixture of tsconfig and internal options.
This commit is contained in:
parent
e4e74ae65c
commit
b09788993d
|
@ -1,5 +1,4 @@
|
||||||
/// <reference path="../typings/node/node.d.ts" />
|
/// <reference path="../typings/node/node.d.ts" />
|
||||||
/// <reference path="../../node_modules/typescript/lib/typescript.d.ts" />
|
|
||||||
|
|
||||||
import fs = require('fs');
|
import fs = require('fs');
|
||||||
import fse = require('fs-extra');
|
import fse = require('fs-extra');
|
||||||
|
@ -38,12 +37,18 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
|
||||||
static excludeExtensions = ['.d.ts'];
|
static excludeExtensions = ['.d.ts'];
|
||||||
|
|
||||||
constructor(public inputPath: string, public cachePath: string, public options) {
|
constructor(public inputPath: string, public cachePath: string, public options) {
|
||||||
this.tsOpts = Object.create(options);
|
if (options.rootFilePaths) {
|
||||||
|
this.rootFilePaths = options.rootFilePaths.splice(0);
|
||||||
|
delete options.rootFilePaths;
|
||||||
|
} else {
|
||||||
|
this.rootFilePaths = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// in tsc 1.7.x this api was renamed to parseJsonConfigFileContent
|
||||||
|
// the conversion is a bit awkward, see https://github.com/Microsoft/TypeScript/issues/5276
|
||||||
|
this.tsOpts = ts.parseConfigFile({compilerOptions: options, files: []}, null, null).options;
|
||||||
this.tsOpts.outDir = this.cachePath;
|
this.tsOpts.outDir = this.cachePath;
|
||||||
this.tsOpts.target = (<any>ts).ScriptTarget[options.target];
|
|
||||||
this.tsOpts.module = (<any>ts).ModuleKind[options.module];
|
|
||||||
this.tsOpts.experimentalDecorators = true;
|
|
||||||
this.rootFilePaths = options.rootFilePaths ? options.rootFilePaths.splice(0) : [];
|
|
||||||
this.tsServiceHost = new CustomLanguageServiceHost(this.tsOpts, this.rootFilePaths,
|
this.tsServiceHost = new CustomLanguageServiceHost(this.tsOpts, this.rootFilePaths,
|
||||||
this.fileRegistry, this.inputPath);
|
this.fileRegistry, this.inputPath);
|
||||||
this.tsService = ts.createLanguageService(this.tsServiceHost, ts.createDocumentRegistry());
|
this.tsService = ts.createLanguageService(this.tsServiceHost, ts.createDocumentRegistry());
|
||||||
|
|
|
@ -112,34 +112,33 @@ module.exports = function makeBrowserTree(options, destinationPath) {
|
||||||
|
|
||||||
// Use TypeScript to transpile the *.ts files to ES6
|
// Use TypeScript to transpile the *.ts files to ES6
|
||||||
var es6Tree = compileWithTypescript(modulesTree, {
|
var es6Tree = compileWithTypescript(modulesTree, {
|
||||||
allowNonTsExtensions: false,
|
|
||||||
declaration: false,
|
declaration: false,
|
||||||
emitDecoratorMetadata: true,
|
emitDecoratorMetadata: true,
|
||||||
|
experimentalDecorators: true,
|
||||||
mapRoot: '', // force sourcemaps to use relative path
|
mapRoot: '', // force sourcemaps to use relative path
|
||||||
noEmitOnError: false,
|
noEmitOnError: false,
|
||||||
rootDir: '.',
|
rootDir: '.',
|
||||||
rootFilePaths: ['angular2/manual_typings/globals-es6.d.ts'],
|
rootFilePaths: ['angular2/manual_typings/globals-es6.d.ts'],
|
||||||
sourceMap: true,
|
sourceMap: true,
|
||||||
sourceRoot: '.',
|
sourceRoot: '.',
|
||||||
target: 'ES6'
|
target: 'es6'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Use TypeScript to transpile the *.ts files to ES5
|
// Use TypeScript to transpile the *.ts files to ES5
|
||||||
var typescriptOptions = {
|
var typescriptOptions = {
|
||||||
allowNonTsExtensions: false,
|
|
||||||
declaration: true,
|
declaration: true,
|
||||||
stripInternal: true,
|
stripInternal: true,
|
||||||
emitDecoratorMetadata: true,
|
emitDecoratorMetadata: true,
|
||||||
experimentalDecorators: true,
|
experimentalDecorators: true,
|
||||||
mapRoot: '', // force sourcemaps to use relative path
|
mapRoot: '', // force sourcemaps to use relative path
|
||||||
module: 'CommonJS',
|
module: 'commonjs',
|
||||||
moduleResolution: 1 /* classic */,
|
moduleResolution: 'classic',
|
||||||
noEmitOnError: true,
|
noEmitOnError: true,
|
||||||
rootDir: '.',
|
rootDir: '.',
|
||||||
rootFilePaths: ['angular2/manual_typings/globals.d.ts'],
|
rootFilePaths: ['angular2/manual_typings/globals.d.ts'],
|
||||||
sourceMap: true,
|
sourceMap: true,
|
||||||
sourceRoot: '.',
|
sourceRoot: '.',
|
||||||
target: 'ES5'
|
target: 'es5'
|
||||||
};
|
};
|
||||||
var es5Tree = compileWithTypescript(es5ModulesTree, typescriptOptions);
|
var es5Tree = compileWithTypescript(es5ModulesTree, typescriptOptions);
|
||||||
|
|
||||||
|
|
|
@ -33,21 +33,20 @@ module.exports = function makeNodeTree(destinationPath) {
|
||||||
});
|
});
|
||||||
|
|
||||||
var typescriptTree = compileWithTypescript(modulesTree, {
|
var typescriptTree = compileWithTypescript(modulesTree, {
|
||||||
allowNonTsExtensions: false,
|
|
||||||
emitDecoratorMetadata: true,
|
emitDecoratorMetadata: true,
|
||||||
experimentalDecorators: true,
|
experimentalDecorators: true,
|
||||||
declaration: true,
|
declaration: true,
|
||||||
stripInternal: true,
|
stripInternal: true,
|
||||||
mapRoot: '', /* force sourcemaps to use relative path */
|
mapRoot: '', /* force sourcemaps to use relative path */
|
||||||
module: 'CommonJS',
|
module: 'commonjs',
|
||||||
moduleResolution: 1 /* classic */,
|
moduleResolution: 'classic',
|
||||||
noEmitOnError: true,
|
noEmitOnError: true,
|
||||||
rootDir: '.',
|
rootDir: '.',
|
||||||
rootFilePaths:
|
rootFilePaths:
|
||||||
['angular2/manual_typings/globals.d.ts', 'angular2/typings/es6-shim/es6-shim.d.ts'],
|
['angular2/manual_typings/globals.d.ts', 'angular2/typings/es6-shim/es6-shim.d.ts'],
|
||||||
sourceMap: true,
|
sourceMap: true,
|
||||||
sourceRoot: '.',
|
sourceRoot: '.',
|
||||||
target: 'ES5'
|
target: 'es5'
|
||||||
});
|
});
|
||||||
|
|
||||||
// Now we add the LICENSE file into all the folders that will become npm packages
|
// Now we add the LICENSE file into all the folders that will become npm packages
|
||||||
|
|
Loading…
Reference in New Issue