fix(ivy): ngcc should not fail on invalid package.json (#26539)

Some package.json files may have invalid JSON, for example package.json blueprints from `@schematics/angular` (see https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/workspace/files/package.json).

This makes ngcc more resilient, by simpling logging a warning if an error is encountered, instead of failing as it does right now.

PR Close #26539
This commit is contained in:
cexbrayat
2018-10-18 15:08:08 +02:00
committed by Andrew Kushnir
parent 5247594e86
commit f5a0ec0d7c
2 changed files with 35 additions and 4 deletions

View File

@ -78,6 +78,11 @@ describe('getEntryPointInfo()', () => {
umd: `/some_package/material_style/bundles/material_style.umd.js`,
});
});
it('should return null if the package.json is not valid JSON', () => {
const entryPoint = getEntryPointInfo('/some_package', '/some_package/unexpected_symbols');
expect(entryPoint).toBe(null);
});
});
function createMockFileSystem() {
@ -115,8 +120,15 @@ function createMockFileSystem() {
"module": "./esm5/material_style.es5.js",
"es2015": "./esm2015/material_style.js"
}`,
'material_style.metadata.json': 'some meta data'
}
'material_style.metadata.json': 'some meta data',
},
'unexpected_symbols': {
// package.json might not be a valid JSON
// for example, @schematics/angular contains a package.json blueprint
// with unexpected symbols
'package.json':
'{"devDependencies": {<% if (!minimal) { %>"@types/jasmine": "~2.8.8" <% } %>}}',
},
}
});
}