refactor(ivy): ngcc - remove the `targetPath` properties of Transformer and Renderer (#29556)

We have already removed this concept from the public API. This just cleans it out altogether.

The `targetPath` was an alternative output path to the original `basePath`.
This is not really a very useful concept, since the actual target path
of each output file is more complex and not consistently relative to the `basePath`.

PR Close #29556
This commit is contained in:
Pete Bacon Darwin 2019-03-27 16:48:20 +00:00 committed by Jason Aden
parent 632669f069
commit c456b73302
8 changed files with 13 additions and 16 deletions

View File

@ -65,7 +65,7 @@ const SUPPORTED_FORMATS: EntryPointFormat[] = ['esm5', 'esm2015'];
export function mainNgcc(
{basePath, targetEntryPointPath, propertiesToConsider = SUPPORTED_FORMAT_PROPERTIES,
compileAllFormats = true, createNewEntryPointFormats = false}: NgccOptions): void {
const transformer = new Transformer(basePath, basePath);
const transformer = new Transformer(basePath);
const host = new DependencyHost();
const resolver = new DependencyResolver(host);
const finder = new EntryPointFinder(resolver);

View File

@ -45,7 +45,7 @@ import {EntryPointBundle} from './entry_point_bundle';
* - Some formats may contain multiple "modules" in a single file.
*/
export class Transformer {
constructor(private sourcePath: string, private targetPath: string) {}
constructor(private sourcePath: string) {}
/**
* Transform the source (and typings) files of a bundle.
@ -84,9 +84,9 @@ export class Transformer {
getRenderer(host: NgccReflectionHost, isCore: boolean, bundle: EntryPointBundle): Renderer {
switch (bundle.format) {
case 'esm2015':
return new EsmRenderer(host, isCore, bundle, this.sourcePath, this.targetPath);
return new EsmRenderer(host, isCore, bundle, this.sourcePath);
case 'esm5':
return new Esm5Renderer(host, isCore, bundle, this.sourcePath, this.targetPath);
return new Esm5Renderer(host, isCore, bundle, this.sourcePath);
default:
throw new Error(`Renderer for "${bundle.format}" not yet implemented.`);
}

View File

@ -15,9 +15,8 @@ import {EntryPointBundle} from '../packages/entry_point_bundle';
export class Esm5Renderer extends EsmRenderer {
constructor(
host: NgccReflectionHost, isCore: boolean, bundle: EntryPointBundle, sourcePath: string,
targetPath: string) {
super(host, isCore, bundle, sourcePath, targetPath);
host: NgccReflectionHost, isCore: boolean, bundle: EntryPointBundle, sourcePath: string) {
super(host, isCore, bundle, sourcePath);
}
/**

View File

@ -17,9 +17,8 @@ import {isDtsPath} from '../../../src/ngtsc/util/src/typescript';
export class EsmRenderer extends Renderer {
constructor(
host: NgccReflectionHost, isCore: boolean, bundle: EntryPointBundle, sourcePath: string,
targetPath: string) {
super(host, isCore, bundle, sourcePath, targetPath);
host: NgccReflectionHost, isCore: boolean, bundle: EntryPointBundle, sourcePath: string) {
super(host, isCore, bundle, sourcePath);
}
/**

View File

@ -81,8 +81,7 @@ export const RedundantDecoratorMap = Map;
export abstract class Renderer {
constructor(
protected host: NgccReflectionHost, protected isCore: boolean,
protected bundle: EntryPointBundle, protected sourcePath: string,
protected targetPath: string) {}
protected bundle: EntryPointBundle, protected sourcePath: string) {}
renderProgram(
decorationAnalyses: DecorationAnalyses, switchMarkerAnalyses: SwitchMarkerAnalyses,
@ -333,7 +332,7 @@ export abstract class Renderer {
const outputPath = resolve(this.targetPath, relative(this.sourcePath, sourceFile.fileName));
const outputMapPath = `${outputPath}.map`;
const outputMap = output.generateMap({
source: sourceFile.fileName,
source: outputPath,
includeContent: true,
// hires: true // TODO: This results in accurate but huge sourcemaps. Instead we should fix
// the merge algorithm.

View File

@ -28,7 +28,7 @@ function setup(file: {name: string, contents: string}) {
referencesRegistry, [AbsoluteFsPath.fromUnchecked('/')], false)
.analyzeProgram();
const switchMarkerAnalyses = new SwitchMarkerAnalyzer(host).analyzeProgram(bundle.src.program);
const renderer = new EsmRenderer(host, false, bundle, dir, dir);
const renderer = new EsmRenderer(host, false, bundle, dir);
return {
host,
program: bundle.src.program,

View File

@ -28,7 +28,7 @@ function setup(file: {name: string, contents: string}) {
referencesRegistry, [AbsoluteFsPath.fromUnchecked('/')], false)
.analyzeProgram();
const switchMarkerAnalyses = new SwitchMarkerAnalyzer(host).analyzeProgram(bundle.src.program);
const renderer = new Esm5Renderer(host, false, bundle, dir, dir);
const renderer = new Esm5Renderer(host, false, bundle, dir);
return {
host,
program: bundle.src.program,

View File

@ -21,7 +21,7 @@ import {makeTestEntryPointBundle} from '../helpers/utils';
class TestRenderer extends Renderer {
constructor(host: Esm2015ReflectionHost, isCore: boolean, bundle: EntryPointBundle) {
super(host, isCore, bundle, '/src', '/dist');
super(host, isCore, bundle, '/src');
}
addImports(output: MagicString, imports: {specifier: string, qualifier: string}[]) {
output.prepend('\n// ADD IMPORTS\n');