fix(tsc-wrapped): emit js files in all cases
This commit is contained in:

committed by
Chuck Jazdzewski

parent
73a46205a0
commit
c0e05e6f03
@ -56,7 +56,10 @@ const DTS = /\.d\.ts$/;
|
||||
export class MetadataWriterHost extends DelegatingHost {
|
||||
private metadataCollector = new MetadataCollector({quotedNames: true});
|
||||
private metadataCollector1 = new MetadataCollector({version: 1});
|
||||
constructor(delegate: ts.CompilerHost, private ngOptions: NgOptions) { super(delegate); }
|
||||
constructor(
|
||||
delegate: ts.CompilerHost, private ngOptions: NgOptions, private emitAllFiles: boolean) {
|
||||
super(delegate);
|
||||
}
|
||||
|
||||
private writeMetadata(emitFilePath: string, sourceFile: ts.SourceFile) {
|
||||
// TODO: replace with DTS filePath when https://github.com/Microsoft/TypeScript/pull/8412 is
|
||||
@ -87,10 +90,12 @@ export class MetadataWriterHost extends DelegatingHost {
|
||||
writeFile: ts.WriteFileCallback =
|
||||
(fileName: string, data: string, writeByteOrderMark: boolean,
|
||||
onError?: (message: string) => void, sourceFiles?: ts.SourceFile[]) => {
|
||||
if (/\.d\.ts$/.test(fileName)) {
|
||||
const isDts = /\.d\.ts$/.test(fileName);
|
||||
if (this.emitAllFiles || isDts) {
|
||||
// Let the original file be written first; this takes care of creating parent directories
|
||||
this.delegate.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles);
|
||||
|
||||
}
|
||||
if (isDts) {
|
||||
// TODO: remove this early return after https://github.com/Microsoft/TypeScript/pull/8412
|
||||
// is
|
||||
// released
|
||||
|
@ -117,7 +117,11 @@ export function main(
|
||||
if (diagnostics) console.timeEnd('NG codegen');
|
||||
let definitionsHost: ts.CompilerHost = tsickleCompilerHost;
|
||||
if (!ngOptions.skipMetadataEmit) {
|
||||
definitionsHost = new MetadataWriterHost(tsickleCompilerHost, ngOptions);
|
||||
// if tsickle is not not used for emitting, but we do use the MetadataWriterHost,
|
||||
// it also needs to emit the js files.
|
||||
const emitJsFiles =
|
||||
ngOptions.annotationsAs === 'decorators' && !ngOptions.annotateForClosureCompiler;
|
||||
definitionsHost = new MetadataWriterHost(tsickleCompilerHost, ngOptions, emitJsFiles);
|
||||
}
|
||||
// Create a new program since codegen files were created after making the old program
|
||||
let programWithCodegen = createProgram(definitionsHost, program);
|
||||
|
Reference in New Issue
Block a user