Skip to content

Conversation

arturovt
Copy link
Contributor

The checkNoChanges method previously used an early-return guard:

  if (!ngDevMode) return;
  // dev-only code ...

In production builds, ngDevMode is replaced with false, so the guard compiles to return;. However, bundlers like ESBuild still keep the remaining statements after the return as unreachable code instead of removing them. This leaves behind unnecessary dead code in the output.

This commit updates the method to instead wrap the full body:

  if (ngDevMode) {
    // dev-only code ...
  }

With this change, the method collapses to an empty function in production builds.

This ensures that the dev-only logic and its dependencies (e.g. checkNoChangesInternal, UseExhaustiveCheckNoChanges) can be fully tree-shaken, reducing bundle size.

image

@pullapprove pullapprove bot requested a review from thePunderWoman August 25, 2025 20:48
@angular-robot angular-robot bot added the area: core Issues related to the framework runtime label Aug 25, 2025
@ngbot ngbot bot added this to the Backlog milestone Aug 25, 2025
@arturovt arturovt force-pushed the refactor/drop-checkNoChanges branch 2 times, most recently from 4a5ad38 to 1579f28 Compare August 27, 2025 19:59
…tter tree-shaking

The `checkNoChanges` method previously used an early-return guard:

  if (!ngDevMode) return;
  // dev-only code ...

In production builds, `ngDevMode` is replaced with `false`, so the
guard compiles to `return;`. However, bundlers like ESBuild
still keep the remaining statements after the return as unreachable
code instead of removing them. This leaves behind unnecessary dead
code in the output.

This commit updates the method to instead wrap the full body:

  if (ngDevMode) {
    // dev-only code ...
  }

With this change, the method collapses to an empty function in
production builds:

  checkNoChanges() {}

This ensures that the dev-only logic and its dependencies
(e.g. `checkNoChangesInternal`, `UseExhaustiveCheckNoChanges`) can be
fully tree-shaken, reducing bundle size.
@arturovt arturovt force-pushed the refactor/drop-checkNoChanges branch from 1579f28 to 68f5eb2 Compare August 28, 2025 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues related to the framework runtime
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants