perf(ivy): ngcc - use flat file for dependency sorting if available (#26403)
Previously we always used the non-flat format because we thought that this was the one that would always be available. It turns out that this is not the case and that only one of the flat and non-flat formats may be available. Therefore we should use whichever is available, defaulting to the flat format if that exists, since that will be faster to parse. PR Close #26403
This commit is contained in:
parent
bec4ca0c73
commit
e804143183
|
@ -79,9 +79,10 @@ export class DependencyResolver {
|
|||
|
||||
// Now add the dependencies between them
|
||||
entryPoints.forEach(entryPoint => {
|
||||
const entryPointPath = entryPoint.esm2015;
|
||||
const entryPointPath = entryPoint.fesm2015 || entryPoint.esm2015;
|
||||
if (!entryPointPath) {
|
||||
throw new Error(`Esm2015 format missing in '${entryPoint.path}' entry-point.`);
|
||||
throw new Error(
|
||||
`ESM2015 format (flat and non-flat) missing in '${entryPoint.path}' entry-point.`);
|
||||
}
|
||||
|
||||
const dependencies = new Set<string>();
|
||||
|
|
|
@ -10,7 +10,7 @@ import {DependencyHost} from '../../src/packages/dependency_host';
|
|||
import {DependencyResolver} from '../../src/packages/dependency_resolver';
|
||||
import {EntryPoint} from '../../src/packages/entry_point';
|
||||
|
||||
describe('DepencencyResolver', () => {
|
||||
describe('DependencyResolver', () => {
|
||||
let host: DependencyHost;
|
||||
let resolver: DependencyResolver;
|
||||
beforeEach(() => {
|
||||
|
@ -18,11 +18,11 @@ describe('DepencencyResolver', () => {
|
|||
resolver = new DependencyResolver(host);
|
||||
});
|
||||
describe('sortEntryPointsByDependency()', () => {
|
||||
const first = { path: 'first', esm2015: 'first/index.ts' } as EntryPoint;
|
||||
const first = { path: 'first', fesm2015: 'first/index.ts' } as EntryPoint;
|
||||
const second = { path: 'second', esm2015: 'second/index.ts' } as EntryPoint;
|
||||
const third = { path: 'third', esm2015: 'third/index.ts' } as EntryPoint;
|
||||
const third = { path: 'third', fesm2015: 'third/index.ts' } as EntryPoint;
|
||||
const fourth = { path: 'fourth', esm2015: 'fourth/index.ts' } as EntryPoint;
|
||||
const fifth = { path: 'fifth', esm2015: 'fifth/index.ts' } as EntryPoint;
|
||||
const fifth = { path: 'fifth', fesm2015: 'fifth/index.ts' } as EntryPoint;
|
||||
|
||||
const dependencies = {
|
||||
'first/index.ts': {resolved: ['second', 'third', 'ignored-1'], missing: []},
|
||||
|
@ -80,10 +80,11 @@ describe('DepencencyResolver', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it('should error if the entry point does not have the esm2015 format', () => {
|
||||
expect(() => resolver.sortEntryPointsByDependency([{ path: 'first' } as EntryPoint]))
|
||||
.toThrowError(`Esm2015 format missing in 'first' entry-point.`);
|
||||
});
|
||||
it('should error if the entry point does not have either the fesm2015 nor esm2015 formats',
|
||||
() => {
|
||||
expect(() => resolver.sortEntryPointsByDependency([{ path: 'first' } as EntryPoint]))
|
||||
.toThrowError(`ESM2015 format (flat and non-flat) missing in 'first' entry-point.`);
|
||||
});
|
||||
|
||||
it('should capture any dependencies that were ignored', () => {
|
||||
spyOn(host, 'computeDependencies').and.callFake(createFakeComputeDependencies(dependencies));
|
||||
|
|
Loading…
Reference in New Issue