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:
George Kalpakas 2020-06-08 22:04:28 +03:00 committed by Misko Hevery
parent e7a0e87c41
commit 8197557fcf
23 changed files with 89 additions and 85 deletions

View File

@ -58,7 +58,7 @@ export class DecorationAnalyzer {
private host = this.bundle.src.host; private host = this.bundle.src.host;
private typeChecker = this.bundle.src.program.getTypeChecker(); private typeChecker = this.bundle.src.program.getTypeChecker();
private rootDirs = this.bundle.rootDirs; private rootDirs = this.bundle.rootDirs;
private packagePath = this.bundle.entryPoint.package; private packagePath = this.bundle.entryPoint.packagePath;
private isCore = this.bundle.isCore; private isCore = this.bundle.isCore;
private compilerOptions = this.tsConfig !== null ? this.tsConfig.options : {}; private compilerOptions = this.tsConfig !== null ? this.tsConfig.options : {};

View File

@ -225,7 +225,7 @@ export class DependencyResolver {
private filterIgnorableDeepImports(entryPoint: EntryPoint, deepImports: Set<AbsoluteFsPath>): private filterIgnorableDeepImports(entryPoint: EntryPoint, deepImports: Set<AbsoluteFsPath>):
AbsoluteFsPath[] { AbsoluteFsPath[] {
const version = (entryPoint.packageJson.version || null) as string | null; 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 || []; const matchers = packageConfig.ignorableDeepImportMatchers || [];
return Array.from(deepImports) return Array.from(deepImports)
.filter(deepImport => !matchers.some(matcher => matcher.test(deepImport))); .filter(deepImport => !matchers.some(matcher => matcher.test(deepImport)));

View File

@ -24,14 +24,14 @@ export type EntryPointFormat = 'esm5'|'esm2015'|'umd'|'commonjs';
* to each of the possible entry-point formats. * to each of the possible entry-point formats.
*/ */
export interface EntryPoint extends JsonObject { 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; 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. */ /** The path to this entry point. */
path: AbsoluteFsPath; 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. */ /** The path to a typings (.d.ts) file for this entry-point. */
typings: AbsoluteFsPath; typings: AbsoluteFsPath;
/** Is this EntryPoint compiled with the Angular View Engine compiler? */ /** Is this EntryPoint compiled with the Angular View Engine compiler? */
@ -166,9 +166,9 @@ export function getEntryPointInfo(
const entryPointInfo: EntryPoint = { const entryPointInfo: EntryPoint = {
name: entryPointPackageJson.name, name: entryPointPackageJson.name,
packageJson: entryPointPackageJson,
package: packagePath,
path: entryPointPath, path: entryPointPath,
packagePath,
packageJson: entryPointPackageJson,
typings: resolve(entryPointPath, typings), typings: resolve(entryPointPath, typings),
compiledByAngular, compiledByAngular,
ignoreMissingDependencies: ignoreMissingDependencies:

View File

@ -47,7 +47,7 @@ export function makeEntryPointBundle(
mirrorDtsFromSrc: boolean = false, mirrorDtsFromSrc: boolean = false,
enableI18nLegacyMessageIdFormat: boolean = true): EntryPointBundle { enableI18nLegacyMessageIdFormat: boolean = true): EntryPointBundle {
// Create the TS program and necessary helpers. // Create the TS program and necessary helpers.
const rootDir = entryPoint.package; const rootDir = entryPoint.packagePath;
const options: ts const options: ts
.CompilerOptions = {allowJs: true, maxNodeModuleJsDepth: Infinity, rootDir, ...pathMappings}; .CompilerOptions = {allowJs: true, maxNodeModuleJsDepth: Infinity, rootDir, ...pathMappings};
const srcHost = new NgccSourcesCompilerHost(fs, options, entryPoint.path); const srcHost = new NgccSourcesCompilerHost(fs, options, entryPoint.path);
@ -57,12 +57,12 @@ export function makeEntryPointBundle(
const absFormatPath = fs.resolve(entryPoint.path, formatPath); const absFormatPath = fs.resolve(entryPoint.path, formatPath);
const typingsPath = fs.resolve(entryPoint.path, entryPoint.typings); const typingsPath = fs.resolve(entryPoint.path, entryPoint.typings);
const src = makeBundleProgram( 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 ? const additionalDtsFiles = transformDts && mirrorDtsFromSrc ?
computePotentialDtsFilesFromJsFiles(fs, src.program, absFormatPath, typingsPath) : computePotentialDtsFilesFromJsFiles(fs, src.program, absFormatPath, typingsPath) :
[]; [];
const dts = transformDts ? makeBundleProgram( 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) : options, dtsHost, additionalDtsFiles) :
null; null;
const isFlatCore = isCore && src.r3SymbolsFile === null; const isFlatCore = isCore && src.r3SymbolsFile === null;

View File

@ -126,7 +126,7 @@ export class EntryPointManifest {
lockFileHash: lockFileHash, lockFileHash: lockFileHash,
entryPointPaths: entryPoints.map(e => { entryPointPaths: entryPoints.map(e => {
const entryPointPaths: EntryPointPaths = [ const entryPointPaths: EntryPointPaths = [
this.fs.relative(basePath, e.entryPoint.package), this.fs.relative(basePath, e.entryPoint.packagePath),
this.fs.relative(basePath, e.entryPoint.path), this.fs.relative(basePath, e.entryPoint.path),
]; ];
// Only add depInfo arrays if needed. // Only add depInfo arrays if needed.

View File

@ -148,7 +148,7 @@ export class Transformer {
const referencesRegistry = new NgccReferencesRegistry(reflectionHost); const referencesRegistry = new NgccReferencesRegistry(reflectionHost);
const switchMarkerAnalyzer = const switchMarkerAnalyzer =
new SwitchMarkerAnalyzer(reflectionHost, bundle.entryPoint.package); new SwitchMarkerAnalyzer(reflectionHost, bundle.entryPoint.packagePath);
const switchMarkerAnalyses = switchMarkerAnalyzer.analyzeProgram(bundle.src.program); const switchMarkerAnalyses = switchMarkerAnalyzer.analyzeProgram(bundle.src.program);
const diagnostics: ts.Diagnostic[] = []; const diagnostics: ts.Diagnostic[] = [];

View File

@ -63,7 +63,7 @@ export function cleanOutdatedPackages(fileSystem: FileSystem, entryPoints: Entry
const packagesToClean = new Set<AbsoluteFsPath>(); const packagesToClean = new Set<AbsoluteFsPath>();
for (const entryPoint of entryPoints) { for (const entryPoint of entryPoints) {
if (needsCleaning(entryPoint.packageJson)) { if (needsCleaning(entryPoint.packageJson)) {
packagesToClean.add(entryPoint.package); packagesToClean.add(entryPoint.packagePath);
} }
} }

View File

@ -39,9 +39,9 @@ export class NewEntryPointFileWriter extends InPlaceFileWriter {
formatProperties: EntryPointJsonProperty[]) { formatProperties: EntryPointJsonProperty[]) {
// The new folder is at the root of the overall package // The new folder is at the root of the overall package
const entryPoint = bundle.entryPoint; const entryPoint = bundle.entryPoint;
const ngccFolder = join(entryPoint.package, NGCC_DIRECTORY); const ngccFolder = join(entryPoint.packagePath, NGCC_DIRECTORY);
this.copyBundle(bundle, entryPoint.package, ngccFolder); this.copyBundle(bundle, entryPoint.packagePath, ngccFolder);
transformedFiles.forEach(file => this.writeFile(file, entryPoint.package, ngccFolder)); transformedFiles.forEach(file => this.writeFile(file, entryPoint.packagePath, ngccFolder));
this.updatePackageJson(entryPoint, formatProperties, ngccFolder); this.updatePackageJson(entryPoint, formatProperties, ngccFolder);
} }
@ -59,7 +59,7 @@ export class NewEntryPointFileWriter extends InPlaceFileWriter {
// Revert the transformed files. // Revert the transformed files.
for (const filePath of transformedFilePaths) { for (const filePath of transformedFilePaths) {
this.revertFile(filePath, entryPoint.package); this.revertFile(filePath, entryPoint.packagePath);
} }
// Revert any changes to `package.json`. // Revert any changes to `package.json`.
@ -118,7 +118,7 @@ export class NewEntryPointFileWriter extends InPlaceFileWriter {
const oldFormatProp = formatProperties[0]!; const oldFormatProp = formatProperties[0]!;
const oldFormatPath = packageJson[oldFormatProp]!; const oldFormatPath = packageJson[oldFormatProp]!;
const oldAbsFormatPath = join(entryPoint.path, oldFormatPath); 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); const newFormatPath = relative(entryPoint.path, newAbsFormatPath);
// Update all properties in `package.json` (both in memory and on disk). // Update all properties in `package.json` (both in memory and on disk).

View File

@ -82,7 +82,7 @@ runInEachFileSystem(() => {
'test', 'esm2015', false, [_('/node_modules/test/entrypoint.js')]); 'test', 'esm2015', false, [_('/node_modules/test/entrypoint.js')]);
const program = bundle.src.program; const program = bundle.src.program;
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle.src); const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle.src);
const analyzer = new SwitchMarkerAnalyzer(host, bundle.entryPoint.package); const analyzer = new SwitchMarkerAnalyzer(host, bundle.entryPoint.packagePath);
const analysis = analyzer.analyzeProgram(program); const analysis = analyzer.analyzeProgram(program);
const entrypoint = getSourceFileOrError(program, _('/node_modules/test/entrypoint.js')); const entrypoint = getSourceFileOrError(program, _('/node_modules/test/entrypoint.js'));
@ -113,7 +113,7 @@ runInEachFileSystem(() => {
'test', 'esm2015', false, [_('/node_modules/test/entrypoint.js')]); 'test', 'esm2015', false, [_('/node_modules/test/entrypoint.js')]);
const program = bundle.src.program; const program = bundle.src.program;
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle.src); const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle.src);
const analyzer = new SwitchMarkerAnalyzer(host, bundle.entryPoint.package); const analyzer = new SwitchMarkerAnalyzer(host, bundle.entryPoint.packagePath);
const analysis = analyzer.analyzeProgram(program); const analysis = analyzer.analyzeProgram(program);
const x = getSourceFileOrError(program, _('/node_modules/other/x.js')); const x = getSourceFileOrError(program, _('/node_modules/other/x.js'));
@ -126,7 +126,7 @@ runInEachFileSystem(() => {
'test', 'esm2015', false, [_('/node_modules/test/entrypoint.js')]); 'test', 'esm2015', false, [_('/node_modules/test/entrypoint.js')]);
const program = bundle.src.program; const program = bundle.src.program;
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle.src); const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle.src);
const analyzer = new SwitchMarkerAnalyzer(host, bundle.entryPoint.package); const analyzer = new SwitchMarkerAnalyzer(host, bundle.entryPoint.packagePath);
const analysis = analyzer.analyzeProgram(program); const analysis = analyzer.analyzeProgram(program);
const x = getSourceFileOrError(program, _('/node_modules/test/node_modules/nested/e.js')); const x = getSourceFileOrError(program, _('/node_modules/test/node_modules/nested/e.js'));

View File

@ -60,52 +60,52 @@ runInEachFileSystem(() => {
first = { first = {
name: 'first', name: 'first',
path: _('/first'), path: _('/first'),
package: _('/first'), packagePath: _('/first'),
packageJson: {esm5: './index.js'}, packageJson: {esm5: './index.js'},
typings: _('/first/index.d.ts'),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
typings: _('/first/index.d.ts'),
} as EntryPoint; } as EntryPoint;
second = { second = {
path: _('/second'), path: _('/second'),
package: _('/second'), packagePath: _('/second'),
packageJson: {esm2015: './sub/index.js'}, packageJson: {esm2015: './sub/index.js'},
typings: _('/second/sub/index.d.ts'),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
typings: _('/second/sub/index.d.ts'),
} as EntryPoint; } as EntryPoint;
third = { third = {
path: _('/third'), path: _('/third'),
package: _('/third'), packagePath: _('/third'),
packageJson: {fesm5: './index.js'}, packageJson: {fesm5: './index.js'},
typings: _('/third/index.d.ts'),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
typings: _('/third/index.d.ts'),
} as EntryPoint; } as EntryPoint;
fourth = { fourth = {
path: _('/fourth'), path: _('/fourth'),
package: _('/fourth'), packagePath: _('/fourth'),
packageJson: {fesm2015: './sub2/index.js'}, packageJson: {fesm2015: './sub2/index.js'},
typings: _('/fourth/sub2/index.d.ts'),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
typings: _('/fourth/sub2/index.d.ts'),
} as EntryPoint; } as EntryPoint;
fifth = { fifth = {
path: _('/fifth'), path: _('/fifth'),
package: _('/fifth'), packagePath: _('/fifth'),
packageJson: {module: './index.js'}, packageJson: {module: './index.js'},
typings: _('/fifth/index.d.ts'),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
typings: _('/fifth/index.d.ts'),
} as EntryPoint; } as EntryPoint;
sixthIgnoreMissing = { sixthIgnoreMissing = {
path: _('/sixth'), path: _('/sixth'),
package: _('/sixth'), packagePath: _('/sixth'),
packageJson: {module: './index.js'}, packageJson: {module: './index.js'},
typings: _('/sixth/index.d.ts'),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: true, ignoreMissingDependencies: true,
typings: _('/sixth/index.d.ts'),
} as EntryPoint; } as EntryPoint;
dependencies = { dependencies = {
@ -291,11 +291,11 @@ runInEachFileSystem(() => {
const testEntryPoint = { const testEntryPoint = {
name: 'test-package', name: 'test-package',
path: _('/project/node_modules/test-package'), path: _('/project/node_modules/test-package'),
package: _('/project/node_modules/test-package'), packagePath: _('/project/node_modules/test-package'),
packageJson: {esm5: './index.js'}, packageJson: {esm5: './index.js'},
typings: _('/project/node_modules/test-package/index.d.ts'),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
typings: _('/project/node_modules/test-package/index.d.ts'),
} as EntryPoint; } as EntryPoint;
const result = resolver.sortEntryPointsByDependency( const result = resolver.sortEntryPointsByDependency(

View File

@ -451,7 +451,8 @@ runInEachFileSystem(() => {
function dumpEntryPointPaths( function dumpEntryPointPaths(
basePath: AbsoluteFsPath, entryPoints: EntryPoint[]): [string, string][] { basePath: AbsoluteFsPath, entryPoints: EntryPoint[]): [string, string][] {
return entryPoints.map(x => [relative(basePath, x.package), relative(basePath, x.path)]); return entryPoints.map(
x => [relative(basePath, x.packagePath), relative(basePath, x.path)]);
} }
}); });
}); });

View File

@ -159,7 +159,8 @@ runInEachFileSystem(() => {
function dumpEntryPointPaths( function dumpEntryPointPaths(
basePath: AbsoluteFsPath, entryPoints: EntryPoint[]): [string, string][] { basePath: AbsoluteFsPath, entryPoints: EntryPoint[]): [string, string][] {
return entryPoints.map(x => [relative(basePath, x.package), relative(basePath, x.path)]); return entryPoints.map(
x => [relative(basePath, x.packagePath), relative(basePath, x.path)]);
} }
}); });
}); });

View File

@ -318,7 +318,7 @@ runInEachFileSystem(() => {
const entryPoint = entryPoints[0]; const entryPoint = entryPoints[0];
expect(entryPoint.name).toEqual('secondary'); expect(entryPoint.name).toEqual('secondary');
expect(entryPoint.path).toEqual(_Abs('/path_mapped/dist/primary/secondary')); expect(entryPoint.path).toEqual(_Abs('/path_mapped/dist/primary/secondary'));
expect(entryPoint.package).toEqual(_Abs('/path_mapped/dist/primary')); expect(entryPoint.packagePath).toEqual(_Abs('/path_mapped/dist/primary'));
}); });
it('should correctly compute an entry-point whose path starts with the same string as another entry-point, via pathMappings', it('should correctly compute an entry-point whose path starts with the same string as another entry-point, via pathMappings',
@ -381,7 +381,8 @@ runInEachFileSystem(() => {
function dumpEntryPointPaths( function dumpEntryPointPaths(
basePath: AbsoluteFsPath, entryPoints: EntryPoint[]): [string, string][] { basePath: AbsoluteFsPath, entryPoints: EntryPoint[]): [string, string][] {
return entryPoints.map(x => [relative(basePath, x.package), relative(basePath, x.path)]); return entryPoints.map(
x => [relative(basePath, x.packagePath), relative(basePath, x.path)]);
} }
}); });

View File

@ -21,9 +21,9 @@ export function makeTestEntryPoint(
entryPointName: string, packageName: string = entryPointName, config?: TestConfig): EntryPoint { entryPointName: string, packageName: string = entryPointName, config?: TestConfig): EntryPoint {
return { return {
name: entryPointName, name: entryPointName,
packageJson: {name: entryPointName},
package: absoluteFrom(`/node_modules/${packageName}`),
path: absoluteFrom(`/node_modules/${entryPointName}`), path: absoluteFrom(`/node_modules/${entryPointName}`),
packagePath: absoluteFrom(`/node_modules/${packageName}`),
packageJson: {name: entryPointName},
typings: absoluteFrom(`/node_modules/${entryPointName}/index.d.ts`), typings: absoluteFrom(`/node_modules/${entryPointName}/index.d.ts`),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
@ -43,8 +43,9 @@ export function makeTestEntryPointBundle(
enableI18nLegacyMessageIdFormat = false): EntryPointBundle { enableI18nLegacyMessageIdFormat = false): EntryPointBundle {
const entryPoint = makeTestEntryPoint(packageName, packageName, config); const entryPoint = makeTestEntryPoint(packageName, packageName, config);
const src = makeTestBundleProgram(srcRootNames[0], isCore); const src = makeTestBundleProgram(srcRootNames[0], isCore);
const dts = const dts = dtsRootNames ?
dtsRootNames ? makeTestDtsBundleProgram(dtsRootNames[0], entryPoint.package, isCore) : null; makeTestDtsBundleProgram(dtsRootNames[0], entryPoint.packagePath, isCore) :
null;
const isFlatCore = isCore && src.r3SymbolsFile === null; const isFlatCore = isCore && src.r3SymbolsFile === null;
return { return {
entryPoint, entryPoint,

View File

@ -167,9 +167,9 @@ runInEachFileSystem(() => {
const fs = getFileSystem(); const fs = getFileSystem();
const entryPoint: EntryPoint = { const entryPoint: EntryPoint = {
name: 'test', name: 'test',
packageJson: {name: 'test'},
package: absoluteFrom('/node_modules/test'),
path: absoluteFrom('/node_modules/test'), path: absoluteFrom('/node_modules/test'),
packagePath: absoluteFrom('/node_modules/test'),
packageJson: {name: 'test'},
typings: absoluteFrom('/node_modules/test/index.d.ts'), typings: absoluteFrom('/node_modules/test/index.d.ts'),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
@ -217,9 +217,9 @@ runInEachFileSystem(() => {
const fs = getFileSystem(); const fs = getFileSystem();
const entryPoint: EntryPoint = { const entryPoint: EntryPoint = {
name: 'test', name: 'test',
packageJson: {name: 'test'},
package: absoluteFrom('/node_modules/test'),
path: absoluteFrom('/node_modules/test'), path: absoluteFrom('/node_modules/test'),
packagePath: absoluteFrom('/node_modules/test'),
packageJson: {name: 'test'},
typings: absoluteFrom('/node_modules/test/index.d.ts'), typings: absoluteFrom('/node_modules/test/index.d.ts'),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
@ -239,9 +239,9 @@ runInEachFileSystem(() => {
const fs = getFileSystem(); const fs = getFileSystem();
const entryPoint: EntryPoint = { const entryPoint: EntryPoint = {
name: 'internal', name: 'internal',
packageJson: {name: 'internal'},
package: absoluteFrom('/node_modules/internal'),
path: absoluteFrom('/node_modules/internal'), path: absoluteFrom('/node_modules/internal'),
packagePath: absoluteFrom('/node_modules/internal'),
packageJson: {name: 'internal'},
typings: absoluteFrom('/node_modules/internal/index.d.ts'), typings: absoluteFrom('/node_modules/internal/index.d.ts'),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
@ -261,9 +261,9 @@ runInEachFileSystem(() => {
const fs = getFileSystem(); const fs = getFileSystem();
const entryPoint: EntryPoint = { const entryPoint: EntryPoint = {
name: 'test', name: 'test',
packageJson: {name: 'test'},
package: absoluteFrom('/node_modules/test'),
path: absoluteFrom('/node_modules/test'), path: absoluteFrom('/node_modules/test'),
packagePath: absoluteFrom('/node_modules/test'),
packageJson: {name: 'test'},
typings: absoluteFrom('/node_modules/test/index.d.ts'), typings: absoluteFrom('/node_modules/test/index.d.ts'),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
@ -284,9 +284,9 @@ runInEachFileSystem(() => {
const fs = getFileSystem(); const fs = getFileSystem();
const entryPoint: EntryPoint = { const entryPoint: EntryPoint = {
name: 'secondary', name: 'secondary',
packageJson: {name: 'secondary'},
package: absoluteFrom('/node_modules/primary'),
path: absoluteFrom('/node_modules/primary/secondary'), path: absoluteFrom('/node_modules/primary/secondary'),
packagePath: absoluteFrom('/node_modules/primary'),
packageJson: {name: 'secondary'},
typings: absoluteFrom('/node_modules/primary/secondary/index.d.ts'), typings: absoluteFrom('/node_modules/primary/secondary/index.d.ts'),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,

View File

@ -148,9 +148,9 @@ runInEachFileSystem(() => {
expect(entryPoints).toEqual([{ expect(entryPoints).toEqual([{
entryPoint: { entryPoint: {
name: 'some_package/valid_entry_point', name: 'some_package/valid_entry_point',
packageJson: jasmine.any(Object),
package: _Abs('/project/node_modules/some_package'),
path: _Abs('/project/node_modules/some_package/valid_entry_point'), path: _Abs('/project/node_modules/some_package/valid_entry_point'),
packagePath: _Abs('/project/node_modules/some_package'),
packageJson: jasmine.any(Object),
typings: typings:
_Abs('/project/node_modules/some_package/valid_entry_point/valid_entry_point.d.ts'), _Abs('/project/node_modules/some_package/valid_entry_point/valid_entry_point.d.ts'),
compiledByAngular: true, compiledByAngular: true,
@ -298,8 +298,8 @@ runInEachFileSystem(() => {
fs.writeFile(_Abs('/project/package-lock.json'), 'LOCK FILE CONTENTS'); fs.writeFile(_Abs('/project/package-lock.json'), 'LOCK FILE CONTENTS');
const entryPoint1: EntryPointWithDependencies = { const entryPoint1: EntryPointWithDependencies = {
entryPoint: { entryPoint: {
package: _Abs('/project/node_modules/package-1/'),
path: _Abs('/project/node_modules/package-1/'), path: _Abs('/project/node_modules/package-1/'),
packagePath: _Abs('/project/node_modules/package-1/'),
} as any, } as any,
depInfo: { depInfo: {
dependencies: new Set([ dependencies: new Set([
@ -312,8 +312,8 @@ runInEachFileSystem(() => {
}; };
const entryPoint2: EntryPointWithDependencies = { const entryPoint2: EntryPointWithDependencies = {
entryPoint: { entryPoint: {
package: _Abs('/project/node_modules/package-2/'),
path: _Abs('/project/node_modules/package-2/entry-point'), path: _Abs('/project/node_modules/package-2/entry-point'),
packagePath: _Abs('/project/node_modules/package-2/'),
} as any, } as any,
depInfo: { depInfo: {
dependencies: new Set(), dependencies: new Set(),

View File

@ -44,11 +44,11 @@ runInEachFileSystem(() => {
_('/project/node_modules/some_package/valid_entry_point')); _('/project/node_modules/some_package/valid_entry_point'));
expect(entryPoint).toEqual({ expect(entryPoint).toEqual({
name: 'some_package/valid_entry_point', name: 'some_package/valid_entry_point',
package: SOME_PACKAGE,
path: _('/project/node_modules/some_package/valid_entry_point'), path: _('/project/node_modules/some_package/valid_entry_point'),
packagePath: SOME_PACKAGE,
packageJson: loadPackageJson(fs, '/project/node_modules/some_package/valid_entry_point'),
typings: typings:
_(`/project/node_modules/some_package/valid_entry_point/valid_entry_point.d.ts`), _(`/project/node_modules/some_package/valid_entry_point/valid_entry_point.d.ts`),
packageJson: loadPackageJson(fs, '/project/node_modules/some_package/valid_entry_point'),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
generateDeepReexports: false, generateDeepReexports: false,
@ -107,10 +107,10 @@ runInEachFileSystem(() => {
}; };
expect(entryPoint).toEqual({ expect(entryPoint).toEqual({
name: 'some_package/valid_entry_point', name: 'some_package/valid_entry_point',
package: SOME_PACKAGE,
path: _('/project/node_modules/some_package/valid_entry_point'), path: _('/project/node_modules/some_package/valid_entry_point'),
typings: _('/project/node_modules/some_package/valid_entry_point/some_other.d.ts'), packagePath: SOME_PACKAGE,
packageJson: overriddenPackageJson, packageJson: overriddenPackageJson,
typings: _('/project/node_modules/some_package/valid_entry_point/some_other.d.ts'),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
generateDeepReexports: false, generateDeepReexports: false,
@ -155,11 +155,11 @@ runInEachFileSystem(() => {
_('/project/node_modules/some_package/missing_package_json')); _('/project/node_modules/some_package/missing_package_json'));
expect(entryPoint).toEqual({ expect(entryPoint).toEqual({
name: 'some_package/missing_package_json', name: 'some_package/missing_package_json',
package: SOME_PACKAGE,
path: _('/project/node_modules/some_package/missing_package_json'), path: _('/project/node_modules/some_package/missing_package_json'),
packagePath: SOME_PACKAGE,
packageJson: {name: 'some_package/missing_package_json', ...override},
typings: _( typings: _(
'/project/node_modules/some_package/missing_package_json/missing_package_json.d.ts'), '/project/node_modules/some_package/missing_package_json/missing_package_json.d.ts'),
packageJson: {name: 'some_package/missing_package_json', ...override},
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
generateDeepReexports: false, generateDeepReexports: false,
@ -236,10 +236,10 @@ runInEachFileSystem(() => {
_('/project/node_modules/some_package/missing_typings')); _('/project/node_modules/some_package/missing_typings'));
expect(entryPoint).toEqual({ expect(entryPoint).toEqual({
name: 'some_package/missing_typings', name: 'some_package/missing_typings',
package: SOME_PACKAGE,
path: _('/project/node_modules/some_package/missing_typings'), path: _('/project/node_modules/some_package/missing_typings'),
typings: _(`/project/node_modules/some_package/missing_typings/${typingsPath}.d.ts`), packagePath: SOME_PACKAGE,
packageJson: loadPackageJson(fs, '/project/node_modules/some_package/missing_typings'), packageJson: loadPackageJson(fs, '/project/node_modules/some_package/missing_typings'),
typings: _(`/project/node_modules/some_package/missing_typings/${typingsPath}.d.ts`),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
generateDeepReexports: false, generateDeepReexports: false,
@ -261,10 +261,10 @@ runInEachFileSystem(() => {
_('/project/node_modules/some_package/missing_metadata')); _('/project/node_modules/some_package/missing_metadata'));
expect(entryPoint).toEqual({ expect(entryPoint).toEqual({
name: 'some_package/missing_metadata', name: 'some_package/missing_metadata',
package: SOME_PACKAGE,
path: _('/project/node_modules/some_package/missing_metadata'), path: _('/project/node_modules/some_package/missing_metadata'),
typings: _(`/project/node_modules/some_package/missing_metadata/missing_metadata.d.ts`), packagePath: SOME_PACKAGE,
packageJson: loadPackageJson(fs, '/project/node_modules/some_package/missing_metadata'), packageJson: loadPackageJson(fs, '/project/node_modules/some_package/missing_metadata'),
typings: _(`/project/node_modules/some_package/missing_metadata/missing_metadata.d.ts`),
compiledByAngular: false, compiledByAngular: false,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
generateDeepReexports: false, generateDeepReexports: false,
@ -290,10 +290,10 @@ runInEachFileSystem(() => {
_('/project/node_modules/some_package/missing_metadata')); _('/project/node_modules/some_package/missing_metadata'));
expect(entryPoint).toEqual({ expect(entryPoint).toEqual({
name: 'some_package/missing_metadata', name: 'some_package/missing_metadata',
package: SOME_PACKAGE,
path: _('/project/node_modules/some_package/missing_metadata'), path: _('/project/node_modules/some_package/missing_metadata'),
typings: _('/project/node_modules/some_package/missing_metadata/missing_metadata.d.ts'), packagePath: SOME_PACKAGE,
packageJson: loadPackageJson(fs, '/project/node_modules/some_package/missing_metadata'), packageJson: loadPackageJson(fs, '/project/node_modules/some_package/missing_metadata'),
typings: _('/project/node_modules/some_package/missing_metadata/missing_metadata.d.ts'),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
generateDeepReexports: false, generateDeepReexports: false,
@ -318,12 +318,12 @@ runInEachFileSystem(() => {
_('/project/node_modules/some_package/types_rather_than_typings')); _('/project/node_modules/some_package/types_rather_than_typings'));
expect(entryPoint).toEqual({ expect(entryPoint).toEqual({
name: 'some_package/types_rather_than_typings', name: 'some_package/types_rather_than_typings',
package: SOME_PACKAGE,
path: _('/project/node_modules/some_package/types_rather_than_typings'), path: _('/project/node_modules/some_package/types_rather_than_typings'),
typings: _( packagePath: SOME_PACKAGE,
`/project/node_modules/some_package/types_rather_than_typings/types_rather_than_typings.d.ts`),
packageJson: packageJson:
loadPackageJson(fs, '/project/node_modules/some_package/types_rather_than_typings'), loadPackageJson(fs, '/project/node_modules/some_package/types_rather_than_typings'),
typings: _(
`/project/node_modules/some_package/types_rather_than_typings/types_rather_than_typings.d.ts`),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
generateDeepReexports: false, generateDeepReexports: false,
@ -353,10 +353,10 @@ runInEachFileSystem(() => {
_('/project/node_modules/some_package/material_style')); _('/project/node_modules/some_package/material_style'));
expect(entryPoint).toEqual({ expect(entryPoint).toEqual({
name: 'some_package/material_style', name: 'some_package/material_style',
package: SOME_PACKAGE,
path: _('/project/node_modules/some_package/material_style'), path: _('/project/node_modules/some_package/material_style'),
typings: _(`/project/node_modules/some_package/material_style/material_style.d.ts`), packagePath: SOME_PACKAGE,
packageJson: loadPackageJson(fs, '/project/node_modules/some_package/material_style'), packageJson: loadPackageJson(fs, '/project/node_modules/some_package/material_style'),
typings: _(`/project/node_modules/some_package/material_style/material_style.d.ts`),
compiledByAngular: true, compiledByAngular: true,
ignoreMissingDependencies: false, ignoreMissingDependencies: false,
generateDeepReexports: false, generateDeepReexports: false,

View File

@ -156,7 +156,7 @@ exports.D = D;
const referencesRegistry = new NgccReferencesRegistry(host); const referencesRegistry = new NgccReferencesRegistry(host);
const decorationAnalyses = const decorationAnalyses =
new DecorationAnalyzer(fs, bundle, host, referencesRegistry).analyzeProgram(); new DecorationAnalyzer(fs, bundle, host, referencesRegistry).analyzeProgram();
const switchMarkerAnalyses = new SwitchMarkerAnalyzer(host, bundle.entryPoint.package) const switchMarkerAnalyses = new SwitchMarkerAnalyzer(host, bundle.entryPoint.packagePath)
.analyzeProgram(bundle.src.program); .analyzeProgram(bundle.src.program);
const renderer = new CommonJsRenderingFormatter(host, false); const renderer = new CommonJsRenderingFormatter(host, false);
const importManager = new ImportManager(new NoopImportRewriter(), 'i'); const importManager = new ImportManager(new NoopImportRewriter(), 'i');

View File

@ -33,8 +33,8 @@ function setup(file: {name: AbsoluteFsPath, contents: string}) {
const referencesRegistry = new NgccReferencesRegistry(host); const referencesRegistry = new NgccReferencesRegistry(host);
const decorationAnalyses = const decorationAnalyses =
new DecorationAnalyzer(fs, bundle, host, referencesRegistry).analyzeProgram(); new DecorationAnalyzer(fs, bundle, host, referencesRegistry).analyzeProgram();
const switchMarkerAnalyses = const switchMarkerAnalyses = new SwitchMarkerAnalyzer(host, bundle.entryPoint.packagePath)
new SwitchMarkerAnalyzer(host, bundle.entryPoint.package).analyzeProgram(bundle.src.program); .analyzeProgram(bundle.src.program);
const renderer = new Esm5RenderingFormatter(host, false); const renderer = new Esm5RenderingFormatter(host, false);
const importManager = new ImportManager(new NoopImportRewriter(), IMPORT_PREFIX); const importManager = new ImportManager(new NoopImportRewriter(), IMPORT_PREFIX);
return { return {

View File

@ -38,8 +38,8 @@ function setup(files: TestFile[], dtsFiles?: TestFile[]) {
const referencesRegistry = new NgccReferencesRegistry(host); const referencesRegistry = new NgccReferencesRegistry(host);
const decorationAnalyses = const decorationAnalyses =
new DecorationAnalyzer(fs, bundle, host, referencesRegistry).analyzeProgram(); new DecorationAnalyzer(fs, bundle, host, referencesRegistry).analyzeProgram();
const switchMarkerAnalyses = const switchMarkerAnalyses = new SwitchMarkerAnalyzer(host, bundle.entryPoint.packagePath)
new SwitchMarkerAnalyzer(host, bundle.entryPoint.package).analyzeProgram(bundle.src.program); .analyzeProgram(bundle.src.program);
const renderer = new EsmRenderingFormatter(host, false); const renderer = new EsmRenderingFormatter(host, false);
const importManager = new ImportManager(new NoopImportRewriter(), IMPORT_PREFIX); const importManager = new ImportManager(new NoopImportRewriter(), IMPORT_PREFIX);
return { return {

View File

@ -90,8 +90,8 @@ function createTestRenderer(
const referencesRegistry = new NgccReferencesRegistry(host); const referencesRegistry = new NgccReferencesRegistry(host);
const decorationAnalyses = const decorationAnalyses =
new DecorationAnalyzer(fs, bundle, host, referencesRegistry).analyzeProgram(); new DecorationAnalyzer(fs, bundle, host, referencesRegistry).analyzeProgram();
const switchMarkerAnalyses = const switchMarkerAnalyses = new SwitchMarkerAnalyzer(host, bundle.entryPoint.packagePath)
new SwitchMarkerAnalyzer(host, bundle.entryPoint.package).analyzeProgram(bundle.src.program); .analyzeProgram(bundle.src.program);
const privateDeclarationsAnalyses = const privateDeclarationsAnalyses =
new PrivateDeclarationsAnalyzer(host, referencesRegistry).analyzeProgram(bundle.src.program); new PrivateDeclarationsAnalyzer(host, referencesRegistry).analyzeProgram(bundle.src.program);
const testFormatter = new TestRenderingFormatter(); const testFormatter = new TestRenderingFormatter();

View File

@ -34,7 +34,7 @@ function setup(file: TestFile) {
const decorationAnalyses = const decorationAnalyses =
new DecorationAnalyzer(fs, bundle, host, referencesRegistry).analyzeProgram(); new DecorationAnalyzer(fs, bundle, host, referencesRegistry).analyzeProgram();
const switchMarkerAnalyses = const switchMarkerAnalyses =
new SwitchMarkerAnalyzer(host, bundle.entryPoint.package).analyzeProgram(src.program); new SwitchMarkerAnalyzer(host, bundle.entryPoint.packagePath).analyzeProgram(src.program);
const renderer = new UmdRenderingFormatter(host, false); const renderer = new UmdRenderingFormatter(host, false);
const importManager = new ImportManager(new NoopImportRewriter(), 'i'); const importManager = new ImportManager(new NoopImportRewriter(), 'i');
return { return {

View File

@ -577,7 +577,7 @@ runInEachFileSystem(() => {
it('should revert changes to `package.json`', () => { it('should revert changes to `package.json`', () => {
const entryPoint = esm5bundle.entryPoint; const entryPoint = esm5bundle.entryPoint;
const packageJsonPath = join(entryPoint.package, 'package.json'); const packageJsonPath = join(entryPoint.packagePath, 'package.json');
fileWriter.writeBundle( fileWriter.writeBundle(
esm5bundle, esm5bundle,