fix(compiler-cli): match string indexed partial declarations (#41747)

Some partial libraries have been minified, which results in the declaration
calls being being converted from property accesses to indexed accesses.
This commit ensures that the linker can process these calls.

Fixes #41655

PR Close #41747
This commit is contained in:
Pete Bacon Darwin 2021-04-21 13:20:27 +01:00 committed by Jessica Janiuk
parent 7744e1e673
commit c3a512a9e9
2 changed files with 9 additions and 2 deletions

View File

@ -139,6 +139,8 @@ function getCalleeName(call: NodePath<t.CallExpression>): string|null {
return callee.name; return callee.name;
} else if (t.isMemberExpression(callee) && t.isIdentifier(callee.property)) { } else if (t.isMemberExpression(callee) && t.isIdentifier(callee.property)) {
return callee.property.name; return callee.property.name;
} else if (t.isMemberExpression(callee) && t.isStringLiteral(callee.property)) {
return callee.property.value;
} else { } else {
return null; return null;
} }

View File

@ -70,9 +70,10 @@ describe('createEs2015LinkerPlugin()', () => {
[ [
'var core;', 'var core;',
`ɵɵngDeclareDirective({minVersion: '0.0.0-PLACEHOLDER', version: '0.0.0-PLACEHOLDER', ngImport: core, x: 1});`, `ɵɵngDeclareDirective({minVersion: '0.0.0-PLACEHOLDER', version: '0.0.0-PLACEHOLDER', ngImport: core, x: 1});`,
`ɵɵngDeclareComponent({minVersion: '0.0.0-PLACEHOLDER', version: '0.0.0-PLACEHOLDER', ngImport: core, foo: () => ɵɵngDeclareDirective({minVersion: '0.0.0-PLACEHOLDER', version: '0.0.0-PLACEHOLDER', ngImport: core, x: 2})});`, `i0.ɵɵngDeclareComponent({minVersion: '0.0.0-PLACEHOLDER', version: '0.0.0-PLACEHOLDER', ngImport: core, foo: () => ɵɵngDeclareDirective({minVersion: '0.0.0-PLACEHOLDER', version: '0.0.0-PLACEHOLDER', ngImport: core, x: 2})});`,
`x.qux(() => ɵɵngDeclareDirective({minVersion: '0.0.0-PLACEHOLDER', version: '0.0.0-PLACEHOLDER', ngImport: core, x: 3}));`, `x.qux(() => ɵɵngDeclareDirective({minVersion: '0.0.0-PLACEHOLDER', version: '0.0.0-PLACEHOLDER', ngImport: core, x: 3}));`,
'spread(...x);', 'spread(...x);',
`i0['ɵɵngDeclareDirective']({minVersion: '0.0.0-PLACEHOLDER', version: '0.0.0-PLACEHOLDER', ngImport: core, x: 4});`,
].join('\n'), ].join('\n'),
{ {
plugins: [createEs2015LinkerPlugin({fileSystem, logger})], plugins: [createEs2015LinkerPlugin({fileSystem, logger})],
@ -93,7 +94,11 @@ describe('createEs2015LinkerPlugin()', () => {
[ [
'ɵɵngDeclareDirective', 'ɵɵngDeclareDirective',
'{minVersion:\'0.0.0-PLACEHOLDER\',version:\'0.0.0-PLACEHOLDER\',ngImport:core,x:3}' '{minVersion:\'0.0.0-PLACEHOLDER\',version:\'0.0.0-PLACEHOLDER\',ngImport:core,x:3}'
] ],
[
'ɵɵngDeclareDirective',
'{minVersion:\'0.0.0-PLACEHOLDER\',version:\'0.0.0-PLACEHOLDER\',ngImport:core,x:4}'
],
]); ]);
}); });