Skip to content

Conversation

sirTomasson
Copy link
Contributor

PR Checklist

Please check to confirm your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

When using esbuild, Angular sets up a custom file watcher using esbuilds metafile inputs. Esbuild will generate define:KEY entries see https://esbuild.github.io/try/#YgAwLjI1LjMALS1kZWZpbmU6Rk9PPSd7fScgLS1tZXRhZmlsZSAtLWJ1bmRsZQBlAGVudHJ5LmpzAGNvbnNvbGUubG9nKEZPTyk. After the build is finished, the file watcher will notice that the define:KEY entries no longer exist on the file system and trigger a rebuild even though no files have changed.

Issue Number: N/A

What is the new behavior?

No rebuilds are triggered since the file watcher is no longer tracking changes to define:KEY entries.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

There other conditions which may also trigger a rebuilds, because the file watcher is tracking all inputs from the metafile, which are not necessarily files. This esbuild plugin example will also trigger a rebuild because esbuild will add the ns-env namespace to the metafile inputs.

Copy link

google-cla bot commented May 2, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@angular-robot angular-robot bot added area: performance Issues related to performance area: @angular/cli labels May 2, 2025
@sirTomasson sirTomasson changed the base branch from main to 19.2.x May 2, 2025 14:16
@sirTomasson sirTomasson changed the base branch from 19.2.x to main May 2, 2025 14:16
Copy link
Member

@clydin clydin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the scope to be @angular/build instead of @angular/cli?

Otherwise, LGTM.

Thank you for the contribution.

@clydin clydin added the target: patch This PR is targeted for the next patch release label May 2, 2025
When using esbuild, Angular sets up a custom file watcher using esbuilds metafile inputs. Esbuild will generate <define:KEY> entries see https://esbuild.github.io/try/#YgAwLjI1LjMALS1kZWZpbmU6Rk9PPSd7fScgLS1tZXRhZmlsZSAtLWJ1bmRsZQBlAGVudHJ5LmpzAGNvbnNvbGUubG9nKEZPTyk. After the build is finished, the file watcher will notice that the <define:KEY> entries no longer exist on the file system and trigger a rebuild even though no files have changed.
This change, fixes the above issue by filtering files starting with `<define:`.
@sirTomasson sirTomasson force-pushed the perf-unnecessary-esbuld-rebuilds branch from b4bfb44 to 85dc594 Compare May 3, 2025 08:53
@sirTomasson
Copy link
Contributor Author

I changed the scope to @angular/build.

@jkrems jkrems added the action: merge The PR is ready for merge by the caretaker label May 3, 2025
@jkrems jkrems merged commit f73e3a3 into angular:main May 3, 2025
32 checks passed
@jkrems
Copy link
Contributor

jkrems commented May 3, 2025

The changes were merged into the following branches: main, 19.2.x, 20.0.x

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jun 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build area: @angular/cli area: performance Issues related to performance target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants