Performance conformance compile-time checks
See original GitHub issueFeature Request
Relevant Package
@angular/compiler
and @angular/compiler-cli
Description
Introduce compile-time conformance checks to guard against performance anti-patterns.
Describe the solution you’d like
The Angular compiler can perform extra checks on the user application to guard against common pitfalls. We already have the available parsing and reporting infrastructure, and there’s work happening in the direction of expanding the number of compile-time checks.
A few examples of helpful performance conformance rules are:
- Find all the unused components, directives, and pipes in the hierarchy of
@NgModule
and report them. - Inline styles within component templates. They are going to break CSS inlining and also view encapsulation.
- Prevent adding fonts within component template. Rather, prefer adding fonts globally to
index.html
. - Check if there’s a relative anchor without a
routerLink
attribute. This is often a user mistake that can cause the page to reload rather than trigger a client-side navigation
Describe alternatives you’ve considered
An alternative is to delegate these checks to linters, such as eslint or codelyzer (now deprecated). Even though this would reduce maintenance, we’d also be limited to only applications using the linting tooling and have explicitly enabled these checks.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:23
- Comments:5 (4 by maintainers)
Top Results From Across the Web
The Surprising Cost of Protocol Conformances in Swift
A deep dive into the Swift runtime to see how protocol conformance checks slow down post-main startup time as your binary size increases....
Read more >Compile-time conditional protocol conformance in Swift
This does not work. The compiler tries to compile each conditional block as a series of statements. But the block : SomeProtocol does...
Read more >Compile-time Safety and Runtime Performance in ...
In this thesis, we argue for programming models that are statically typed, both for reliability and performance reasons, and that provide powerful abstractions, ......
Read more >Performance of Compiler-Assisted Memory Safety Checking
Sometimes a compiler can prove at compile time that an access is in bounds, but usually this is not the case. If the...
Read more >{fmt} 8.0 released with compile-time format string checks ...
{fmt} 8.0 released with compile-time format string checks, compile-time formatting, improved performance and more. by Victor Zverovich.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
These could be a good candidate for extended diagnostics now that it has launched. We should consider which of these checks may make sense as a diagnostic.
Probably difficult to implement as an extended diagnostic and IMHO very annoying when developing. I could see some folks disabling this check by default, but enabling it for CI, though even that would prevent incremental additions and could be frustrating.
Could definitely ban
<style />
tags in Angular templates. Would definitely save some debugging time.Would this be handled by banning
<style />
? Is it possible to define fonts outside of CSS? Is this some kind of<link />
tag we would want to ban?This sounds like an easy win for an extended diagnostic.
you could add to the list:
getObservable() | async
// <- of course this can work, if the return value is in some form memoized, but in 99% of cases, that developer didn’t yet fully understand observables.