Commit graph

11882 commits

Author SHA1 Message Date
JoostK
ec0d1bf6f3 fix(compiler-cli): insert constant statements after the first group of imports (#56431)
The linker inserts the constant statements that are needed to support compiled templates
after the import statements of an ESM file, but it failed to account for import statements
that are not at the top of the file. This is typically seen in FESM files where multiple
individual ESMs have been concatenated into a single ESM file, with imports in various places.
The linker would then find the very last import statement to insert the constant statements
after, but this may result in TDZ errors for component templates that have been emitted
earlier in the file.

This commit updates the Babel linker plugin to insert constant statements after the last
import of the first import group, therefore avoiding the TDZ error.

Fixes #56403

PR Close #56431
2024-06-13 10:15:02 -07:00
Paul Gschwendtner
571d06b6c3 refactor(compiler-cli): allow generating same import specifier in different files (#56406)
The import manager ensures generation of unique identifiers when
inserting imports. This is done by inspecting existing identifiers
within the original source file, while also checking if a similar
identifier was generated at an earlier time. This is correct behavior.

We can improve the detection so that the same identifier can be
generated in different files. This is beneficial for schematic/migration
use-cases where we wouldn't want to generate import aliases in multiple
files just because we generated an import to e.g. `input` previously.

E.g. it's fine to generate

```ts
// a.ts
import {input} from '@angular/core';

// b.ts
import {input} from `@angular/core';

// instead of `input as input_1`.

```

PR Close #56406
2024-06-13 10:14:11 -07:00
Paul Gschwendtner
ef660d1db2 refactor(compiler): expose shorthand object metadata in expression AST (#56405)
Whenever we parse object property assignment shorthands in expression
ASTs, the AST will have no information about whether the property read
for the `LiteralMap` is built based on the shorthand or not.

Exposing this information in the AST is useful for migrations as those
might need to decompose the shorthand into its longer form to e.g.
invoke a signal read.

PR Close #56405
2024-06-13 10:12:54 -07:00
Viktor T
34dc7007be docs: language-service - Fix quick info URLs (#56416)
- Made the links more specific
- Removed the AIO notation

PR Close #56416
2024-06-13 09:23:46 -07:00
Tom Wilkinson
247dce0023 refactor(core): Use ActionResolver in Dispatcher. (#56369)
`EventContract` usages in Angular now use `false` for
`useActionResolver`. Tests have been updated, with functionality that
depends on `ActionResolver` moving to dispatcher_test.ts.

PR Close #56369
2024-06-13 08:50:46 -07:00
Angular Robot
995b7fccc2 build: update babel dependencies to v7.24.7 (#56373)
See associated pull request for more information.

PR Close #56373
2024-06-12 13:11:13 -07:00
Andrew Kushnir
8b8fd167a2 refactor(core): inject PendingTasks as optional in EventEmitter class (#56411)
This commit makes `PendingTasks` dependency in the `EventEmitter` class optional to make sure this code works with various test setups.

PR Close #56411
2024-06-12 13:10:40 -07:00
arturovt
de2ed152a0 fix(zone.js): allow enabling default beforeunload handling (#55875)
Prior to this commit, when zone.js was included, it wasn't possible to handle `beforeunload`
events correctly if event handlers returned strings to prompt the user.

With this change, we introduce a global configuration flag,
`__zone_symbol__enable_beforeunload`, to allow consumers to enable the default
`beforeunload` handling behavior.

This flag is necessary to prevent any breaking changes resulting from this modification.
The previous attempt to fix it caused a large number of failures in G3. Hence, we're
hiding that fix behind the configuration flag.

Closes #47579

PR Close #55875
2024-06-12 13:06:21 -07:00
Andrew Scott
dbd0fa00f8 fix(core): async EventEmitter should contribute to app stability (#56308)
async `EventEmitter` should contribute to app stability.

fixes #56290

PR Close #56308
2024-06-11 15:10:21 -07:00
Andrew Scott
625ca3e2b3 fix(core): signals should be tracked when embeddedViewRef.detectChanges is called (#55719)
This commit fixes an issue where signals in embedded views are not
tracked if they are refreshed with `EmbeddedViewRef.detectChanges`
directly. We had previously assumed that embedded views were always
refreshed along with their hosts.

PR Close #55719
2024-06-11 12:35:03 -07:00
Matthieu Riegler
96135e8af9 refactor(compiler): Extract return type description (#56287)
Thie commit extracts return type description from the jsDoc.

Compiler part of #56277, will also need as dev-infra update.

PR Close #56287
2024-06-11 08:29:22 -07:00
Pawel Kozlowski
ebf00aa065 fix(benchpress): adjust supported browser names for headless chrome (#56360)
The chrome version controlled by selenium reports chrome-headless-shell in the
current setup. This fix accounts for the updated browser name.

PR Close #56360
2024-06-11 08:25:11 -07:00
Angular Robot
0a6f278a3e build: lock file maintenance (#56361)
See associated pull request for more information.

PR Close #56361
2024-06-10 13:54:12 -07:00
Kristiyan Kostadinov
c07e1b3356 fix(migrations): resolve error in standalone migration (#56302)
This is related to an issue that was reported internally. We were assuming that `hasNgModuleMetadataElements` will return true only for property assignments initialized to arrays, but that's not the case.

These changes update the type and our assertions to more accurately reflect the AST and to avoid the error.

PR Close #56302
2024-06-07 09:33:42 -07:00
Alan Agius
d6dd3dbdb0 fix(localize): add @angular/localize/init as polyfill in angular.json (#56300)
This commit addresses an issue where the `@angular/localize/init` polyfill is not included when there are no polyfills specified in the `angular.json` file.

PR Close #56300
2024-06-06 13:41:12 -07:00
Dylan Hunn
8c9b7110c3 docs(zone.js): update release guide for zone.js (#55846)
Update the releasing guide for zone.js, because one of the release commands was outdated.
PR Close #55846
2024-06-05 19:33:28 +00:00
Kristiyan Kostadinov
e2b99806ac refactor(language-service): integrate let declarations (#56270)
Integrates let declarations in the various places within the language service (quick info, completions etc).

PR Close #56270
2024-06-05 18:45:23 +00:00
Angular Robot
014fac8ec4 build: update dependency @rollup/plugin-commonjs to v26 (#56281)
See associated pull request for more information.

PR Close #56281
2024-06-05 18:36:51 +00:00
Thomas Nguyen
dbf1d9361e refactor(core): Refactor parts of event_replay into a shared library that will be used with global event delegation. (#56172)
This also moves the code that stashes the jsaction more closely to the code that actually sets the event listener.

PR Close #56172
2024-06-05 16:35:23 +00:00
Tom Wilkinson
33a6686806 refactor(core): Add and move tests for Dispatcher. (#56193)
Move tests from `eventcontract_test.ts` to `dispatcher_test.ts` for
functionality that lives in `Dispatcher`.

Add an extra test for `preventDefault` behavior for `CLICKMOD` that
covers a previous bug case.

PR Close #56193
2024-06-04 18:05:39 +00:00
arturovt
b283c0c6ac fix(zone.js): store remove abort listener on the scheduled task (#56160)
Prior to this commit, a memory leak occurred when the `abort` listener was
not removed from the `AbortSignal`. We introduced a fix to remove the event
listener, but it was erroneously stored on the `taskData`, which is a shared
global object. Consequently, when something attempted to remove an event listener,
it immediately removed the last stored abort listener. As a result, events would
never be canceled.

We have now rectified this by storing the remove abort listener function directly on
the task itself. This adjustment ensures that the abort listener is tied only to the
specific task. When the `abort` function is called, it cancels the task. Therefore, it
is safe to associate the cleanup function directly with the task.

Closes: #56148

PR Close #56160
2024-06-04 17:29:05 +00:00
Kristiyan Kostadinov
647f2a886d refactor(compiler-cli): add diagnostic for duplicate let declarations (#56199)
Adds a template diagnostic that will flag cases where multiple `@let` declarations use the same name.

PR Close #56199
2024-06-04 17:28:04 +00:00
Kristiyan Kostadinov
b70a286f27 refactor(compiler-cli): account for let declarations in two-way binding check (#56199)
Updates the check that prevent writes to template variables in two-way bindings to account for let declarations.

Also fixes some old tests that weren't properly setting up two-way bindings.

PR Close #56199
2024-06-04 17:28:04 +00:00
Kristiyan Kostadinov
35e9257226 refactor(compiler-cli): support completions for let declarations (#56199)
Adds support for let declarations inside the `CompletionEngine`.

PR Close #56199
2024-06-04 17:28:04 +00:00
Kristiyan Kostadinov
ab529c6ded refactor(compiler-cli): support resolving the symbol of let declaration (#56199)
Updates the symbol builder to handle resolving the symbol of a let declaration.

PR Close #56199
2024-06-04 17:28:04 +00:00
Kristiyan Kostadinov
28e76d7c91 refactor(compiler-cli): integrate let declaration into the indexer (#56199)
Adds support for let declarations in the template indexer.

PR Close #56199
2024-06-04 17:28:04 +00:00
Kristiyan Kostadinov
7ef0dab427 refactor(compiler-cli): integrate let declarations into the template type checker (#56199)
Integrates let declarations into the template type checker by producing corresponding constants in the TCB.

This also includes a couple of custom diagnostics to flag usages of let before they're declared and illegal writes to let declarations. We can't rely on TS for these checks, because it includes the variable name in the diagnostic.

PR Close #56199
2024-06-04 17:28:04 +00:00
Kristiyan Kostadinov
4b00690cea refactor(compiler): integrate let declarations into the template binder (#56199)
Integrates the let declarations into the template binder which will be used to power the scoping behavior of the new syntax.

PR Close #56199
2024-06-04 17:28:03 +00:00
Kristiyan Kostadinov
405e4dda92 refactor(compiler-cli): add compiler flag for testing let declarations (#56199)
Adds a private `_enableLetSyntax` flag that allows for let declarations to be enabled in tests.

PR Close #56199
2024-06-04 17:28:03 +00:00
Matthieu Riegler
33b0d25bfd refactor(core): Use Nullish coalescing assignment for view getters. (#56242)
Micro optim, this wasn't minified by the optimizer.

PR Close #56242
2024-06-03 20:10:35 +00:00
Alan Agius
a33d85dcb7 build: update Node.js to match Angular CLI engines (#56187)
The current supported Node.js engines by the Angular CLI are `^18.19.1 || ^20.11.1 || >=22.0.0`

PR Close #56187
2024-06-03 18:00:46 +00:00
Paweł
c3f2c67fa0 refactor(core): remove doubled line (#56091)
remove doubled line of titlecase pipe in commonModulePipes array

PR Close #56091
2024-05-31 13:24:55 +00:00
Andrew Scott
159c97ec69 refactor(core): provide zone token in prod as well (#56197)
This allows us to make decisions based on whether zone is provided for
when zoneless is the default.

PR Close #56197
2024-05-30 19:24:30 -07:00
Andrew Kushnir
290a47d842 fix(core): handle missing withI18nSupport() call for components that use i18n blocks (#56175)
This commit updates hydration serialization logic to handle a case when the `withI18nSupport()` call is not present for an application that has a component that uses i18n blocks. Note: the issue is only reproducible for components that also inject `ViewContainerRef`, since it triggers a special serialization code path.

Resolves #56074.

PR Close #56175
2024-05-30 18:36:58 +00:00
Tom Wilkinson
2a440e1064 fix(core): Fix shouldPreventDefaultBeforeDispatching bug (#56188)
When I copied this over in caedd10597
the parentheses moved around the A tag check and the CLICK type check,
instead of around the CLICK and CLICKMOD check.

PR Close #56188
2024-05-30 17:54:55 +00:00
Alex Rickabaugh
616cdef474 fix(core): don't coerce all producers to consumers on liveness change (#56140)
When a consumer switches its liveness state, it gets added to / removed from
the consumer list of all of its producers. This operation is transitive, so
if its producer is *also* a consumer and *its* liveness state is switched,
then the change is applied recursively.

Note that this only matters *if* the producer is also a consumer. However,
the logic in `producerAddLiveConsumer` / `producerRemoveLiveConsumerAtIndex`
coerced the producer node into a producer & consumer node, which allocated
extra arrays into the node structure that are never used. This didn't affect
correctness, but increased the memory usage of plain signal nodes (which are
just producers, never consumers).

This fix changes the logic in those operations to simply check if a producer
is also a consumer instead of coercing it into one.

PR Close #56140
2024-05-30 17:44:56 +00:00
Thomas Nguyen
7659dffa3f refactor(core): Remove lambda from error message. (#56161)
This should've been in the previous PR, but a bad rebase removed it.

PR Close #56161
2024-05-30 17:30:53 +00:00
Thomas Nguyen
0e3e6d4336 refactor(core): Switch a .includes to a .indexOf(), as this is currently (#56046)
breaking internal tests that assert no usage of Array ES6 methods.

PR Close #56046
2024-05-30 15:30:52 +00:00
Andrew Kushnir
0c39a46a88 refactor(core): replace AIO link with ADEV one in hydration message (#56178)
This commit updates the content of hydration-related message and replaces AIO with ADEV domain.

PR Close #56178
2024-05-30 14:57:11 +00:00
Kristiyan Kostadinov
989a8e126e refactor(compiler): implement let declarations in render3 ast (#55848)
Introduces a new `LetDeclaration` into the Render3 AST, simiarly to the HTML AST, and adds an initial integration into the various visitors.

PR Close #55848
2024-05-30 14:55:37 +00:00
Kristiyan Kostadinov
d44c8ee98c refactor(compiler): implement let declarations in html ast (#55848)
Adds a new `LetDeclaration` node to the AST that captures the `LetStart`, `LetValue` and `LetEnd` tokens into a single node.

PR Close #55848
2024-05-30 14:55:37 +00:00
Kristiyan Kostadinov
5ee235729c refactor(compiler): add support for tokenizing let declarations (#55848)
Updates the lexer to produce tokens for `let` declarations. Currently it' behind a flag while the feature is being worked on.

PR Close #55848
2024-05-30 14:55:37 +00:00
Matthieu Riegler
78cf9bfc0e fix(core): Do not migrate HttpClientModule imports on components. (#56067)
`provideHttpClient()` returns a `EnvironmentProvider` which is not compatible with component providers.

PR Close #56067
2024-05-30 14:55:06 +00:00
Kristiyan Kostadinov
b70b80ba55 fix(migrations): do not generate aliased variables with the same name (#56154)
Adds some logic to avoid generating expressions like `let $index = $index` in the control flow migration.

Fixes #56152.

PR Close #56154
2024-05-30 14:54:36 +00:00
Angular Robot
88732f0ca4 build: update cross-repo angular dependencies (#56169)
See associated pull request for more information.

PR Close #56169
2024-05-30 14:54:05 +00:00
Andrew Scott
50f8191fbf refactor(core): privately export token that indicates if zone CD is provided (#56137)
This will allow us to internally decide how to configure things when the default is zoneless.

PR Close #56137
2024-05-30 13:48:08 +00:00
naaajii
ba85d08158 fix(migrations): handle empty ngSwitchCase (#56105)
empty ngSwitchCase generate `case ()` which isn't valid syntax therefore adding quotes will help prevent us migrate empty case if no condition was provided

fix angular#56030

PR Close #56105
2024-05-29 15:38:39 +02:00
Thomas Nguyen
4fdc93bcd5 refactor(core): Use event_dispatcher in event_replay code. (#56036)
This makes events bubble! This change also contains changes to
dispatcher and event_dispatcher to make replay synchronous,
so that we avoid odd timing issues. This can be split out though.

Lastly, we have one cleanup change to move the mapping from
event type to functions on the element itself.

PR Close #56036
2024-05-29 12:59:23 +02:00
Alan Agius
fa4bcf3621 test: add back control_flow_migration tests (#56130)
These were incorrectly removed via https://github.com/angular/angular/pull/55391#issuecomment-2135352758

PR Close #56130
2024-05-28 16:48:08 +02:00
Kristiyan Kostadinov
0b6018b755 build: update to latest dev infra code (#56128)
Updates the repo to the latest dev infra code which involves updating a patch and renaming all the golden files to end with `.api.md`.

PR Close #56128
2024-05-28 14:42:31 +02:00