Commit 532ae73
perf(compiler-cli): avoid module resolution in cycle analysis (#40948)
The compiler performs cycle analysis for the used directives and pipes
of a component's template to avoid introducing a cyclic import into the
generated output. The used directives and pipes are represented by their
output expression which would typically be an `ExternalExpr`; those are
responsible for the generation of an `import` statement. Cycle analysis
needs to determine the `ts.SourceFile` that would end up being imported
by these `ExternalExpr`s, as the `ts.SourceFile` is then checked against
the program's `ImportGraph` to determine if the import is allowed, i.e.
does not introduce a cycle. To accomplish this, the `ExternalExpr` was
dissected and ran through module resolution to obtain the imported
`ts.SourceFile`.
This module resolution step is relatively expensive, as it typically
needs to hit the filesystem. Even in the presence of a module resolution
cache would these module resolution requests generally see cache misses,
as the generated import originates from a file for which the cache has
not previously seen the imported module specifier.
This commit removes the need for the module resolution by wrapping the
generated `Expression` in an `EmittedReference` struct. This allows the
reference emitter mechanism that is responsible for generating the
`Expression` to also communicate from which `ts.SourceFile` the
generated `Expression` would be imported, precluding the need for module
resolution down the road.
PR Close #409481 parent 2035b15 commit 532ae73
10 files changed
Lines changed: 162 additions & 83 deletions
File tree
- packages/compiler-cli/src/ngtsc
- annotations/src
- imports
- src
- test
- modulewithproviders/src
- scope/src
- typecheck/src
Lines changed: 43 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
628 | 628 | | |
629 | 629 | | |
630 | 630 | | |
631 | | - | |
| 631 | + | |
| 632 | + | |
632 | 633 | | |
| 634 | + | |
633 | 635 | | |
634 | 636 | | |
635 | | - | |
| 637 | + | |
| 638 | + | |
636 | 639 | | |
637 | 640 | | |
638 | 641 | | |
639 | 642 | | |
640 | 643 | | |
641 | 644 | | |
642 | 645 | | |
643 | | - | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
644 | 653 | | |
645 | 654 | | |
646 | 655 | | |
647 | 656 | | |
648 | 657 | | |
649 | 658 | | |
| 659 | + | |
650 | 660 | | |
651 | 661 | | |
652 | 662 | | |
653 | | - | |
| 663 | + | |
| 664 | + | |
654 | 665 | | |
655 | 666 | | |
656 | 667 | | |
| |||
665 | 676 | | |
666 | 677 | | |
667 | 678 | | |
668 | | - | |
| 679 | + | |
| 680 | + | |
669 | 681 | | |
670 | 682 | | |
671 | 683 | | |
672 | 684 | | |
673 | 685 | | |
674 | 686 | | |
675 | | - | |
| 687 | + | |
| 688 | + | |
676 | 689 | | |
677 | 690 | | |
678 | 691 | | |
| |||
682 | 695 | | |
683 | 696 | | |
684 | 697 | | |
685 | | - | |
686 | | - | |
| 698 | + | |
| 699 | + | |
687 | 700 | | |
688 | | - | |
689 | | - | |
| 701 | + | |
| 702 | + | |
690 | 703 | | |
691 | 704 | | |
692 | 705 | | |
| |||
1189 | 1202 | | |
1190 | 1203 | | |
1191 | 1204 | | |
1192 | | - | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
1193 | 1216 | | |
1194 | 1217 | | |
1195 | 1218 | | |
| |||
1204 | 1227 | | |
1205 | 1228 | | |
1206 | 1229 | | |
1207 | | - | |
1208 | | - | |
1209 | | - | |
1210 | | - | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
1211 | 1234 | | |
1212 | 1235 | | |
1213 | 1236 | | |
1214 | | - | |
| 1237 | + | |
1215 | 1238 | | |
1216 | 1239 | | |
1217 | | - | |
1218 | | - | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
1219 | 1243 | | |
1220 | 1244 | | |
1221 | 1245 | | |
| |||
Lines changed: 5 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
421 | | - | |
| 421 | + | |
422 | 422 | | |
423 | 423 | | |
424 | 424 | | |
| |||
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
469 | | - | |
470 | | - | |
471 | | - | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
| 474 | + | |
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
277 | 276 | | |
278 | 277 | | |
279 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
213 | 212 | | |
214 | 213 | | |
215 | 214 | | |
216 | | - | |
217 | | - | |
| 215 | + | |
| 216 | + | |
218 | 217 | | |
219 | 218 | | |
220 | 219 | | |
221 | | - | |
| 220 | + | |
222 | 221 | | |
223 | 222 | | |
0 commit comments