question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Performance conformance compile-time checks

See original GitHub issue

Feature 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:open
  • Created 2 years ago
  • Reactions:23
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
dgp1130commented, Jan 28, 2022

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.

  • Find all the unused components, directives, and pipes in the hierarchy of @NgModule and report them.

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.

  • Inline styles within component templates. They are going to break CSS inlining and also view encapsulation.

Could definitely ban <style /> tags in Angular templates. Would definitely save some debugging time.

  • Prevent adding fonts within component template. Rather, prefer adding fonts globally to index.html.

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?

  • 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

This sounds like an easy win for an extended diagnostic.

2reactions
sodcommented, Jul 1, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found