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:
parent
632669f069
commit
c456b73302
|
@ -65,7 +65,7 @@ const SUPPORTED_FORMATS: EntryPointFormat[] = ['esm5', 'esm2015'];
|
||||||
export function mainNgcc(
|
export function mainNgcc(
|
||||||
{basePath, targetEntryPointPath, propertiesToConsider = SUPPORTED_FORMAT_PROPERTIES,
|
{basePath, targetEntryPointPath, propertiesToConsider = SUPPORTED_FORMAT_PROPERTIES,
|
||||||
compileAllFormats = true, createNewEntryPointFormats = false}: NgccOptions): void {
|
compileAllFormats = true, createNewEntryPointFormats = false}: NgccOptions): void {
|
||||||
const transformer = new Transformer(basePath, basePath);
|
const transformer = new Transformer(basePath);
|
||||||
const host = new DependencyHost();
|
const host = new DependencyHost();
|
||||||
const resolver = new DependencyResolver(host);
|
const resolver = new DependencyResolver(host);
|
||||||
const finder = new EntryPointFinder(resolver);
|
const finder = new EntryPointFinder(resolver);
|
||||||
|
|
|
@ -45,7 +45,7 @@ import {EntryPointBundle} from './entry_point_bundle';
|
||||||
* - Some formats may contain multiple "modules" in a single file.
|
* - Some formats may contain multiple "modules" in a single file.
|
||||||
*/
|
*/
|
||||||
export class Transformer {
|
export class Transformer {
|
||||||
constructor(private sourcePath: string, private targetPath: string) {}
|
constructor(private sourcePath: string) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transform the source (and typings) files of a bundle.
|
* Transform the source (and typings) files of a bundle.
|
||||||
|
@ -84,9 +84,9 @@ export class Transformer {
|
||||||
getRenderer(host: NgccReflectionHost, isCore: boolean, bundle: EntryPointBundle): Renderer {
|
getRenderer(host: NgccReflectionHost, isCore: boolean, bundle: EntryPointBundle): Renderer {
|
||||||
switch (bundle.format) {
|
switch (bundle.format) {
|
||||||
case 'esm2015':
|
case 'esm2015':
|
||||||
return new EsmRenderer(host, isCore, bundle, this.sourcePath, this.targetPath);
|
return new EsmRenderer(host, isCore, bundle, this.sourcePath);
|
||||||
case 'esm5':
|
case 'esm5':
|
||||||
return new Esm5Renderer(host, isCore, bundle, this.sourcePath, this.targetPath);
|
return new Esm5Renderer(host, isCore, bundle, this.sourcePath);
|
||||||
default:
|
default:
|
||||||
throw new Error(`Renderer for "${bundle.format}" not yet implemented.`);
|
throw new Error(`Renderer for "${bundle.format}" not yet implemented.`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,8 @@ import {EntryPointBundle} from '../packages/entry_point_bundle';
|
||||||
|
|
||||||
export class Esm5Renderer extends EsmRenderer {
|
export class Esm5Renderer extends EsmRenderer {
|
||||||
constructor(
|
constructor(
|
||||||
host: NgccReflectionHost, isCore: boolean, bundle: EntryPointBundle, sourcePath: string,
|
host: NgccReflectionHost, isCore: boolean, bundle: EntryPointBundle, sourcePath: string) {
|
||||||
targetPath: string) {
|
super(host, isCore, bundle, sourcePath);
|
||||||
super(host, isCore, bundle, sourcePath, targetPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,9 +17,8 @@ import {isDtsPath} from '../../../src/ngtsc/util/src/typescript';
|
||||||
|
|
||||||
export class EsmRenderer extends Renderer {
|
export class EsmRenderer extends Renderer {
|
||||||
constructor(
|
constructor(
|
||||||
host: NgccReflectionHost, isCore: boolean, bundle: EntryPointBundle, sourcePath: string,
|
host: NgccReflectionHost, isCore: boolean, bundle: EntryPointBundle, sourcePath: string) {
|
||||||
targetPath: string) {
|
super(host, isCore, bundle, sourcePath);
|
||||||
super(host, isCore, bundle, sourcePath, targetPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -81,8 +81,7 @@ export const RedundantDecoratorMap = Map;
|
||||||
export abstract class Renderer {
|
export abstract class Renderer {
|
||||||
constructor(
|
constructor(
|
||||||
protected host: NgccReflectionHost, protected isCore: boolean,
|
protected host: NgccReflectionHost, protected isCore: boolean,
|
||||||
protected bundle: EntryPointBundle, protected sourcePath: string,
|
protected bundle: EntryPointBundle, protected sourcePath: string) {}
|
||||||
protected targetPath: string) {}
|
|
||||||
|
|
||||||
renderProgram(
|
renderProgram(
|
||||||
decorationAnalyses: DecorationAnalyses, switchMarkerAnalyses: SwitchMarkerAnalyses,
|
decorationAnalyses: DecorationAnalyses, switchMarkerAnalyses: SwitchMarkerAnalyses,
|
||||||
|
@ -333,7 +332,7 @@ export abstract class Renderer {
|
||||||
const outputPath = resolve(this.targetPath, relative(this.sourcePath, sourceFile.fileName));
|
const outputPath = resolve(this.targetPath, relative(this.sourcePath, sourceFile.fileName));
|
||||||
const outputMapPath = `${outputPath}.map`;
|
const outputMapPath = `${outputPath}.map`;
|
||||||
const outputMap = output.generateMap({
|
const outputMap = output.generateMap({
|
||||||
source: sourceFile.fileName,
|
source: outputPath,
|
||||||
includeContent: true,
|
includeContent: true,
|
||||||
// hires: true // TODO: This results in accurate but huge sourcemaps. Instead we should fix
|
// hires: true // TODO: This results in accurate but huge sourcemaps. Instead we should fix
|
||||||
// the merge algorithm.
|
// the merge algorithm.
|
||||||
|
|
|
@ -28,7 +28,7 @@ function setup(file: {name: string, contents: string}) {
|
||||||
referencesRegistry, [AbsoluteFsPath.fromUnchecked('/')], false)
|
referencesRegistry, [AbsoluteFsPath.fromUnchecked('/')], false)
|
||||||
.analyzeProgram();
|
.analyzeProgram();
|
||||||
const switchMarkerAnalyses = new SwitchMarkerAnalyzer(host).analyzeProgram(bundle.src.program);
|
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 {
|
return {
|
||||||
host,
|
host,
|
||||||
program: bundle.src.program,
|
program: bundle.src.program,
|
||||||
|
|
|
@ -28,7 +28,7 @@ function setup(file: {name: string, contents: string}) {
|
||||||
referencesRegistry, [AbsoluteFsPath.fromUnchecked('/')], false)
|
referencesRegistry, [AbsoluteFsPath.fromUnchecked('/')], false)
|
||||||
.analyzeProgram();
|
.analyzeProgram();
|
||||||
const switchMarkerAnalyses = new SwitchMarkerAnalyzer(host).analyzeProgram(bundle.src.program);
|
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 {
|
return {
|
||||||
host,
|
host,
|
||||||
program: bundle.src.program,
|
program: bundle.src.program,
|
||||||
|
|
|
@ -21,7 +21,7 @@ import {makeTestEntryPointBundle} from '../helpers/utils';
|
||||||
|
|
||||||
class TestRenderer extends Renderer {
|
class TestRenderer extends Renderer {
|
||||||
constructor(host: Esm2015ReflectionHost, isCore: boolean, bundle: EntryPointBundle) {
|
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}[]) {
|
addImports(output: MagicString, imports: {specifier: string, qualifier: string}[]) {
|
||||||
output.prepend('\n// ADD IMPORTS\n');
|
output.prepend('\n// ADD IMPORTS\n');
|
||||||
|
|
Loading…
Reference in New Issue