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="../../node_modules/typescript/lib/typescript.d.ts" />
|
||||
|
||||
import fs = require('fs');
|
||||
import fse = require('fs-extra');
|
||||
|
@ -38,12 +37,18 @@ class DiffingTSCompiler implements DiffingBroccoliPlugin {
|
|||
static excludeExtensions = ['.d.ts'];
|
||||
|
||||
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.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.fileRegistry, this.inputPath);
|
||||
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
|
||||
var es6Tree = compileWithTypescript(modulesTree, {
|
||||
allowNonTsExtensions: false,
|
||||
declaration: false,
|
||||
emitDecoratorMetadata: true,
|
||||
experimentalDecorators: true,
|
||||
mapRoot: '', // force sourcemaps to use relative path
|
||||
noEmitOnError: false,
|
||||
rootDir: '.',
|
||||
rootFilePaths: ['angular2/manual_typings/globals-es6.d.ts'],
|
||||
sourceMap: true,
|
||||
sourceRoot: '.',
|
||||
target: 'ES6'
|
||||
target: 'es6'
|
||||
});
|
||||
|
||||
// Use TypeScript to transpile the *.ts files to ES5
|
||||
var typescriptOptions = {
|
||||
allowNonTsExtensions: false,
|
||||
declaration: true,
|
||||
stripInternal: true,
|
||||
emitDecoratorMetadata: true,
|
||||
experimentalDecorators: true,
|
||||
mapRoot: '', // force sourcemaps to use relative path
|
||||
module: 'CommonJS',
|
||||
moduleResolution: 1 /* classic */,
|
||||
module: 'commonjs',
|
||||
moduleResolution: 'classic',
|
||||
noEmitOnError: true,
|
||||
rootDir: '.',
|
||||
rootFilePaths: ['angular2/manual_typings/globals.d.ts'],
|
||||
sourceMap: true,
|
||||
sourceRoot: '.',
|
||||
target: 'ES5'
|
||||
target: 'es5'
|
||||
};
|
||||
var es5Tree = compileWithTypescript(es5ModulesTree, typescriptOptions);
|
||||
|
||||
|
|
|
@ -33,21 +33,20 @@ module.exports = function makeNodeTree(destinationPath) {
|
|||
});
|
||||
|
||||
var typescriptTree = compileWithTypescript(modulesTree, {
|
||||
allowNonTsExtensions: false,
|
||||
emitDecoratorMetadata: true,
|
||||
experimentalDecorators: true,
|
||||
declaration: true,
|
||||
stripInternal: true,
|
||||
mapRoot: '', /* force sourcemaps to use relative path */
|
||||
module: 'CommonJS',
|
||||
moduleResolution: 1 /* classic */,
|
||||
module: 'commonjs',
|
||||
moduleResolution: 'classic',
|
||||
noEmitOnError: true,
|
||||
rootDir: '.',
|
||||
rootFilePaths:
|
||||
['angular2/manual_typings/globals.d.ts', 'angular2/typings/es6-shim/es6-shim.d.ts'],
|
||||
sourceMap: true,
|
||||
sourceRoot: '.',
|
||||
target: 'ES5'
|
||||
target: 'es5'
|
||||
});
|
||||
|
||||
// Now we add the LICENSE file into all the folders that will become npm packages
|
||||
|
|
Loading…
Reference in New Issue