refactor(ngcc): rename EntryPoint#package
to EntryPoint#packagePath
(#37040)
Rename the `package` property to `packagePath` on the `EntryPoint` interface. This makes it more clear that the `packagePath` property holds the absolute path to the containing package (similar to how `path` holds the path to the entry-point). This will also align with the `packageName` property that will be added in a subsequent commit. This commit also re-orders the `EntryPoint` properties to group related properties together and to match the order of properties on instances with that on the interface. PR Close #37040
This commit is contained in:

committed by
Misko Hevery

parent
bf57776b59
commit
d471454675
@ -58,7 +58,7 @@ export class DecorationAnalyzer {
|
||||
private host = this.bundle.src.host;
|
||||
private typeChecker = this.bundle.src.program.getTypeChecker();
|
||||
private rootDirs = this.bundle.rootDirs;
|
||||
private packagePath = this.bundle.entryPoint.package;
|
||||
private packagePath = this.bundle.entryPoint.packagePath;
|
||||
private isCore = this.bundle.isCore;
|
||||
private compilerOptions = this.tsConfig !== null ? this.tsConfig.options : {};
|
||||
|
||||
|
@ -225,7 +225,7 @@ export class DependencyResolver {
|
||||
private filterIgnorableDeepImports(entryPoint: EntryPoint, deepImports: Set<AbsoluteFsPath>):
|
||||
AbsoluteFsPath[] {
|
||||
const version = (entryPoint.packageJson.version || null) as string | null;
|
||||
const packageConfig = this.config.getPackageConfig(entryPoint.package, version);
|
||||
const packageConfig = this.config.getPackageConfig(entryPoint.packagePath, version);
|
||||
const matchers = packageConfig.ignorableDeepImportMatchers || [];
|
||||
return Array.from(deepImports)
|
||||
.filter(deepImport => !matchers.some(matcher => matcher.test(deepImport)));
|
||||
|
@ -24,14 +24,14 @@ export type EntryPointFormat = 'esm5'|'esm2015'|'umd'|'commonjs';
|
||||
* to each of the possible entry-point formats.
|
||||
*/
|
||||
export interface EntryPoint extends JsonObject {
|
||||
/** The name of the package (e.g. `@angular/core`). */
|
||||
/** The name of the entry-point (e.g. `@angular/core` or `@angular/common/http`). */
|
||||
name: string;
|
||||
/** The parsed package.json file for this entry-point. */
|
||||
packageJson: EntryPointPackageJson;
|
||||
/** The path to the package that contains this entry-point. */
|
||||
package: AbsoluteFsPath;
|
||||
/** The path to this entry point. */
|
||||
path: AbsoluteFsPath;
|
||||
/** The path to the package that contains this entry-point. */
|
||||
packagePath: AbsoluteFsPath;
|
||||
/** The parsed package.json file for this entry-point. */
|
||||
packageJson: EntryPointPackageJson;
|
||||
/** The path to a typings (.d.ts) file for this entry-point. */
|
||||
typings: AbsoluteFsPath;
|
||||
/** Is this EntryPoint compiled with the Angular View Engine compiler? */
|
||||
@ -166,9 +166,9 @@ export function getEntryPointInfo(
|
||||
|
||||
const entryPointInfo: EntryPoint = {
|
||||
name: entryPointPackageJson.name,
|
||||
packageJson: entryPointPackageJson,
|
||||
package: packagePath,
|
||||
path: entryPointPath,
|
||||
packagePath,
|
||||
packageJson: entryPointPackageJson,
|
||||
typings: resolve(entryPointPath, typings),
|
||||
compiledByAngular,
|
||||
ignoreMissingDependencies:
|
||||
|
@ -47,7 +47,7 @@ export function makeEntryPointBundle(
|
||||
mirrorDtsFromSrc: boolean = false,
|
||||
enableI18nLegacyMessageIdFormat: boolean = true): EntryPointBundle {
|
||||
// Create the TS program and necessary helpers.
|
||||
const rootDir = entryPoint.package;
|
||||
const rootDir = entryPoint.packagePath;
|
||||
const options: ts
|
||||
.CompilerOptions = {allowJs: true, maxNodeModuleJsDepth: Infinity, rootDir, ...pathMappings};
|
||||
const srcHost = new NgccSourcesCompilerHost(fs, options, entryPoint.path);
|
||||
@ -57,12 +57,12 @@ export function makeEntryPointBundle(
|
||||
const absFormatPath = fs.resolve(entryPoint.path, formatPath);
|
||||
const typingsPath = fs.resolve(entryPoint.path, entryPoint.typings);
|
||||
const src = makeBundleProgram(
|
||||
fs, isCore, entryPoint.package, absFormatPath, 'r3_symbols.js', options, srcHost);
|
||||
fs, isCore, entryPoint.packagePath, absFormatPath, 'r3_symbols.js', options, srcHost);
|
||||
const additionalDtsFiles = transformDts && mirrorDtsFromSrc ?
|
||||
computePotentialDtsFilesFromJsFiles(fs, src.program, absFormatPath, typingsPath) :
|
||||
[];
|
||||
const dts = transformDts ? makeBundleProgram(
|
||||
fs, isCore, entryPoint.package, typingsPath, 'r3_symbols.d.ts',
|
||||
fs, isCore, entryPoint.packagePath, typingsPath, 'r3_symbols.d.ts',
|
||||
options, dtsHost, additionalDtsFiles) :
|
||||
null;
|
||||
const isFlatCore = isCore && src.r3SymbolsFile === null;
|
||||
|
@ -126,7 +126,7 @@ export class EntryPointManifest {
|
||||
lockFileHash: lockFileHash,
|
||||
entryPointPaths: entryPoints.map(e => {
|
||||
const entryPointPaths: EntryPointPaths = [
|
||||
this.fs.relative(basePath, e.entryPoint.package),
|
||||
this.fs.relative(basePath, e.entryPoint.packagePath),
|
||||
this.fs.relative(basePath, e.entryPoint.path),
|
||||
];
|
||||
// Only add depInfo arrays if needed.
|
||||
|
@ -148,7 +148,7 @@ export class Transformer {
|
||||
const referencesRegistry = new NgccReferencesRegistry(reflectionHost);
|
||||
|
||||
const switchMarkerAnalyzer =
|
||||
new SwitchMarkerAnalyzer(reflectionHost, bundle.entryPoint.package);
|
||||
new SwitchMarkerAnalyzer(reflectionHost, bundle.entryPoint.packagePath);
|
||||
const switchMarkerAnalyses = switchMarkerAnalyzer.analyzeProgram(bundle.src.program);
|
||||
|
||||
const diagnostics: ts.Diagnostic[] = [];
|
||||
|
@ -63,7 +63,7 @@ export function cleanOutdatedPackages(fileSystem: FileSystem, entryPoints: Entry
|
||||
const packagesToClean = new Set<AbsoluteFsPath>();
|
||||
for (const entryPoint of entryPoints) {
|
||||
if (needsCleaning(entryPoint.packageJson)) {
|
||||
packagesToClean.add(entryPoint.package);
|
||||
packagesToClean.add(entryPoint.packagePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,9 +39,9 @@ export class NewEntryPointFileWriter extends InPlaceFileWriter {
|
||||
formatProperties: EntryPointJsonProperty[]) {
|
||||
// The new folder is at the root of the overall package
|
||||
const entryPoint = bundle.entryPoint;
|
||||
const ngccFolder = join(entryPoint.package, NGCC_DIRECTORY);
|
||||
this.copyBundle(bundle, entryPoint.package, ngccFolder);
|
||||
transformedFiles.forEach(file => this.writeFile(file, entryPoint.package, ngccFolder));
|
||||
const ngccFolder = join(entryPoint.packagePath, NGCC_DIRECTORY);
|
||||
this.copyBundle(bundle, entryPoint.packagePath, ngccFolder);
|
||||
transformedFiles.forEach(file => this.writeFile(file, entryPoint.packagePath, ngccFolder));
|
||||
this.updatePackageJson(entryPoint, formatProperties, ngccFolder);
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ export class NewEntryPointFileWriter extends InPlaceFileWriter {
|
||||
|
||||
// Revert the transformed files.
|
||||
for (const filePath of transformedFilePaths) {
|
||||
this.revertFile(filePath, entryPoint.package);
|
||||
this.revertFile(filePath, entryPoint.packagePath);
|
||||
}
|
||||
|
||||
// Revert any changes to `package.json`.
|
||||
@ -118,7 +118,7 @@ export class NewEntryPointFileWriter extends InPlaceFileWriter {
|
||||
const oldFormatProp = formatProperties[0]!;
|
||||
const oldFormatPath = packageJson[oldFormatProp]!;
|
||||
const oldAbsFormatPath = join(entryPoint.path, oldFormatPath);
|
||||
const newAbsFormatPath = join(ngccFolder, relative(entryPoint.package, oldAbsFormatPath));
|
||||
const newAbsFormatPath = join(ngccFolder, relative(entryPoint.packagePath, oldAbsFormatPath));
|
||||
const newFormatPath = relative(entryPoint.path, newAbsFormatPath);
|
||||
|
||||
// Update all properties in `package.json` (both in memory and on disk).
|
||||
|
Reference in New Issue
Block a user