Commit graph

4800 commits

Author SHA1 Message Date
Alan Agius
1c30234d24 ci: update dev-infra github actions to latest SHA (#63640)
This commit updates all usages of `angular/dev-infra/github-actions` to their latest SHA.
This is necessary to ensure that all workflows are using the most up-to-date versions of the actions,
which can include bug fixes, performance improvements, or new features.

PR Close #63640
2025-09-09 10:46:27 -07:00
Alan Agius
9d1fb33f5e fix(core): introduce BootstrapContext for improved server bootstrapping (#63640)
This commit introduces a number of changes to the server bootstrapping process to make it more robust and less error-prone, especially for concurrent requests.

Previously, the server rendering process relied on a module-level global platform injector. This could lead to issues in server-side rendering environments where multiple requests are processed concurrently, as they could inadvertently share or overwrite the global injector state.

The new approach introduces a `BootstrapContext` that is passed to the `bootstrapApplication` function. This context provides a platform reference that is scoped to the individual request, ensuring that each server-side render has an isolated platform injector. This prevents state leakage between concurrent requests and makes the overall process more reliable.

BREAKING CHANGE:
The server-side bootstrapping process has been changed to eliminate the reliance on a global platform injector.

Before:
```ts
const bootstrap = () => bootstrapApplication(AppComponent, config);
```

After:
```ts
const bootstrap = (context: BootstrapContext) =>
  bootstrapApplication(AppComponent, config, context);
```

A schematic is provided to automatically update `main.server.ts` files to pass the `BootstrapContext` to the `bootstrapApplication` call.

In addition, `getPlatform()` and `destroyPlatform()` will now return `null` and be a no-op respectively when running in a server environment.

(cherry picked from commit 8bf80c9d2314b4f2bcf3df83ae01552a6fc49834)

PR Close #63640
2025-09-09 10:46:27 -07:00
Matthieu Riegler
06d70a25ea fix(migrations): take care of tests that import both HttpClientModule & HttpClientTestingModule. (#58777)
While having both `HttpClientModule` & `HttpClientTestingModule` serves no real purpose (`HttpClientTestingModule` imports `HttpClientModule`), some code bases can have those 2 together and the migration can be quite breaking.

fixes #58536

PR Close #58777
2024-11-22 14:47:12 +00:00
Kristiyan Kostadinov
5f2d98a1b1 fix(core): avoid slow stringification when checking for duplicates in dev mode (#58521)
When we check for duplicates in dev mode, we end up stringifying an `LView` even if we don't report an error. This can be expensive in large views.

These changes work around the issue by only generating the string when we have an error to throw.

Fixes #58509.

PR Close #58521
2024-11-06 13:02:35 +01:00
Kristiyan Kostadinov
3aa45a2fa1 fix(core): resolve forward-referenced host directives during directive matching (#58492) (#58500)
When the compiler generates the `HostDirectivesFeature`, it generates either an eager call (`ɵɵHostDirectivesFeature([])`) or a lazy call (`ɵɵHostDirectivesFeature(() => [])`. The lazy call is necessary when there are forward references within the `hostDirectives` array. Currently we resolve the lazy variant when the component definition is created which has been enough for most cases, however if the host is injected by one of its host directives, we can run into a reference error because DI is synchronous and the host's class hasn't been defined yet.

These changes resolve the issue by pushing the lazy resolution later during directive matching when all classes are guanrateed to exist.

Fixes #58485.

PR Close #58492

PR Close #58500
2024-11-04 17:18:52 +01:00
Kristiyan Kostadinov
ddda3558ca refactor(core): remove globalApi tag (#58375)
`@globalApi` was an AIO implementation detail that isn't relevant anymore.

PR Close #58375
2024-10-28 12:33:53 -07:00
cexbrayat
37b921dcde refactor(core): test EventEmitter completion on destroy with outputToObservable (#58239)
A unit test has been added to check that `EventEmitter` properly completes upon component/directive destrouction when used with `outputToObservable`.
It explains why `destroyRef` has to be injected in `EventEmitter` in the first place.

PR Close #58239
2024-10-17 11:37:58 +00:00
Matthieu Riegler
a9e440d96b refactor(core): drop the Mutable utility type. (#58124)
The complexity of this type isn't necessary, `Writable` is well suited where it was used.

PR Close #58124
2024-10-10 10:47:51 +00:00
cexbrayat
31fb9d0d52 docs: mention autoDetectChanges parameter default value (#58092)
It was unclear whether the parameter was necessary, as its default value was not mentioned in the jdsoc.

PR Close #58092
2024-10-09 13:50:32 +00:00
Krzysztof Platis
b40875a2cc fix(platform-server): destroy PlatformRef when error happens during the bootstrap() phase (#58112) (#58135)
The `bootstrap()` phase might fail e.g. due to an rejected promise in some `APP_INIIALIZER`.
If `PlatformRef` is not destroyed, then the main app's injector is not destroyed and therefore `ngOnDestroy` hooks of singleton services is not called on the end (failure) of SSR.

This could lead to possible memory leaks in custom SSR apps, if their singleton services' `ngOnDestroy` hooks contained an important teardown logic (e.g. unsubscribing from RxJS observable).

Note: I needed to fix by the way another thing too: now we destroy `moduleRef` when `platformInjector` is destroyed - by setting a `PLATFORM_DESTROY_LISTENER`

Patch port of #58112

PR Close #58135
2024-10-09 13:50:02 +00:00
Kristiyan Kostadinov
46bafb0b0a fix(core): clean up afterRender after it is executed (#58119)
We stop tracking `afterRender` hooks as soon as they execute, but their on destroy callbacks stay registered until either the injector is destroyed or the user calls `destroy` manually. This was leading to memory leaks in the `@defer` triggers based on top of `afterRender` when placed inside long-lived views, because the callback would execute, but its destroy logic was waiting for the view to be destroyed.

These changes resolve the issue by destroying the `AfterRenderRef` once it is executed.

PR Close #58119
2024-10-08 13:27:07 -07:00
Matthieu Riegler
9ca9db4f74 refactor(core): drop ViewRefTracker in favor of ApplicationRef. (#58096)
We can leverage an `import type` to prevent the circular import.

PR Close #58096
2024-10-08 13:25:24 -07:00
arturovt
46a2ad39f5 fix(common): prevent warning about oversize image twice (#58021)
I’ve noticed that there was a loop inside a loop. Since we’re already iterating through
`images` using `forEach`, it was running a `for` loop through `images` again. This was
probably a mistake made when the functionality was initially added. The test actually
verified that `logs.length` is `1`, but in the real environment, it logs twice
(which is quite obvious due to the code).

I’ve also added the missing file to the Bazel target.

PR Close #58021
2024-10-02 11:46:18 +00:00
Kristiyan Kostadinov
b9d846dad7 fix(migrations): delete constructor if it only has super call (#58013)
Adds some logic to the `inject` migration that will remove constructors that are made up of only a `super` call after the migration.

PR Close #58013
2024-09-30 13:39:43 -07:00
arturovt
8f2b0ede59 fix(common): skip checking whether SVGs are oversized (#57966)
Prior to this commit, the `ImagePerformanceWarning` class was checking all `img`
elements in the DOM to determine whether they were oversized after the DOM loading
was complete. We should not check SVGs because they are vector-based and can scale
infinitely without losing quality.

Closes #57941

PR Close #57966
2024-09-30 13:28:46 -07:00
Kristiyan Kostadinov
2f347ef8fc fix(core): provide flag to opt into manual cleanup for after render hooks (#57917)
Adds a `manualCleanup` flag to `afterRender` and `afterNextRender`, similarly to `effect`. The reason is that currently if the hook is created outside of an injection context, it requires an injector to be passed in. In some cases that injector might be an injector that is never destroyed (e.g. `EnvironmentInjector`) which can give a false sense of security users thinking that the hook will be cleaned up automatically. We fell into this in the CDK which caused a memory leak (see https://github.com/angular/components/pull/29709). With the `manualCleanup` option users explicitly opt into cleaning the hook up themselves.

PR Close #57917
2024-09-26 14:20:55 -07:00
Thomas Nguyen
2e7cfcb2ef refactor(core): Remove global event delegation code. (#57893)
This is no longer needed since we are no longer experimenting with it.

PR Close #57893
2024-09-26 14:18:18 -07:00
Alex Rickabaugh
e40a4fa3c7 fix(upgrade): support input signal bindings (#57020)
`@angular/upgrade` writes to inputs when downgrading an Angular 2+ component
into an Angular.JS adapter. Previously, it wrote directly to the input
property, which isn't compatible with input signals. It also handles
`ngOnChanges` directly.

The correct way to support input signals would be to refactor upgrade to use
`ComponentRef.setInput`, which also handles `ngOnChanges` internally.
However, this refactoring might be more breaking since it would change the
timing of certain operations. Instead, this commit updates the code to
recognize `InputSignal` and write it through the `InputSignalNode`. This
avoids the above breaking changes for now, until a bigger refactoring can be
tested.

Fixes #56860.

PR Close #57020
2024-09-26 14:14:15 -07:00
Joey Perrott
03ac3c299d refactor: update license text to point to angular.dev (#57902)
Update license text to point to angular.dev instead of angular.io

PR Close #57902
2024-09-24 15:28:46 +02:00
ChinoUkaegbu
c6b86357f6 docs(core): update wording in ComponentDecorator (#57878)
PR Close #57878
2024-09-23 11:59:08 +02:00
Matthieu Riegler
76709d5d6e fix(core): Handle @let declaration with array when preparingForHydration (#57816)
Before this commit, `@let` decleration with an array where  mistaken for a component in the lView and throwing an unexpected error.

This commit fixes this.

PR Close #57816
2024-09-17 16:29:40 +02:00
Kristiyan Kostadinov
5c866942a1 fix(migrations): account for explicit standalone: false in migration (#57803)
Fixes that the standalone migration was duplicating the `standalone` flag if the declaration was `standalone: false`.

PR Close #57803
2024-09-13 10:48:42 +02:00
Kristiyan Kostadinov
9895e4492f fix(migrations): replace leftover modules with their exports during pruning (#57684)
Currently during the module pruning stage of the standalone migration we assume that any leftover modules which only have `imports` and `exports` can safely be removed. That can be incorrect for the cases where some parts of the app were converted to standalone outside of the migration.

These changes update the logic so that such modules are replaced with the `exports` which are used within the specific component.

Fixes #51420.

PR Close #57684
2024-09-06 14:15:50 +00:00
Matthieu Riegler
09f2ec0a12 refactor(compiler-cli): Do extract symbols from private modules. (#57611)
Modules like `core/primitives` are considered private and their symbols shouldn't be exposed nor linked in the docs.

PR Close #57611
2024-09-06 14:15:19 +00:00
Matthieu Riegler
93bdbbc812 docs(docs-infra): Add dev-mode only mention for core/global (#57365)
PR Close #57365
2024-08-29 10:17:35 -07:00
Paul Gschwendtner
d9c1004a35 refactor(migrations): ensure control flow analysis of signal input migration works with all TS versions (#57566)
Ensures that the control flow analysis version of the signal input works
with all TS versions currently supported.

PR Close #57566
2024-08-29 07:51:39 -07:00
Paul Gschwendtner
bb29c8bbd7 refactor(migrations): cleanup TODOs in signal input migration (#57566)
Cleans up remaining TODOs in the signal input migration, and other
small clean ups.

PR Close #57566
2024-08-29 07:51:38 -07:00
Matthieu Riegler
3b7162d03c docs: Add mention to ENVIRONMENT_INITIALIZER (#57464)
Explicitly mention that `ENVIRONMENT_INITIALIZER` should not be async.

PR Close #57464
2024-08-29 07:43:48 -07:00
Vlad Boisa
3bc28678fa docs(docs-infra): remove hash before link (#57351)
Remove hash in link for correct view

Fixes #57349

docs(docs-infra): change the link

Change the link with name of class and method

docs: fix the link name

PR Close #57351
2024-08-29 07:42:13 -07:00
Paul Gschwendtner
36aa3af77b refactor(migrations): forward-fix conflicts with generic of ProgramInfo. (#57565)
One PR removed the generic of `ProgramInfo`, while another PR,
separately merged, introduced new instanes of `ProgramInfo`.

PR Close #57565
2024-08-28 09:17:34 -07:00
Paul Gschwendtner
389933f079 refactor(migrations): allow tsurge migrations to run with just NgCompiler (#57562)
This is important so that migrations can easily be wired up in the
language service where only `NgCompiler` is available.

PR Close #57562
2024-08-28 08:47:46 -07:00
Paul Gschwendtner
b14c864170 refactor(migrations): properly handle multi query migration (#57556)
Properly handles queries with multiple results, by extracting the
type from the `QueryList`.

Also adds more tests and handles imports.

PR Close #57556
2024-08-28 08:43:39 -07:00
Paul Gschwendtner
10fce207e0 refactor(migrations): initial migration logic for converting to signal queries (#57556)
Adds initial migration logic to convert decorator query declarations to
signal queries.

We will re-use more part of the signal input migration in follow-ups, to
properly migrate, and e.g. even handle control flow

PR Close #57556
2024-08-28 08:43:38 -07:00
Alex Rickabaugh
eba3a0ade0 Revert "refactor(migrations): initial migration logic for converting to signal queries (#57525)" (#57555)
This reverts commit 6f5b435a69.

Reason: breaks g3

PR Close #57555
2024-08-27 14:03:06 -07:00
Alex Rickabaugh
3d48a72193 Revert "refactor(migrations): properly handle multi query migration (#57525)" (#57555)
This reverts commit f454ad3bcf.

Reason: breaks g3

PR Close #57555
2024-08-27 14:03:06 -07:00
Kristiyan Kostadinov
df42d2be16 test: avoid leaking some LViews in tests (#57546)
We had some tests that were leaking LViews, because we were testing things like `createComponent`, but not destroying them afterwards. These changes clean up most of them, although there are a handful still left that I didn't have time to fully track down.

PR Close #57546
2024-08-27 13:29:09 -07:00
Kristiyan Kostadinov
106917af87 fix(core): avoid leaking memory if component throws during creation (#57546)
When we create the LView for a component, we track it in the `TRACKED_LVIEWS` map. It gets untracked when it is destroy, but if it throws during creation, the user won't have access to a `ComponentRef` in order to clean it up.

These changes automatically untrack the related LViews if the component couldn't be created.

PR Close #57546
2024-08-27 13:29:09 -07:00
Alan Agius
b74b5f0c06 build: remove Sourcemaps from Schematics bundles (#57545)
This commit reduces the bundle size of `@angular/core` by 19.5 MB by excluding sourcemaps from the schematics.

Since the `esbuild` rule doesn't allow disabling sourcemaps directly, we work around this by setting the sourcemaps to `external`. Afterward, we filter the output to include only the `.js` files.

PR Close #57545
2024-08-27 13:27:33 -07:00
Paul Gschwendtner
6a953c6ed4 refactor(migrations): properly handle multi query migration (#57525)
Properly handles queries with multiple results, by extracting the
type from the `QueryList`.

Also adds more tests and handles imports.

PR Close #57525
2024-08-27 13:20:19 -07:00
Paul Gschwendtner
01cae95596 refactor(migrations): initial migration logic for converting to signal queries (#57525)
Adds initial migration logic to convert decorator query declarations to
signal queries.

We will re-use more part of the signal input migration in follow-ups, to
properly migrate, and e.g. even handle control flow

PR Close #57525
2024-08-27 13:20:19 -07:00
Thomas Nguyen
6d3a2af146 fix(core): Do not bubble capture events. (#57476)
These should only fire if the target is the same as the targetElement. Also, delete an out of date test since capture/non-capture tests are separately covered.

PR Close #57476
2024-08-23 14:46:55 -07:00
Paul Gschwendtner
223b7857ef refactor(migrations): replacements in tsurge are always serializable (#57501)
This removes an unnecessary type wrapping that can be removed because
`Replacements` is expected to be serializable by default.

Similar to how it's done in `TsurgeComplexMigration`.

PR Close #57501
2024-08-23 13:49:31 -07:00
Alex Rickabaugh
6059ca8f1f refactor(core): restructure AfterRenderManager to connect related phases (#57453) (#57504)
The `afterRender` infrastructure was first implemented around the idea of
independent, singular hooks. It was later updated to support a spec of
multiple hooks that pass values from one to another as they execute, but the
implementation still worked in terms of singular hooks under the hood. This
creates a number of maintenance issues, and a few bugs. For example, when
one hook fails, further hooks in the pipeline should no longer execute, but
this was hard to ensure under the old design.

This refactoring restructures `afterRender` infrastructure significantly to
introduce the concept of a "sequence", a collection of hooks of different
phases that execute together. Overall, the implementation is simplified
while making it more resilient to issues and future use cases, such as the
upcoming `afterRenderEffect`.

As part of this refactoring, the `internalAfterNextRender` concept is
removed, as well as the unused `queueStateUpdate` concept which used it.

PR Close #57453

PR Close #57504
2024-08-23 12:48:01 -07:00
Alex Rickabaugh
800f6c8ca3 refactor(core): track dirtiness bits in ApplicationRef (#57453) (#57504)
Previously the zoneless scheduler had a concept of whether views needed to
be refreshed or not, based on the notification type that was received. It
tracked this information as a boolean.

This commit refactors things to track dirtiness in `ApplicationRef` itself,
as a `dirtyFlags` field with bits corresponding to either view tree
dirtiness or after-render hooks.

PR Close #57453

PR Close #57504
2024-08-23 12:48:01 -07:00
Paul Gschwendtner
87c594b90b refactor(migrations): add support for simpler variant of tsurge migration (#57484)
Introduces a simpler, smaller variant of the current `Tsurge` migration
class. The difference is simply that for the migration phase (the third
stage), some migrations do not need a full set of workers re-analyzing
every compilation unit again to compute the "final migration
replacements".

This can be the case, for example, if a migration eagerly computes all
replacements in the analyze stage, visiting every unit, and then after
deriving the global metadata, problematic replacements are simply
filtered (e.g. via some unique IDs again).

PR Close #57484
2024-08-23 12:01:59 +00:00
Paul Gschwendtner
f133489a16 refactor(migrations): clean up unused google3 code from signal input migration (#57484)
The code was replaced by the automatic Tsurge batch runner. This commit
cleans up the now unused code.

PR Close #57484
2024-08-23 12:01:59 +00:00
Paul Gschwendtner
df3e9c1661 refactor(migrations): leverage tsurge for signal input migration (#57451)
This commit simplifies the batching support for the signal input
migration by using the new tsurge framework we've built.

This allows for consistent setup across all possible entry-points and
also simplifies the 1P setup given that we can simply use the Tsurge
macros, instead of having to maintain our own Go-based runner.

PR Close #57451
2024-08-19 22:44:43 -07:00
Paul Gschwendtner
cb7d817edd refactor(migrations): improve generic assignability in tsurge and pass more info (#57451)
* Improves some of the generic assignability for tsurge. Anything is
  allowed to be returned from an overridden `prepareProgram` method.
  This is useful for the signal input migration.
* Passes the absolute root paths to migrations. This is helpful for the
  signal input migration and there is no other way to access it. It's
  better to pass specifically, compared to passing the whole unsafe
  `ParsedConfiguration` object.

PR Close #57451
2024-08-19 22:44:43 -07:00
Paul Gschwendtner
57db366522 refactor(migrations): framework to build batchable migrations (#57396)
Introduces a migration framework to build batchable migrations that
can run in Large Scale mode against e.g. all of Google, using workers.

This is the original signal input migration infrastructure extracted
into a more generic framework that we can use for writing additional
ones for output, signal queries etc, while making sure those are not
scoped to a single `ts.Program` that limits them to per-directory
execution in very large projects (e.g. G3).

The migration will be updated to use this, and in 1P we will add
helpers to easily integrate such migrations into a Go-based pipeline
runner.

PR Close #57396
2024-08-17 08:54:16 -05:00
vladboisa
4bd9ba714c docs(docs-infra): move link tag for correct view (#57395)
Move the link tag to the down, for correctly parsing of '@link'

Fixes #57332

PR Close #57395
2024-08-15 15:51:53 -04:00