Commit graph

102 commits

Author SHA1 Message Date
Andrew Scott
01fec33556 docs: Deprecate BootstrapOptions on bootstrapModule (#62690)
This deprecates `BootstrapOptions` since `NgZone` can now be configured
in the providers. This is a necessary step because when zoneless becomes
the default, developers will have to add ZoneJS via
`provideZoneChangeDetection` and that will override anything defined in
`BootstrapOptions`.

PR Close #62690
2025-08-06 11:19:45 +02:00
Jessica Janiuk
882522c1ad refactor(compiler): Tree shake Element Registry (#62682)
This creates a feature to detect usages of animate.leave and only enables the element removal registry when necessary

PR Close #62682
2025-07-23 09:37:16 -04:00
Jessica Janiuk
6b1f4b9e8b feat(core): add enter and leave animation instructions (#62682)
This adds the instructions to support enter and leave animations on nodes.

PR Close #62682
2025-07-23 09:37:16 -04:00
Andrew Scott
971981e1df fix(core): TestBed.tick should ensure test components are synchronized (#61382)
This ensures that `TestBed.tick` updates any components created with
`TestBed.createComponent`, regardless of whether autoDetectChanges is
on.

PR Close #61382
2025-05-21 15:02:52 +00:00
Matthieu Riegler
6c2fbad8a2 refactor(core): Improve NG0600 error message. (#60418)
This commit adds the mention of templates as illegal context to write signals.

fixes #60143

PR Close #60418
2025-04-22 16:35:38 +02:00
Matthieu Riegler
0b69b61929 fix(core): Flush animations when no component has been checked (#58089)
When Angular runs application synchronization automatically, animations
are now guaranteed to be flushed, regardless of whether change detection
was run on any components attached to `ApplicationRef`. This most
frequently affects animations related to component removal where the DOM
element for the component would previously not be removed due to
animations not being flushed

BREAKING CHANGE: Animations are guaranteed to be flushed when Angular
runs automatic change detection or manual calls to `ApplicationRef.tick`.
Prior to this change, animations would not be flushed in some situations
if change detection did not run on any views attached to the
application. This change can affect tests which may rely on the old
behavior, often by making assertions on DOM elements that should have
been removed but weren't because DOM removal is delayed until animations
are flushed.

fixes #58075

PR Close #58089
2025-04-09 11:12:54 -07:00
Doug Parker
0ae1889560 fix(core): run ApplicationRef.prototype.bootstrap in NgZone (#60720)
`bootstrapApplication` always creates the root component in the `NgZone`, however `ApplicationRef.prototype.bootstrap` historically did not, meaning that if users did not go out of their way to call `ngZone.run(() => appRef.bootstrap(SomeComp))`, components would not run change detection correctly.

This commit updates `ApplicationRef.prototype.bootstrap` to _always_ run within `NgZone`, removing this hazard and ensuring components always run CD as expected.

PR Close #60720
2025-04-07 11:32:31 -07:00
Andrew Kushnir
491818f51f docs: mark REQUEST and related symbols as stable (#60717)
This commit removes the `@developerPreview` annotation from the `REQUEST`, `RESPONSE_INIT` and `REQUEST_CONTEXT` symbols, making them stable.

PR Close #60717
2025-04-03 13:04:23 -07:00
Doug Parker
2348f26d8a refactor(core): add ApplicationRef.prototype.bootstrapImpl with an injector parameter (#60622)
This is a roll forward of commit d5a8a1c524. Nothing is meaningfully different, as we're trying again to see if the CI failure is reproducible.

PR Close #60622
2025-04-03 10:48:01 -07:00
Matthieu Riegler
1c1ad12ad3 refactor(core): Instantiate the ErrorHandler lazily. (#58984)
This change prevents that user code in a custom `ErrorHandler` to run as part of `ApplicationRef`'s creation.

fixes #58970

PR Close #58984
2025-04-02 19:20:50 +00:00
arturovt
1c7b356625 fix(core): release hasPendingTasks observers (#59723)
In this commit, we unsubscribe the `hasPendingTasks` subject to remove all active observers and enable granular garbage collection, as users may forget to unsubscribe manually when subscribing to `isStable`.

PR Close #59723
2025-04-02 18:26:06 +00:00
Jessica Janiuk
d5a8a1c524 Revert "refactor(core): add ApplicationRef.prototype.bootstrapImpl with an injector parameter (#60622)" (#60669)
This reverts commit 7cb8639da9.

PR Close #60669
2025-04-01 12:18:52 +00:00
Doug Parker
7cb8639da9 refactor(core): add ApplicationRef.prototype.bootstrapImpl with an injector parameter (#60622)
This allows any components individually bootstrapped to inherit from a unique `Injector`. This is useful when bootstrapping multiple root components with different providers.

For now, the function is private while we explore potential designs to consolidate it with the existing `ApplicationRef.prototype.bootstrap` method.

PR Close #60622
2025-04-01 12:01:00 +00:00
Andrew Kushnir
152261cd34 refactor(core): produce a message about @defer behavior when HMR is enabled (#60533)
When the HMR is enabled in Angular, all `@defer` block dependencies are loaded
eagerly, instead of waiting for configured trigger conditions. From the DX perspective,
it might be seen as an issue when all dependencies are being loaded eagerly. This commit
adds a logic to produce a message into the console to provide more info for developers.

PR Close #60533
2025-03-28 15:00:32 +00:00
Andrew Kushnir
3d2263cb1f refactor(core): convert scripts within packages/core/src to relative imports (#60227)
This commit updates scripts within `packages/core/src` to relative imports as a prep work to the upcoming infra updates.

PR Close #60227
2025-03-25 10:58:00 -07:00
arturovt
526268c262 refactor(core): inline standalone check to be dropped (#60305)
Inlines `standalone` check into the message to be dropped.

PR Close #60305
2025-03-11 13:01:43 -07:00
Andrew Scott
338818ce89 fix(core): Surface errors from ApplicationRef.tick to callsite (#60102)
This commit ensures that errors during `ApplicationRef.tick` are
surfaced to the callsite rather than being caught and reported to the
`ErrorHandler`.

The current catch and report approach was originally
added in e263e19a2a
with the goal of preventing automatic change detection crashes due to
the error happening in the subscription. However, this results in hiding
a public API that can hide errors. Callers cannot assume that the tick
was successful and perform follow-up work.

This change now surfaces errors and adds the error handling directly to
the callsites.

BREAKING CHANGE: `ApplicationRef.tick` will no longer catch and report
errors to the appplication `ErrorHandler`. Errors will instead be thrown out of
the method and will allow callers to determine how to handle these
errors, such as aborting follow-up work or reporting the error and
continuing.

PR Close #60102
2025-03-10 08:17:14 -07:00
hawkgs
2b114e784d docs(docs-infra): API doc content rendering fixes (#60116)
The PR introduces a few doc content rendering fixes:
- Fix highlighted section heading styles (regression from #59965).
- Convert JSDoc links within 'Usage Notes' sections to HTML and render them.
- Add IDs to doc content headings. This, by itself, makes these headings available in the page ToC.

PR Close #60116
2025-03-04 17:46:30 +00:00
Andrew Scott
491b0a4ead fix(core): Remove duplicate reporting of errors in CDR.detectChanges (#60056)
This change removes the reporting of errors from the
`ChangeDetectorRef.detectChanges` API. The reporting results in the
error being "handled" in two ways, both by reporting to error handler
and rethrowing the error. This rethrown error generally ends up being
caught further up and again reported to the error handler. The error
handler is meant to be for uncaught errors, and since Angular is not at
the top of the stack of the call of `CDR.detectChanges`, it does not
know what is being done with the rethrown error.

Note that for zone-based applications, this will likely have no effect
other than removing duplicate reporting of the error. If the rethrown
error is not already being caught, it will reach the NgZone's error
trap and still be reported to the application `ErrorHandler`.

PR Close #60056
2025-02-25 12:20:22 -05:00
Miles Malerba
6789c7ef94 fix(core): Defer afterRender until after first CD (#59455) (#59551)
This reverts commit ac2dbe3eb1.

PR Close #59551
2025-02-12 12:20:04 -08:00
Miles Malerba
a299e02e91 fix(core): preserve tracing snapshot until tick finishes (#59796)
This change waits until the end of `tick` to clear the tracing snapshot.
This ensures that if we notify the scheduler during `tick` the correct
tracing snapshot is used.

PR Close #59796
2025-02-05 09:00:49 -08:00
Andrew Scott
ad88304233 refactor(core): move callAndReportToErrorHandler to bootstrap file (#59793)
This function is only used in the bootstrap file and does not need to be in application_ref

PR Close #59793
2025-02-03 13:54:40 -08:00
hawkgs
b9155b5121 docs: set syntax highlighting to the remaining Markdown code examples blocks (#59088)
There are some code blocks that slipped through the initial Regex-es.

Related to #59026

PR Close #59088
2025-01-14 15:14:02 -05:00
Pawel Kozlowski
815f1b1457 refactor(core): add profiler calls for tne newly introduced events (#59233)
The set of profiler events was recently extended. This commit plugs
newly created events dispatch into the approriate places
of the Angular core.

PR Close #59233
2025-01-14 12:35:21 -05:00
Andrew Kushnir
e77df14620 Revert "refactor(core): add profiler calls for tne newly introduced events (#59233)" (#59506)
This reverts commit 435d31ed5f.

PR Close #59506
2025-01-13 17:03:36 -05:00
Pawel Kozlowski
435d31ed5f refactor(core): add profiler calls for tne newly introduced events (#59233)
The set of profiler events was recently extended. This commit plugs
newly created events dispatch into the approriate places
of the Angular core.

PR Close #59233
2025-01-13 10:52:19 -05:00
Andrew Kushnir
ac2dbe3eb1 Revert "fix(core): Defer afterRender until after first CD (#58250)" (#59455)
This reverts commit 9870b643bf.

PR Close #59455
2025-01-09 14:30:01 -05:00
arturovt
205330d46a refactor(core): drop platform injection token names in production (#59400)
In this commit, we tree-shake the injection token names in production.

PR Close #59400
2025-01-09 12:28:17 -05:00
Miles Malerba
9870b643bf fix(core): Defer afterRender until after first CD (#58250)
For `afterRender`/`afterNextRender` calls associated with a particular
view, ensure that they are not registered until after the first time the
view is rendered.

Co-authored-by: Alex Rickabaugh <alxhub@users.noreply.github.com>

PR Close #58250
2025-01-08 15:33:38 +00:00
arturovt
206229df10 refactor(core): tree-shake ApplicationRef.warnIfDestroyed (#59269)
In this commit, we replace `private warnIfDestroyed` with a `warnIfDestroyed` function that can
be completely removed in production. This change is necessary because, with `private warnIfDestroyed`,
the empty method is still retained in production, even though it has no body.

PR Close #59269
2025-01-06 17:28:10 +00:00
Kristiyan Kostadinov
c9b8319774 refactor(core): allow tracing service to wrap event listeners (#59134)
Allows the tracing service to wrap event listeners bound by the framework.

PR Close #59134
2024-12-12 14:52:42 -08:00
hawkgs
0513fbc9fc docs: set syntax highlighting of code examples MD code blocks (#59026)
Set the syntax highlighting based on the code examples' language.

PR Close #59026
2024-12-04 17:30:28 +01:00
arturovt
a4b86b23cf refactor(core): preventing resolving renderer factory every tick (#58618)
Prevents the `RendererFactory2` from being resolved each time the tick runs, as it only needs to be requested once.

PR Close #58618
2024-11-28 15:17:28 +01:00
arielbackenroth
3b765367f3 fix(core): Explicitly manage TracingSnapshot lifecycle and dispose of it once it's been used. (#58929)
Provide a callback to the TracingService implementation when a Snapshot can be disposed.
The underlying tracing implementation may use refcounting and needs to release resources
to enable the trace to complete.

While change detection uses the snapshot for exactly one callback, after render runs
multiple hooks in the sequence so we need a more predictable way to indicate that the snapshot
can be finalized.s

PR Close #58929
2024-11-27 18:11:13 +01:00
Alan Agius
0499e1b27d refactor(core): remove private whenStable (#58891)
The `@angular/ssr` package no longer depends on this symbol.

PR Close #58891
2024-11-26 18:10:50 +00:00
arielbackenroth
785c6116cc fix(core): Ensure _tick is always run within the TracingSnapshot. (#58881)
Fix a bug where calls to _tick are called without running through the snapshot.
This helps ensure that all snapshots that are requested are resumed.

PR Close #58881
2024-11-25 21:19:52 +00:00
Andrew Kushnir
f6a84f0224 refactor(core): remove unused field in ApplicationRef class (#58864)
This commit removes an unused field in the `ApplicationRef` class. Most likely the usage of the field was removed earlier.

PR Close #58864
2024-11-25 16:12:37 +00:00
Andrew Kushnir
7f6f5f95ea refactor(core): use ApplicationRef.whenStable instead of a custom util function (#58834)
This commit removes a custom `whenStable` util in favor of standard `ApplicationRef.whenStable` API.

There is also an important different between the custom `whenStable` function and `ApplicationRef.whenStable` implementation: the `whenStable` was caching the "stable" promise on per-ApplicationRef basis, which resulted in unexpected behavior with zoneless, when some code ended up getting a stale resolved promise, when an application was not stable yet, this causing order of operations issues. This commit also has an extra test that covers that case.

PR Close #58834
2024-11-25 15:25:10 +00:00
Kristiyan Kostadinov
7eeae9f170 refactor(core): adjust tracing service (#58771)
Adjusts the tracing service based on internal requirements.

PR Close #58771
2024-11-21 16:34:53 +00:00
Alex Rickabaugh
d27f97ddab refactor(core): introduce TracingService for snapshot-based tracing (#58771)
This commit introduces a private API, the `TracingService` DI token. By
providing this token, Angular can be configured to capture tracing snapshots
for certain operations such as change detection notifications, and to run
downstream operations within the context of those snapshots.
`TracingService` abstracts this context propagation and makes it pluggable.

PR Close #58771
2024-11-21 16:34:53 +00:00
Andrew Kushnir
a55341b1ab refactor(core): add REQUEST, RESPONSE_INIT and REQUEST_CONTEXT tokens (#58669)
This commit introduces the `REQUEST`, `RESPONSE_INIT` and `REQUEST_CONTEXT` tokens, which will replace similar ones from 2850318623/packages/angular/ssr/tokens/src/tokens.ts, so those tokens would be imported in application code via `@angular/core` package.

PR Close #58669
2024-11-14 14:21:21 -08:00
Alan Agius
378284fa08 refactor(core): introduce ngServerMode as global (#58386)
This commit adds the `ngServerMode` as global, which allows for the tree-shaking of server-only code from the bundles. When this flag is unset at runtime, server-specific code will be excluded by Closure, optimizing bundle size.

**Internal Angular Flag:** This is an internal Angular flag (not a public API), avoid relying on it in application code.

PR Close #58386
2024-10-30 10:13:28 -07:00
Matthieu Riegler
5d9cc8f408 refactor(core): remove the standalone feature (#58288)
By removing the standalone feature, we reduce the amount of code generated for components but at the cost of including the `StandaloneService` in the main bundle even if no standalone components are included in it.

PR Close #58288
2024-10-24 16:19:02 -07:00
Pawel Fras
5fde27b8a4 refactor(core): fix deprecation version for APP_INITIALIZER and PLATFORM_INITIALIZER (#58322)
this commit changes deprecation version mentioned in JSDocs for APP_INITIALIZER and PLATFORM_INITIALIZER from 18.1.0 to 19.0.0

PR Close #58322
2024-10-23 08:01:28 -07:00
Younes Jaaidi
19edf2c057 feat(core): add syntactic sugar for initializers (#53152)
add helper functions provideAppInitializer, provideEnvironmentInitializer & providePlatformInitializer
to respectively simplify and replace the use of APP_INITIALIZER, ENVIRONMENT_INITIALIZER, PLATFORM_INITIALIZER

add a migration for the three initialiers

PR Close #53152
2024-10-22 09:38:18 -07:00
cexbrayat
ee426c62f0 fix(core): allow signal write error (#57973)
Now that effects allow to write to signals (see 4e890cc5ac),
the SIGNAL_WRITE_FROM_ILLEGAL_CONTEXT error is only thrown in `computed` functions.
This commit updates the error message to remove the mention of effects and of the deprecated `allowSignalWrites` option.

PR Close #57973
2024-10-04 13:27:00 +00:00
Joey Perrott
9dbe6fc18b refactor: update license text to point to angular.dev (#57901)
Update license text to point to angular.dev instead of angular.io

PR Close #57901
2024-09-24 15:33:00 +02:00
Andrew Scott
a1f229850a feat(core): migrate ExperimentalPendingTasks to PendingTasks (#57533)
This commit promotes the `ExperimentalPendingTasks` service from
experimental to developer preview and includes a migration schematic for
the rename.

BREAKING CHANGE: `ExperimentalPendingTasks` has been renamed to
`PendingTasks`.

PR Close #57533
2024-09-20 18:26:48 +02:00
Alex Rickabaugh
4e890cc5ac refactor(core): add support for new effect scheduling. (#56501)
The original effect design for Angular had one "bucket" of effects, which
are scheduled on the microtask queue. This approach got us pretty far, but
as developers have built more complex reactive systems, we've hit the
limitations of this design.

This commit changes the nature of effects significantly. In particular,
effects created in components have a completely new scheduling system, which
executes them as a part of the change detection cycle. This results in
behavior similar to that of nested effects in other reactive frameworks. The
scheduling behavior here uses the "mark for traversal" flag
(`HasChildViewsToRefresh`). This has really nice behavior:

 * if the component is dirty already, effects run following preorder hooks
   (ngOnInit, etc).
 * if the component isn't dirty, it doesn't get change detected only because
   of the dirty effect.

This is not a breaking change, since `effect()` is in developer preview (and
it remains so).

As a part of this redesigned `effect()` behavior, the `allowSignalWrites`
flag was removed. Effects no longer prohibit writing to signals at all. This
decision was taken in response to feedback / observations of usage patterns,
which showed the benefit of the restriction did not justify the DX cost.

The new effect timing is not yet enabled - a future PR will flip the flag.

PR Close #56501
2024-09-18 14:52:25 -07:00
Andrew Scott
122af30373 refactor(core): Merge autoDetectChanges behaviors between fixtures (#57416)
This commit updates the implementations of `autoDetectChanges` to be
shared between the zone-based and zoneless fixtures. This now allows
`autoDetect` to be turned off for zoneless fixtures after it was
previously on because the host view is no longer directly attached to
`ApplicationRef`.

PR Close #57416
2024-08-27 13:12:44 -07:00