angular/packages/compiler-cli
Kristiyan Kostadinov 05a16b973d refactor(compiler): add support for advanced tracking expressions (#51618)
These changes build on top of #51514 to add support for advanced expressions inside the `track` parameter of `for` loop blocks. There are two different outputs that the compiler can generate:

1. If the tracking function only references the item or `$index`, the compiler generates a pure arrow function as a constant references in the `repeaterCreate` instruction.
2. If the tracking function has references to properties outside of the `for` loop block, the compiler will rewrite those references to go through `this` and generate a function declaration. The runtime will `bind` the declaration to the current component instance so that the rewritten `this` references are resolved correctly.

Advanced tracking expression come with the following limitations to ensure the best possible performance:
1. They can only reference the item, `$index` and properties directly on the component instance. This means that there'll be an error when accessing this like local template variables and references. While we could get this to work, we would have to traverse the context tree at runtime which will degrade the performance of the loop, because it's a linear time operation that is performed on each comparison. Furthermore, allowing local references would require us re-evaluate the list when any one of them has changed.
2. Pipes aren't allowed inside the tracking function.
3. Object literals and pipes used inside the tracking expression will be recreated on each invocation.

PR Close #51618
2023-09-05 14:19:18 +00:00
..
integrationtest refactor(compiler-cli): remove unused integration tests. (#49862) 2023-04-17 14:57:02 +00:00
linker refactor(compiler): introduce AST for outputting arrow functions (#51436) 2023-08-23 14:45:33 -07:00
ngcc refactor(compiler-cli): add back ngcc as a no-op with a warning (#50045) 2023-04-28 18:18:40 +02:00
private refactor(compiler-cli): remove unused class decorator downlevel code (#49351) 2023-03-08 17:59:12 +00:00
src refactor(compiler): type check deferred when and prefetch when triggers (#51570) 2023-09-05 14:18:44 +00:00
test refactor(compiler): add support for advanced tracking expressions (#51618) 2023-09-05 14:19:18 +00:00
BUILD.bazel refactor(compiler-cli): drop tsickle code paths (#50602) 2023-08-17 10:23:49 -07:00
esbuild.config.js refactor: remove __ESM_IMPORT_META_URL__ workaround now that we can use ESM (#48521) 2022-12-19 19:50:41 +00:00
index.ts refactor(compiler-cli): Export the interface PluginCompilerHost for 1p use. (#48874) 2023-02-02 09:44:18 -08:00
package.json feat(core): support TypeScript 5.2 (#51334) 2023-08-18 07:55:16 -07:00
tsconfig-build.json refactor(compiler-cli): dismantle View Engine implementation of ngc (#44269) 2021-12-01 10:36:30 -08:00
tsconfig.json build: update tsconfigs to use ES2020 as target and module (#43431) 2021-10-01 18:28:42 +00:00