Commit graph

31427 commits

Author SHA1 Message Date
Kristiyan Kostadinov
4ef11c987d fix(core): resolve forward-referenced host directives during directive matching (#58492)
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
2024-11-04 16:17:23 +01:00
cexbrayat
a116a64d35 refactor(migrations): useFactory in provide-initializer migration (#58493)
The following provider:

```ts
{
  provide: APP_INITIALIZER,
  useFactory: (initService: InitService) => {
    return () => initService.init()
  },
  deps: [InitService],
  multi: true
}
```

was migrated into:

```ts
provideAppInitializer(() => { return ((initService: InitService) => {
  return () => initService.init()
})(inject(InitService)); })
```

This doesn't compile because there is an extra function:

```
✘ [ERROR] TS2345: Argument of type '() => () => void' is not assignable to parameter of type '() => void | Observable<unknown> | Promise<unknown>'.
  Type '() => void' is not assignable to type 'void | Observable<unknown> | Promise<unknown>'. [plugin angular-compiler]

    src/app/app.config.ts:7:26:
      7 │ ...ovideAppInitializer(() => { return ((initService: InitService) => {
```

It now migrates the provider into:

```ts
provideAppInitializer(((initService: InitService) => {
  return () => initService.init()
})(inject(InitService)))
```

PR Close #58493
2024-11-04 15:45:50 +01:00
Angular Robot
536ee2bfbd build: update io_bazel_rules_sass digest to c375923 (#58477)
See associated pull request for more information.

PR Close #58477
2024-11-04 15:37:37 +01:00
Alan Agius
c21734c840 ci: restore the local Yarn copy before executing renovate-update-generated-files (#58497)
There is an unidentified issue causing the Yarn binary to be altered, resulting in packages not installing correctly and leading to failures in the process.

PR Close #58497
2024-11-04 15:35:06 +01:00
Enea Jahollari
6819d6abf3 fix(migrations): flip the default standalone flag in route-lazy-loading migration (#58474)
Before v19, the default value of the standalone flag was false, this code change flips the logic in the migration to make it true by default.

PR Close #58474
2024-11-03 19:07:09 +01:00
Kristiyan Kostadinov
7d0ba0cac8 refactor(compiler): trigger hmr load on initialization (#58465)
Adjusts the HMR initialization to avoid the edge case where a developer makes change to a non-rendered component that exists in a lazy loaded chunk that has not been loaded yet. The changes include:
* Moving the `import` statement out into a separate function.
* Adding a null check for `d.default` before calling `replaceMEtadata`.
* Triggering the `import` callback eagerly on initialization.

Example of the new generated code:

```js
(() => {
  function Cmp_HmrLoad(t) {
    import(
      /* @vite-ignore */ "/@ng/component?c=test.ts%40Cmp&t=" + encodeURIComponent(t)
    ).then((m) => m.default && i0.ɵɵreplaceMetadata(Cmp, m.default, [/* Dependencies go here */]));
  }
  (typeof ngDevMode === "undefined" || ngDevMode) && Cmp_HmrLoad(Date.now());
  (typeof ngDevMode === "undefined" || ngDevMode) &&
    import.meta.hot &&
    import.meta.hot.on("angular:component-update", (d) => {
      if (d.id === "test.ts%40Cmp") {
        Cmp_HmrLoad(d.timestamp);
      }
    });
})();
```

PR Close #58465
2024-11-01 19:14:16 +00:00
Alan Agius
fbd7b7c484 ci: run Renovate post tasks sequentially (#58472)
Due to a bug in Renovate (see: 276a01fdd7/lib/util/exec/common.ts (L50-L53)), post tasks are incorrectly running in parallel. This causes 'yarn install' to overlap with 'yarn ng-dev misc update-generated-files', resulting in incomplete installs before file updates start.

PR Close #58472
2024-11-01 19:10:27 +00:00
Alan Agius
13f1de3351 ci: update renovate postUpgradeTasks executionMode to branch (#58470)
This change modifies the execution level of `postUpgradeTasks` in Renovate. By setting `executionMode` to `branch`, the task will run once per branch, rather than for each dependency update. This helps streamline tasks across dependencies by consolidating them at the branch level.

PR Close #58470
2024-11-01 16:50:50 +00:00
Costin Sin
2e54d6dea8 refactor(zone.js): Change the type of _taskCounts to an IndexSignature that can have keys (#51739)
named as the values of the `TaskType` type.

The Closure Compiler used at Google has a property renaming optimization
that can change the property names when minifying code. Having the
correct type helps the TSJS team that develops a tool to identfy
property renaming issues directly in TypeScript.

Signed-off-by: Costin Sin <sin.costinrobert@gmail.com>

PR Close #51739
2024-11-01 15:44:06 +00:00
Alan Agius
bf64531ce4 ci: restrict file updates to a specified file location for post-task saves (#58460)
This is aiming to resolve issues with Renovate when executing `yarn ng-dev misc update-generated-files`

PR Close #58460
2024-11-01 15:43:23 +00:00
Angular Robot
3e2bc69386 build: update io_bazel_rules_sass digest to e3b2785 (#58420)
See associated pull request for more information.

PR Close #58420
2024-11-01 14:42:58 +00:00
Jordan Hall
45adc72040 build: Update publish-build-artifacts to honor ORG (#58408)
Currently you pass in the ORG and it still tries to publish to Angular rather than your ow ORG repo that gets created

PR Close #58408
2024-11-01 14:41:56 +00:00
Shannon V.C.
340866cb6b docs: fix external link in NG0100 error page (#58462)
Fixes external link for 'Everything you need to know about the "ExpressionChangedAfterItHasBeenCheckedError" error' on the NG0100 error page.
Domain has changed from indepth.dev to angularindepth.com

PR Close #58462
2024-11-01 14:34:29 +00:00
Kristiyan Kostadinov
3061c67539 refactor(language-service): update code fix for unused imports (#58468)
Since the unused imports diagnostic setup has changed, we need to update the code fix to account for it.

PR Close #58468
2024-11-01 14:33:56 +00:00
Kristiyan Kostadinov
c0738c90c3 fix(compiler-cli): make the unused imports diagnostic easier to read (#58468)
The unused imports diagnostic reports once on the entire initializer and then again once per unused imports. This ends up being a bit hard to follow, because in a lot of cases the code snippet looks identical.

These changes switch to highlighting the `imports:` part of the property declaration and only highlighting the unused imports without a message.

PR Close #58468
2024-11-01 14:33:55 +00:00
Kristiyan Kostadinov
5ca48e802b refactor(compiler): remove unused field from output AST (#58444)
The `ExternalReference.runtime` field wasn't being used anywhere.

PR Close #58444
2024-11-01 14:32:57 +00:00
Kristiyan Kostadinov
21adbba784 fix(compiler): avoid having to duplicate core environment (#58444)
Switches to referencing the core environment directly in the generated code, instead of having to duplicate it.

PR Close #58444
2024-11-01 14:32:57 +00:00
Jeevan Mahesha
95146248bb docs: update ng-template guide to include NgTemplateOutlet import and correct syntax (#58443)
PR Close #58443
2024-10-31 19:59:18 +01:00
Pawel Kozlowski
87344e49c0 refactor(docs-infra): migrate to output (#58447)
This change contains result of the automated migration
of the decorator based @Output to the function equivalent.

PR Close #58447
2024-10-31 19:58:37 +01:00
Alan Agius
4f94bd782d build: update yarn to 1.22.22 (#58448)
Trying to get around a problem is causing renovate to keep trying updating this file.

PR Close #58448
2024-10-31 19:06:16 +01:00
Alan Agius
01fcbafa2b build: update cross-repo angular dependencies (#58446)
See associated pull request for more information.

Closes #57880 as a pr takeover

PR Close #58446
2024-10-31 19:05:01 +01:00
Andrew Kushnir
89db5f734d refactor(core): tree-shake defer block registry (#58424)
This commit updates the code of the incremental hydration feature to make the `DeferBlockRegistry` class tree-shakable. The class is only needed for hydration cases and it should not be included into client bundles for client-only apps.

PR Close #58424
2024-10-31 18:12:03 +01:00
Jessica Janiuk
32a5388af9 refactor(core): More cleanup of incremental hydration code (#58430)
This cleans up much of incremental.ts and adds documentation.

PR Close #58430
2024-10-31 11:26:58 +01:00
Jessica Janiuk
20a6a52722 refactor(core): Eliminate recursion in incremental hydration (#58419)
This implements a queue rather than a recursive call, which enables
proper cleanup timing for defer block registry.

PR Close #58419
2024-10-31 11:22:58 +01:00
Kristiyan Kostadinov
94eae783c1 refactor(migrations): attempt to correct initialization order in internal inject migration (#58427)
Updates the internal part of the `inject` migration to attempt to correct some cases where the declaration order of properties doesn't match the initialization order.

PR Close #58427
2024-10-31 09:17:51 +01:00
Kristiyan Kostadinov
70f8c99885 refactor(migrations): make it easier to delete nodes including comments (#58427)
We were repeating the logic that deletes a node together with all its comments in a few different places. These changes consolidate the logic under `ChangeTracker.removeNode`.

PR Close #58427
2024-10-31 09:17:51 +01:00
Kristiyan Kostadinov
d7afb0a086 refactor(migrations): internal inject migration applying some changes to abstract classes (#58427)
We were filtering out abstract classes pretty late in the migration which led to the internal part of it to make some changes that aren't finalized later. These changes fix the issue by filtering out abstract classes during analysis.

PR Close #58427
2024-10-31 09:17:51 +01:00
Alan Agius
f04e6063ae fix(docs-infra): reduce margin-block-start from doc anchor headers (#58431)
This change reduces the spacing between headers, which is currently excessive.

PR Close #58431
2024-10-31 09:15:34 +01:00
Alex Rickabaugh
d8829fb3d1 docs: release notes for the v19.0.0-rc.0 release 2024-10-30 13:22:15 -07:00
Alex Rickabaugh
af5d776c04 docs: release notes for the v18.2.10 release 2024-10-30 12:12:09 -07:00
Matthieu Riegler
183af09059 refactor(migrations): Make the explicit standalone migration idempotent (#58418)
With this commit the  explicit standalone migration uses the presents of imports to make sure that we can safely remove the standalone prop
and not adding it again when re-run.

PR Close #58418
2024-10-30 11:55:11 -07: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
Pawel Kozlowski
3161360852 fix(migrations): properly migrate output aliases (#58411)
Before this fix the output migration was incorrectly assuming
that the @Output decorator takes its params as an object.
What happens in reality is that the @Output decorator is taking
alias as the only argument, without any object literal wrapper.

PR Close #58411
2024-10-30 10:01:28 -07:00
Pawel Kozlowski
db7ed20d7b fix(migrations): properly replace imports across files (#58414)
This change fixes a bug where the output migration was interacting
with the InputManager utility in the way that was resulting in
incorrect import replacements.

The fix consists of making sure that a new ImportManager instance
is created for each and every file containing @Output declarations.

PR Close #58414
2024-10-30 09:24:05 -07:00
Paul Gschwendtner
0d955f67ed refactor(migrations): gracefully handle metadata parsing errors in signal migration (#58413)
In 1P, we saw that a type of a target wasn't resolvable, referenced in a
`hostBindings#directive` field. This breaks the entire pipeline; so we
should handle gracefully but report an error.

Worst case scenario here is that we would miss some references to the
given directive/component. This is acceptable and we can continue
investigation why that given target was broken; especially since the
file was part of the target inputs- but seemingly not in the `tsconfig`.

PR Close #58413
2024-10-30 09:23:39 -07:00
Paul Gschwendtner
7f10343659 refactor(migrations): improve temporary variable insertion in signal migrations (#58413)
Fixes that the migrations weren't properly determing the highest block
of multiple shared references. The logic was flawed by checking the
`start` indices; because we also need to respect that the blocks
should enclose all references; and the block practically is a common
ancestor. This is not guaranteed without this commit.

Note: The logic assumes that all references are part of the same control
flow container; this is verified.

PR Close #58413
2024-10-30 09:23:39 -07:00
Kristiyan Kostadinov
2f9af914b7 fix(compiler-cli): disable standalone by default on older versions of Angular (#58405)
Disables the standalone by default behavior in the compiler when running against and older version of Angular. This is necessary, because the language service may be using the latest version of the compiler against and older version of core in a particular workspace.

PR Close #58405
2024-10-30 09:23:12 -07:00
Pawel Kozlowski
8fa556b1e1 refactor(docs-infra): use reactive APIs in adev components (#58357)
This is a relativelly small refactoring to a couple of
adev components. The goal here is to use new reactive
APIs in the idiomatic way.

PR Close #58357
2024-10-30 09:21:25 -07:00
Angular Robot
929db81f96 build: update scorecard action dependencies (#58400)
See associated pull request for more information.

PR Close #58400
2024-10-29 05:10:29 -07:00
Alan Agius
53733a4ef8 refactor(core): move static AfterRenderImpl.PHASES to a top-level variable (#58402)
Improves code minification.

PR Close #58402
2024-10-29 05:08:13 -07:00
Jessica Janiuk
2e11b6fc42 refactor(core): prevent unnecessary hydration work in csr cases (#58366)
This adds a shouldHydrate check that prevents any additional work in cases when hydration is not necessary.

PR Close #58366
2024-10-29 05:07:37 -07:00
Jessica Janiuk
acd4f80737 fix(core): Prevents trying to trigger incremental hydration on CSR (#58366)
hydrate triggers were firing in CSR cases and attempting to find parent defer blocks. This prevents that from happening. In these cases, the defer block id will be empty.

fixes: #58359

PR Close #58366
2024-10-29 05:07:37 -07:00
Angular Robot
7d9b38e97b docs: update Angular CLI help [main] (#58396)
Updated Angular CLI help contents.

PR Close #58396
2024-10-28 12:51:33 -07:00
george looshch
63f3d0c8fa docs: remove an unnecessary whitespace (#58388)
Remove an unnecessary whitespace between an opening parenthesis and a
word in the documentation on lifecycle.

Closes #58380

PR Close #58388

PR Close #58388
2024-10-28 12:49:36 -07:00
george looshch
92fbecb527 docs: fix backtick escaping in a Markdown file (#58387)
Fix backtick escaping for the template string example in the
documentation on expression syntax.

Closes #58382

PR Close #58387

PR Close #58387
2024-10-28 12:48:58 -07:00
Jeevan Mahesha
8a7985daa0 docs: update ProfileEditorComponent to use inject() for FormBuilder (#58378)
PR Close #58378
2024-10-28 12:48:27 -07:00
Jessica Janiuk
db467e10b7 refactor(core): Additional cleanup for incremental hydration (#58394)
This adds comments, removes some duplicate logic, and eliminates some unnecessary complexity of the incremental hydration core logic.

PR Close #58394
2024-10-28 12:40:27 -07:00
Kristiyan Kostadinov
4434f3c7a1 fix(migrations): inject migration always inserting generated variables before super call (#58393)
Fixes that if a class has a `super` call, the `inject` migration would always insert the generated variable before it, even if there's other code before the `super` call.

PR Close #58393
2024-10-28 12:39:03 -07:00
Kristiyan Kostadinov
26be4d64ae refactor(migrations): inject migration internal mode incorrectly migration properties initialized to identifiers (#58393)
Fixes that when the `inject` migration in internal mode was starting to visit the nodes one level down from the root when considering whether an expression contains local references. This lead it to skip over top-level identifiers and migrate some code incorrectly.

PR Close #58393
2024-10-28 12:39:03 -07:00
Kristiyan Kostadinov
b98400f582 fix(migrations): inject migration not inserting generated code after super call in some cases (#58393)
Fixes an issue where the `inject` migration was generating and attempting to insert code after a `super` call, but the string buffering implementation was dropping it if the statement right after the `super` call was deleted as a result of the migration.

PR Close #58393
2024-10-28 12:39:03 -07:00