diff --git a/packages/compiler-cli/src/ngcc/src/packages/transformer.ts b/packages/compiler-cli/src/ngcc/src/packages/transformer.ts index a742f8352b..b799970903 100644 --- a/packages/compiler-cli/src/ngcc/src/packages/transformer.ts +++ b/packages/compiler-cli/src/ngcc/src/packages/transformer.ts @@ -85,8 +85,8 @@ export class Transformer { console.time(entryPoint.name + '(rendering)'); // Transform the source files and source maps. - const renderer = - this.getRenderer(format, packageProgram, reflectionHost, isCore, r3SymbolsFile); + const renderer = this.getRenderer( + format, packageProgram, reflectionHost, isCore, r3SymbolsFile, transformDts); const renderedFiles = renderer.renderProgram(packageProgram, decorationAnalyses, switchMarkerAnalyses); console.timeEnd(entryPoint.name + '(rendering)'); @@ -125,14 +125,14 @@ export class Transformer { getRenderer( format: string, program: ts.Program, host: NgccReflectionHost, isCore: boolean, - rewriteCoreImportsTo: ts.SourceFile|null): Renderer { + rewriteCoreImportsTo: ts.SourceFile|null, transformDts: boolean): Renderer { switch (format) { case 'esm2015': case 'esm5': case 'fesm2015': case 'fesm5': return new EsmRenderer( - host, isCore, rewriteCoreImportsTo, this.sourcePath, this.targetPath); + host, isCore, rewriteCoreImportsTo, this.sourcePath, this.targetPath, transformDts); default: throw new Error(`Renderer for "${format}" not yet implemented.`); } diff --git a/packages/compiler-cli/src/ngcc/src/rendering/esm_renderer.ts b/packages/compiler-cli/src/ngcc/src/rendering/esm_renderer.ts index a0b3394c74..aa59ab1640 100644 --- a/packages/compiler-cli/src/ngcc/src/rendering/esm_renderer.ts +++ b/packages/compiler-cli/src/ngcc/src/rendering/esm_renderer.ts @@ -15,8 +15,8 @@ export class EsmRenderer extends Renderer { constructor( protected host: NgccReflectionHost, protected isCore: boolean, protected rewriteCoreImportsTo: ts.SourceFile|null, protected sourcePath: string, - protected targetPath: string) { - super(host, isCore, rewriteCoreImportsTo, sourcePath, targetPath); + protected targetPath: string, transformDts: boolean) { + super(host, isCore, rewriteCoreImportsTo, sourcePath, targetPath, transformDts); } /** diff --git a/packages/compiler-cli/src/ngcc/src/rendering/renderer.ts b/packages/compiler-cli/src/ngcc/src/rendering/renderer.ts index e20979050f..54f2cacdd1 100644 --- a/packages/compiler-cli/src/ngcc/src/rendering/renderer.ts +++ b/packages/compiler-cli/src/ngcc/src/rendering/renderer.ts @@ -57,7 +57,7 @@ export abstract class Renderer { constructor( protected host: NgccReflectionHost, protected isCore: boolean, protected rewriteCoreImportsTo: ts.SourceFile|null, protected sourcePath: string, - protected targetPath: string) {} + protected targetPath: string, protected transformDts: boolean) {} renderProgram( program: ts.Program, decorationAnalyses: DecorationAnalyses, @@ -74,9 +74,11 @@ export abstract class Renderer { } }); - // Transform the .d.ts files - const dtsFiles = this.getTypingsFilesToRender(decorationAnalyses); - dtsFiles.forEach((classes, file) => renderedFiles.push(...this.renderDtsFile(file, classes))); + if (this.transformDts) { + // Transform the .d.ts files + const dtsFiles = this.getTypingsFilesToRender(decorationAnalyses); + dtsFiles.forEach((classes, file) => renderedFiles.push(...this.renderDtsFile(file, classes))); + } return renderedFiles; } diff --git a/packages/compiler-cli/src/ngcc/test/rendering/esm2015_renderer_spec.ts b/packages/compiler-cli/src/ngcc/test/rendering/esm2015_renderer_spec.ts index f0b07ef6bf..d1ba2c9f68 100644 --- a/packages/compiler-cli/src/ngcc/test/rendering/esm2015_renderer_spec.ts +++ b/packages/compiler-cli/src/ngcc/test/rendering/esm2015_renderer_spec.ts @@ -23,7 +23,7 @@ function setup(file: {name: string, contents: string}, transformDts: boolean = f const decorationAnalyses = new DecorationAnalyzer(program.getTypeChecker(), host, [''], false).analyzeProgram(program); const switchMarkerAnalyses = new SwitchMarkerAnalyzer(host).analyzeProgram(program); - const renderer = new EsmRenderer(host, false, null, dir, dir); + const renderer = new EsmRenderer(host, false, null, dir, dir, false); return {host, program, sourceFile, renderer, decorationAnalyses, switchMarkerAnalyses}; } diff --git a/packages/compiler-cli/src/ngcc/test/rendering/esm5_renderer_spec.ts b/packages/compiler-cli/src/ngcc/test/rendering/esm5_renderer_spec.ts index 88d54d6280..20d7f8a9ec 100644 --- a/packages/compiler-cli/src/ngcc/test/rendering/esm5_renderer_spec.ts +++ b/packages/compiler-cli/src/ngcc/test/rendering/esm5_renderer_spec.ts @@ -20,7 +20,7 @@ function setup(file: {name: string, contents: string}) { const decorationAnalyses = new DecorationAnalyzer(program.getTypeChecker(), host, [''], false).analyzeProgram(program); const switchMarkerAnalyses = new SwitchMarkerAnalyzer(host).analyzeProgram(program); - const renderer = new EsmRenderer(host, false, null, '', ''); + const renderer = new EsmRenderer(host, false, null, '', '', false); return {host, program, sourceFile, renderer, decorationAnalyses, switchMarkerAnalyses}; } diff --git a/packages/compiler-cli/src/ngcc/test/rendering/renderer_spec.ts b/packages/compiler-cli/src/ngcc/test/rendering/renderer_spec.ts index 467acbc128..3b30a01600 100644 --- a/packages/compiler-cli/src/ngcc/test/rendering/renderer_spec.ts +++ b/packages/compiler-cli/src/ngcc/test/rendering/renderer_spec.ts @@ -17,7 +17,7 @@ import {Esm2015ReflectionHost} from '../../src/host/esm2015_host'; import {Renderer} from '../../src/rendering/renderer'; class TestRenderer extends Renderer { - constructor(host: Esm2015ReflectionHost) { super(host, false, null, '/src', '/dist'); } + constructor(host: Esm2015ReflectionHost) { super(host, false, null, '/src', '/dist', false); } addImports(output: MagicString, imports: {name: string, as: string}[]) { output.prepend('\n// ADD IMPORTS\n'); }