fix(ngcc): correctly get config for sub-entry-points when primary entry-point is ignored (#37040)
Previously, when an entry-point was ignored via an ngcc config, ngcc would scan sub-directories for sub-entry-points, but would not use the correct `packagePath`. For example, if `@angular/common` was ignored, it would look at `@angular/common/http` but incorrectly use `.../@angular/common/http` as the `packagePath` (instead of `.../@angular/common`). As a result, it would not retrieve the correct ngcc config for the actual package. This commit fixes it by ensuring the correct `packagePath` is used, even if the primary entry-point corresponding to that path is ignored. In order to do this, a new return value for `getEntryPointInfo()` is added: `IGNORED_ENTRY_POINT`. This is used to differentiate between directories that correspond to no or an incompatible entry-point and those that correspond to an entry-point that could otherwise be valid but is explicitly ignored. Consumers of `getEntryPointInfo()` can then use this info to discard ignored entry-points, but still use the correct `packagePath` when scanning their sub-directories for secondary entry-points. PR Close #37040
This commit is contained in:

committed by
Misko Hevery

parent
ab9bc8a9ec
commit
e7a0e87c41
@ -1615,21 +1615,28 @@ runInEachFileSystem(() => {
|
||||
loadTestFiles([
|
||||
{
|
||||
name: _('/ngcc.config.js'),
|
||||
contents: `module.exports = { packages: {
|
||||
'@angular/core': {
|
||||
entryPoints: {
|
||||
'./testing': {ignore: true}
|
||||
},
|
||||
},
|
||||
'@angular/common': {
|
||||
entryPoints: {
|
||||
'.': {ignore: true}
|
||||
},
|
||||
}
|
||||
}};`,
|
||||
contents: `
|
||||
module.exports = {
|
||||
packages: {
|
||||
'@angular/core': {
|
||||
entryPoints: {
|
||||
'./testing': {ignore: true},
|
||||
},
|
||||
},
|
||||
'@angular/common': {
|
||||
entryPoints: {
|
||||
'.': {ignore: true},
|
||||
'./http': {override: {fesm2015: undefined}},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
`,
|
||||
},
|
||||
]);
|
||||
|
||||
mainNgcc({basePath: '/node_modules', propertiesToConsider: ['es2015']});
|
||||
|
||||
// We process core but not core/testing.
|
||||
expect(loadPackage('@angular/core').__processed_by_ivy_ngcc__).toEqual({
|
||||
module: '0.0.0-PLACEHOLDER',
|
||||
@ -1638,12 +1645,14 @@ runInEachFileSystem(() => {
|
||||
typings: '0.0.0-PLACEHOLDER',
|
||||
});
|
||||
expect(loadPackage('@angular/core/testing').__processed_by_ivy_ngcc__).toBeUndefined();
|
||||
|
||||
// We do not compile common but we do compile its sub-entry-points.
|
||||
expect(loadPackage('@angular/common').__processed_by_ivy_ngcc__).toBeUndefined();
|
||||
expect(loadPackage('@angular/common/http').__processed_by_ivy_ngcc__).toEqual({
|
||||
// `fesm2015` is not processed, because the ngcc config removes it.
|
||||
// fesm2015: '0.0.0-PLACEHOLDER',
|
||||
module: '0.0.0-PLACEHOLDER',
|
||||
es2015: '0.0.0-PLACEHOLDER',
|
||||
fesm2015: '0.0.0-PLACEHOLDER',
|
||||
typings: '0.0.0-PLACEHOLDER',
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user