perf(ngcc): reduce the size of the entry-point manifest file (#36486)

The base path for package and entry-points is known so there is
no need to store these in the file. Also this commit avoids storing
empty arrays unnecessarily.

PR Close #36486
This commit is contained in:
Pete Bacon Darwin
2020-04-09 14:56:28 +01:00
committed by atscott
parent 918e628f9b
commit 603b0944d5
3 changed files with 47 additions and 29 deletions

View File

@ -1079,7 +1079,7 @@ runInEachFileSystem(() => {
// Populate the manifest file
mainNgcc(
{basePath: '/node_modules', propertiesToConsider: ['esm5'], logger: new MockLogger()});
// Check that common/testings ES5 was processed
// Check that common/testing ES5 was processed
let commonTesting =
JSON.parse(fs.readFile(_('/node_modules/@angular/common/testing/package.json')));
expect(hasBeenProcessed(commonTesting, 'esm5')).toBe(true);
@ -1087,8 +1087,8 @@ runInEachFileSystem(() => {
// Modify the manifest to test that is has no effect
let manifest: EntryPointManifestFile =
JSON.parse(fs.readFile(_('/node_modules/__ngcc_entry_points__.json')));
manifest.entryPointPaths = manifest.entryPointPaths.filter(
paths => paths[1] !== _('/node_modules/@angular/common/testing'));
manifest.entryPointPaths =
manifest.entryPointPaths.filter(paths => paths[1] !== '@angular/common/testing');
fs.writeFile(_('/node_modules/__ngcc_entry_points__.json'), JSON.stringify(manifest));
// Now run ngcc again ignoring this manifest but trying to process ES2015, which are not yet
// processed.
@ -1107,12 +1107,12 @@ runInEachFileSystem(() => {
// had removed earlier.
manifest = JSON.parse(fs.readFile(_('/node_modules/__ngcc_entry_points__.json')));
expect(manifest.entryPointPaths).toContain([
_('/node_modules/@angular/common'), _('/node_modules/@angular/common/testing'),
'@angular/common',
'@angular/common/testing',
[
_('/node_modules/@angular/core'), _('/node_modules/@angular/common'),
_('/node_modules/rxjs')
],
[], []
]);
});
});

View File

@ -284,18 +284,16 @@ runInEachFileSystem(() => {
JSON.parse(fs.readFile(_Abs('/project/node_modules/__ngcc_entry_points__.json')));
expect(file.entryPointPaths).toEqual([
[
_Abs('/project/node_modules/package-1/'),
_Abs('/project/node_modules/package-1/'),
'package-1',
'package-1',
[
_Abs('/project/node_modules/other_package_1'),
_Abs('/project/node_modules/other_package_2'),
],
[],
[],
],
[
_Abs('/project/node_modules/package-2/'),
_Abs('/project/node_modules/package-2/entry-point'),
'package-2',
'package-2/entry-point',
[],
[
_Abs('/project/node_modules/missing_1'),