Commit graph

29561 commits

Author SHA1 Message Date
Andrew Scott
589b66b379 Revert "build: update ts_library to produce ES2022 (#49332)" (#49554)
This reverts commit 262c989c81.

PR Close #49554
2023-03-22 14:34:25 -07:00
Andrew Scott
e917a81771 Revert "build: force benchpress to be compiled with ES2020 (#49332)" (#49554)
This reverts commit 132c00c2f8.

PR Close #49554
2023-03-22 14:34:25 -07:00
Alan Agius
132c00c2f8 build: force benchpress to be compiled with ES2020 (#49332)
Benchpress requires a decent amount of work to be ES2022 compliant. This will be done in a followup PR.

PR Close #49332
2023-03-22 14:00:20 -07:00
Alan Agius
262c989c81 build: update ts_library to produce ES2022 (#49332)
This commit patches `ts_library` to be able to produce `ES2022`. Also, updates the build tsconfig and sets `useDefineForClassFields` to `false` to keep the same behaviour of `ng_module`.

PR Close #49332
2023-03-22 14:00:20 -07:00
Alan Agius
9c3f8d52d8 ci: disable system js tests (#49332)
These are currently broken due to the APF v16 changes which dropped support for ES2015.

PR Close #49332
2023-03-22 14:00:20 -07:00
Alan Agius
4d89696285 test: remove google-closure-compiler from tests (#49332)
google-closure-compiler does not support ES2022

(cherry picked from commit 54365418bb8388ffa9b6388ae438e4d6ac4e081d)

PR Close #49332
2023-03-22 14:00:20 -07:00
Alan Agius
349ff01c4b refactor: update code to be ES2022 compliant (#49332)
This commit updates parts of the FW to be ES2022 complaint.

These changes are needed to fix the following problems problems with using properties before they are initialized.

Example
```ts
class Foo {
   bar = this.buz;
   constructor(private buz: unknown){}
}
```

PR Close #49332
2023-03-22 14:00:19 -07:00
Alan Agius
842d569a94 feat(bazel): (APF) Angular Package Format updates (#49332)
Several updates to Angular Package Format.

BREAKING CHANGE:

Several changes to the Angular Package Format (APF)
- Removal of FESM2015
- Replacing ES2020 with ES2022
- Replacing FESM2020 with FESM2022

PR Close #49332
2023-03-22 14:00:19 -07:00
Andrew Scott
0dd5c47811 release: cut the v16.0.0-next.4 release 2023-03-22 13:28:34 -07:00
Andrew Scott
c6d8e5fef4 docs: release notes for the v15.2.4 release 2023-03-22 13:22:22 -07:00
Jessica Janiuk
0851bd5283 refactor(core): Improve hydration error handling (#49502)
This adds user friendly error messages outlining exactly where hydration
mismatches occur and what was expected with easy to read stringified
DOM. It also includes a pointer to exactly where the mismatch happened
and lets the user know what was expected.

PR Close #49502
2023-03-22 11:47:41 -07:00
Andrew Kushnir
8ea1fb7396 refactor(core): exclude disconnected nodes from hydration (#49471)
This commit updates the hydration logic to handle situations where DOM nodes might end up
being disconnected from the DOM tree. We serialize ids of those nodes into the hydration
state transfer data and use the information to switch from hydration to the regular "creation
mode" at runtime.

This situation may happen during the content projection, when some nodes don't make it
into one of the content projection slots (for example, when there is no default
<ng-content /> slot in projector component's template).

Note: we leverage the fact that we have this information available in the DOM emulation
layer (in Domino) for now. Longer-term solution should not rely on the DOM emulation and
only use internal data structures and state to compute this information.

PR Close #49471
2023-03-22 10:04:56 -07:00
Kristiyan Kostadinov
546b285ec1 fix(migrations): preserve trailing commas in code generated by standalone migration (#49533)
This is based on some internal feedback. Adds logic to the standalone migration that attempts to preserve trailing commas when updating existing AST nodes. When creating new ones, it tries to infer whether to generate the trailing comma based on the surrounding code.

PR Close #49533
2023-03-22 16:41:53 +01:00
Alan Agius
41f27ad086 refactor(platform-server): remove renderApplication overload that accepts a component (#49463)
This commit removes the `renderApplication` overload that accepts a root component as the first parameter.

BREAKING CHANGE:

`renderApplication` method no longer accepts a root component as first argument. Instead, provide a bootstrapping function that returns a `Promise<ApplicationRef>`.

Before
```ts
const output: string = await renderApplication(RootComponent, options);
```

Now
```ts
const bootstrap = () => bootstrapApplication(RootComponent, appConfig);
const output: string = await renderApplication(bootstrap, options);
```

PR Close #49463
2023-03-22 16:40:31 +01:00
Andrew Scott
ff9d3b0f02 refactor(router): Remove legacy url creation code (#49360)
This commit removes code for the old way of creating a `UrlTree`.

PR Close #49360
2023-03-22 16:37:01 +01:00
Angular Robot
60d71484fd build: update eslint dependencies to v5.56.0 (#49507)
See associated pull request for more information.

PR Close #49507
2023-03-22 16:23:56 +01:00
Peter Götz
ab0b3622a5 docs: remove ticks in code sample to generate components (#49525)
These ticks appear in the actual documentation and when copied verbatim while following the tutorial, running this command in the terminal simply does nothing.
PR Close #49525
2023-03-22 16:02:47 +01:00
Andrew Scott
69a6e09e7e refactor(router): Remove deprecated loadChildren file (#49504)
This file was used while migrations were happening internally. All code is now updated to the callback

PR Close #49504
2023-03-21 14:09:22 -07:00
Andrew Scott
0af891f391 refactor(router): Update router export location for deprecated interfaces (#49504)
Moving these exports to a separate file will allow easier local patches internally.

PR Close #49504
2023-03-21 14:09:22 -07:00
Andrew Scott
83f53aca1c refactor(core): Remove VE/Render3 aliases from ViewRef code (#49499)
These aliases were used while we needed to maintain compatibility with ViewEngine

PR Close #49499
2023-03-21 14:08:29 -07:00
Angular Robot
62871537d5 docs: update Angular CLI help [main] (#49523)
Updated Angular CLI help contents.

PR Close #49523
2023-03-21 20:34:13 +01:00
Alex Rickabaugh
c4d2a55c44 test: increase size tracking threshold to 5K / 5% (#49520)
This commit increases the threshold of payload size tracking tests from
500 bytes to 5,000 bytes, and from 1% to 5%. This is done to minimize merge
conflicts while still catching real regressions.

PR Close #49520
2023-03-21 20:30:04 +01:00
Andrew Kushnir
504bd992ce refactor(core): add a note that hydration for i18n blocks is not yet supported (#49497)
This commit updates the serialization logic to detect a situation when i18n was used for a template and throw an error to indicate that hydration for i18n blocks is not yet supported.

Hydration for i18n blocks will be added in follow up versions.

PR Close #49497
2023-03-21 19:28:41 +01:00
Andrew Kushnir
a94b66f432 refactor(core): avoid ngSkipHydration on nodes other than component host ones (#49500)
Angular Hydration uses Components as a hydration boundary, i.e. you can enable/disable hydration on per-component basis. This commit enforces that the `ngSkipHydration` can only be applied on component host nodes (an error if thrown otherwise).

PR Close #49500
2023-03-21 18:59:25 +01:00
Andrew Kushnir
a0c289cbac refactor(core): avoid repeated views in serialized data (#49475)
This commit updates the serialization logic to recognized similar repeated views and instead of including the same info over and over again, a special field is added to the serialized view object with a number of repetitions. The hydration logic also recognizes the flag and creates the necessary number of dehydrated views in a container.

This optimization should help minimize the amount of extra annotations required for cases like *ngFor with large number of items.

PR Close #49475
2023-03-21 18:40:29 +01:00
Andrew Kushnir
3ef5d87408 refactor(core): post-hydration cleanup of unclaimed views (#49455)
This commit adds a logic to remove all views that were not cleaimed during the hydration. The process is started once the ApplicationRef becomes stable on the client (which matches the timing of serialization on the server).

PR Close #49455
2023-03-21 18:17:41 +01:00
Andrew Kushnir
f30a4072cd refactor(core): store segment heads for empty comtainers (#49455)
This commit updates the logic to store references to the comment (anchor) node as a segment head, when a container is empty (no views). Previously, the logic verified whether a container is non-empty and only stored segment head in this case. The problem is that the ViewContainerRef later on uses the segment head to start the DOM lookup and as a result, the process can not be started, since we have `null`. Now the segment head reference would point to a comment node (the anchor node) and ViewContainerRef would be able to start the lookup process. For empty views, the segment head would become an anchor of the container (which is exactly what we need).

PR Close #49455
2023-03-21 18:17:41 +01:00
Andrew Kushnir
ced237693a refactor(core): adding hydration for content projection (#49454)
This commit adds serialization and hydration logic for content projection.

While hydration for regular elements relies on their location in the TNode tree, the content projection may move elements around, so in order to hydrate them correcty, the runtime needs some extra information. This commit adds a serialization logic that adds element locations (instructions on how to navigate to a particular element from another known location of other element) into the hydration state for the following cases:

- when a TNode is a first element in projection segment (other nodes are linked from that node)
- when a TNode's next sibling is different before and after projection (we serialize extra info about the template-based sibling)
- when a TNode's previous sibling was a content projection (i.e. `<ng-content>` slot), because we can not rely on the previous element in this case (projection happens at a later point)

PR Close #49454
2023-03-21 17:42:53 +01:00
Pawel Kozlowski
d1617c449d feat(core): allow removal of previously registered DestroyRef callbacks (#49493)
This change makes it possible to remove a previously registered destroy
callback - to do so it is enough to call the unregistration function
returned from the onDestroy method call.

PR Close #49493
2023-03-21 16:58:22 +01:00
Paul Gschwendtner
24b3e8f042 build: exclude draft PRs from triage queue (#49515)
Excludes draft PRs from triage queue. Note that we cannot use
`draft:false` as otherwise all issues would be filtered. Rather
we need to negate `draft:true` which matches non-draft PRs and
normal issues.

PR Close #49515
2023-03-21 16:40:48 +01:00
Angular Robot
f0f1e7dfa7 build: update scorecard action dependencies (#49508)
See associated pull request for more information.

PR Close #49508
2023-03-21 16:39:09 +01:00
Pawel Kozlowski
66f8ed15e8 refactor(core): adjust signature of the EffectRef (#49490)
Before this change the effect creation function was returning
an instance of the Effect interface with explicit destroy and
schedule operations. This commit makes the following changes
to the return type of effect:
- the interface is renamed from Effect to EffectRef;
- the only available method on this interface is destroy.

We want to tighten the interface in question so only a minimal
set of useful operations is initially exposed.

PR Close #49490
2023-03-21 15:51:42 +01:00
Paul Gschwendtner
e2d3da5c71 test: update i18n size golden to reflect main (#49514)
The `i18n` integration size test golden has been updated with
an increase 20hrs ago, but now with the recent Angular update,
it seems back to the previous size, a decrease in size.

https://github.com/angular/angular/pull/49495.

PR Close #49514
2023-03-21 15:18:13 +01:00
Paul Gschwendtner
ac6715a5c6 test: update AIO size golden to account for main increase (#49514)
The AIO main bundle has increased a little due to the recently
added hydration logic into the core runtime.

e.g. code like this: https://screenshot.googleplex.com/8CvRNMdkT3LqXg3

PR Close #49514
2023-03-21 15:18:13 +01:00
Angular Robot
1acf3ec84b build: update cross-repo angular dependencies (#49514)
See associated pull request for more information.

PR Close #49514
2023-03-21 15:18:13 +01:00
Alan Agius
53b2ea9451 refactor(platform-browser): remove private DomSharedStylesHost workaround (#49482)
This workaround is no longer needed as all usage of `DomSharedStylesHost` have been removed from Google3.

PR Close #49482
2023-03-21 13:56:02 +01:00
Pawel Kozlowski
81b9e858a8 Revert "refactor(core): adding hydration for content projection (#49454)" (#49511)
This reverts commit 7885f35fd6.

PR Close #49511
2023-03-21 13:51:14 +01:00
Andrew Kushnir
7885f35fd6 refactor(core): adding hydration for content projection (#49454)
This commit adds serialization and hydration logic for content projection.

While hydration for regular elements relies on their location in the TNode tree, the content projection may move elements around, so in order to hydrate them correcty, the runtime needs some extra information. This commit adds a serialization logic that adds element locations (instructions on how to navigate to a particular element from another known location of other element) into the hydration state for the following cases:

- when a TNode is a first element in projection segment (other nodes are linked from that node)
- when a TNode's next sibling is different before and after projection (we serialize extra info about the template-based sibling)
- when a TNode's previous sibling was a content projection (i.e. `<ng-content>` slot), because we can not rely on the previous element in this case (projection happens at a later point)

PR Close #49454
2023-03-21 09:44:03 +01:00
Thomas Pischke
6ad4b914cc docs: remove pipe in exponential backoff (#49494)
PR Close #49494
2023-03-21 07:58:05 +01:00
Thomas Pischke
191f3bf172 docs: update deprecated exponential backoff example (#49494)
PR Close #49494
2023-03-21 07:58:05 +01:00
Aditya Srinivasan
4b4e8619b7 docs: fix link ngFor documentation link (#49479)
Fix the `ngFor` API link under the "Structural directive shorthand" section
PR Close #49479
2023-03-21 07:56:38 +01:00
Alex Rickabaugh
84a2ad7b01 refactor(core): expose private setAlternateWeakRefImpl (#49466)
This commit adds the ability to override the `WeakRef` implementation used
by signals as a private API. This can be used in certain environments to
allow tests which use older browsers to still run, albeit without weak
references.

PR Close #49466
2023-03-20 12:32:20 -07:00
Kristiyan Kostadinov
897a9e578d build: update size golden (#49495)
Fixes a size golden that was out of date.

PR Close #49495
2023-03-20 17:35:30 +01:00
Masaoki Kobayashi
e655e8a603 fix(core): more accurate matching of classes during content projection (#48888)
Showing a minimum app to reproduce the bug.
1. Create the app and add angular material.
```
ng new project
cd project
ng add @angular/material
```
1. Overwrite the src/app/app.component.html with minimal content.
```
<button mat-button *ngIf="true"><span *ngIf="true" class="{{'a'}}"></span></button>
```
1. Run the app. The button is not shown because of an exception.
```
main.ts:6
ERROR TypeError: item.toLowerCase is not a function
    at isCssClassMatching (core.mjs:8726:35)
    at isNodeMatchingSelector (core.mjs:8814:22)
    at isNodeMatchingSelectorList (core.mjs:8931:13)
    at matchingProjectionSlotIndex (core.mjs:14179:13)
    at Module.ɵɵprojectionDef (core.mjs:14222:49)
    at MatButton_Template (button.mjs:113:99)
    at executeTemplate (core.mjs:10534:9)
    at renderView (core.mjs:10356:13)
    at renderComponent (core.mjs:11529:5)
    at renderChildComponents (core.mjs:10216:9)
```
Because isCssClassMatching() function does not take care if the value is not string, while attrs[] may contain AttributeMarker which is actually numbers, item.toLowerCase() throws the exception.
Just inserted a check if the item is string.

Created a testcase for the original fix. It causes an exception without the fix.

fix(core): add a check code to avoid an exception inside isCssClassMatching

Showing a minimum app to reproduce the bug.
1. Create the app and add angular material.
```
ng new project
cd project
ng add @angular/material
```
1. Add `import { MatButtonModule } from '@angular/material/button'`,
   and also MatButtonModule inside @NgModule imports in src/app/app.module.ts to use MatButtonModule.
1. Overwrite the src/app/app.component.html with minimal content.
```
<button mat-button *ngIf="true"><span *ngIf="true" class="{{'a'}}"></span></button>
```
1. Run the app. The button is not shown because of an exception.
```
main.ts:6
ERROR TypeError: item.toLowerCase is not a function
    at isCssClassMatching (core.mjs:8726:35)
    at isNodeMatchingSelector (core.mjs:8814:22)
    at isNodeMatchingSelectorList (core.mjs:8931:13)
    at matchingProjectionSlotIndex (core.mjs:14179:13)
    at Module.ɵɵprojectionDef (core.mjs:14222:49)
    at MatButton_Template (button.mjs:113:99)
    at executeTemplate (core.mjs:10534:9)
    at renderView (core.mjs:10356:13)
    at renderComponent (core.mjs:11529:5)
    at renderChildComponents (core.mjs:10216:9)
```
Because isCssClassMatching() function does not take care if the value is not string, while attrs[] may contain AttributeMarker which is actually numbers, item.toLowerCase() throws the exception.
Just inserted a check if the item is string.

PR Close #48888
2023-03-20 16:07:13 +01:00
avmaxim
d5946bdc97 docs(docs-infra): improve docs for @angular/localize package. (#49393)
This PR adds missing documentation for `@angular/localize` package and fixes a tiny one-word typo in the `README.md` file for `@angular/localize schematic`.

Fixes #49219.

PR Close #49393
2023-03-20 13:12:19 +01:00
Kristiyan Kostadinov
8f539c11f4 feat(compiler): add support for compile-time required inputs (#49468)
Adds support for marking a directive input as required. During template type checking, the compiler will verify that all required inputs have been specified and will raise a diagnostic if one or more are missing. Some specifics:
* Inputs are marked as required by passing an object literal with a `required: true` property to the `Input` decorator or into the `inputs` array.
* Required inputs imply that the directive can't work without them. This is why there's a new check that enforces that all required inputs of a host directive are exposed on the host.
* Required input diagnostics are reported through the `OutOfBandDiagnosticRecorder`, rather than generating a new structure in the TCB, because it allows us to provide a better error message.
* Currently required inputs are only supported during AOT compilation, because knowing which bindings are present during JIT can be tricky and may lead to increased bundle sizes.

Fixes #37706.

PR Close #49468
2023-03-20 13:10:30 +01:00
Matthieu Riegler
230345876c fix(core): Allow TestBed.configureTestingModule to work with recursive cycle of standalone components. (#49473)
When having a recursive circle of imports on standalone components, `queueTypesFromModulesArrayRecur` triggered a `Maximum call stack size exceeded` error.
This commit fixes this.

Fixes #49469

PR Close #49473
2023-03-20 10:02:15 +01:00
Virginia Dooley
686499aa95 docs: Send data to server - insert updated links. (#49447)
PR Close #49447
2023-03-20 08:49:20 +01:00
Matthieu Riegler
b4e1bfb9b0 docs: remove bazel builder section (#49423)
PR Close #49423
2023-03-20 08:48:42 +01:00
Andrew Scott
8d99ad0a39 Revert "feat(compiler): add support for compile-time required inputs (#49453)" (#49467)
This reverts commit 13dd614cd1.

This breaks a g3 Typescript compilation tests where diagnostics are
expected for a missing input in the component.

PR Close #49467
2023-03-17 18:29:14 +01:00