Commit graph

31442 commits

Author SHA1 Message Date
Paul Gschwendtner
728bfbbb31 refactor(migrations): speed up code refactoring action for queries (#58525)
We were not properly passing around the TCB full program optimization,
so TCB generation was done per individual file. This significantly
slowed down reference resolution.

PR Close #58525
2024-11-06 16:30:18 +01:00
Paul Gschwendtner
4a0dc3c712 refactor(migrations): enable debug printing of compiler diagnostics (#58515)
This is useful for some migrations and eases debugging, so we are
building an environment-guarded debug print.

PR Close #58515
2024-11-06 13:04:22 +01:00
Paul Gschwendtner
d4d76ead80 fix(compiler-cli): do not fail fatal when references to non-existent module are discovered (#58515)
Currently when application source code references e.g. an NgModule that
points to references that aren't available, the compiler will break at
runtime without any actionable/reasonable error.

This could happen for example when a library is referenced in code, but
the library is simply not available in the `node_modules`. Clearly,
TypeScript would issue import diagnostics here, but the Angular compiler
shouldn't break fatally. This is useful for migrations which may run
against projects which aren't fully compilable. The compiler handles
this fine in all cases, except when processing `.d.ts` currently... and
the runtime exception invalides all other information of the program
etc.

This commit fixes this by degrading such unexpected cases for `.d.ts`
metadata reading to be handled gracefully. This matches existing logic
where the `.d.ts` doesn't necessarily match the "expecation"/"expected
format".

The worst case is that the Angular compiler will not have type
information for some directives of e.g. a library that just isn't
installed in local `node_modules`; compared to magical errors and
unexpected runtime behavior.

PR Close #58515
2024-11-06 13:04:22 +01:00
Paul Gschwendtner
e85ac5c7cb fix(migrations): properly bundle shared compiler code into migrations (#58515)
The use of relative imports vs. module imports and the existing mismatch
can cause symbols to be duplicated in migrations. This is problematic as
it breaks migration logic or compiler logic in the worst case.

Long-term we will solve this by having a better Bazel toolchain where
both relative and module imports can point to the same files; but in
practice this is not the case right now.

This commit fixes the fallback template logic in the signal
input/queries migration; in case no type check block information is
available.

PR Close #58515
2024-11-06 13:04:22 +01:00
Kristiyan Kostadinov
8ae84be3df 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:37 +01:00
Kristiyan Kostadinov
b0711d74c4 refactor(core): clean up standalone flag (#58478)
The `NG_STANDALONE_DEFAULT_VALUE` is no longer being patched internally and can be removed.

PR Close #58478
2024-11-06 07:01:25 +01:00
Madhu Ranjan
5c9e2e41e1 docs: fix example for pipe operator precedence by removing extra parenthesis (#58488)
PR Close #58488
2024-11-06 07:00:42 +01:00
Angular Robot
3db099c8e6 build: update babel dependencies (#58499)
See associated pull request for more information.

PR Close #58499
2024-11-06 06:59:44 +01:00
Angular Robot
85fa27d92a build: update dependency angular-split to v18 (#58510)
See associated pull request for more information.

PR Close #58510
2024-11-05 16:38:13 +01:00
Alan Agius
5b5828e856 ci: exclude packages/ssr/BUILD.bazel from requiring a G3 sync (#58514)
This file is only used to generate adev docs

PR Close #58514
2024-11-05 16:36:19 +01:00
Angular Robot
e7ac965b29 docs: update Angular CLI help [19.0.x] (#58511)
Updated Angular CLI help contents.

PR Close #58511
2024-11-05 14:10:20 +01:00
Charles Lyding
c36a1c023b fix(platform-browser): correctly add external stylesheets to ShadowDOM components (#58482)
Angular components that use ShadowDOM view encapsulation have an alternate
execution path for adding component styles to the DOM that does not use the
SharedStylesHost that all other view encapsulation modes leverage. To ensure
that ShadowDOM components receive all defined styles, additional logic has been
added to the ShadowDOM specific renderer to also cover external styles.

PR Close #58482
2024-11-05 11:33:17 +01:00
Angular Robot
90509f88fe build: update all non-major dependencies (#58506)
See associated pull request for more information.

PR Close #58506
2024-11-05 08:14:53 +01:00
Angular Robot
a32e897c5a build: migrate config renovate.json (#58503)
PR Close #58503
2024-11-05 07:51:40 +01:00
Sheik Althaf
ba84a02a6b refactor(devtools): convert to bootstrap application for shell and demo apps (#58319)
Migrated the demo apps and shell-browser apps to use bootstrap application, simplifed routing and standalone components.

PR Close #58319
2024-11-05 07:35:43 +01:00
cexbrayat
11f86a0a08 refactor(migrations): use import manager in provide-initializer (#58456)
The manual replacement logic had a flaw and was inserting the imports several times.

For example:

```ts
import { APP_INITIALIZER, ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { InitService } from './init.service';

export const appConfig: ApplicationConfig = {
  providers: [provideZoneChangeDetection({ eventCoalescing: true }),
    {
      provide: APP_INITIALIZER,
      useFactory: (initService: InitService) => initService.init(),
      deps: [InitService],
      multi: true
    },
    {
      provide: APP_INITIALIZER,
      useFactory: (initService: InitService) => initService.init(),
      deps: [InitService],
      multi: true
    }
  ]
};
```

produced:

```ts
import { ApplicationConfig, provideZoneChangeDetection, inject, provideAppInitializer }{ ApplicationConfig, provideZoneChangeDetection, inject, provideAppInitializer } from '@angular/core';
import { InitService } from './init.service';

export const appConfig: ApplicationConfig = {
  providers: [provideZoneChangeDetection({ eventCoalescing: true }),
    provideAppInitializer(() => { return ((initService: InitService) => initService.init())(inject(InitService)); }),
    provideAppInitializer(() => { return ((initService: InitService) => initService.init())(inject(InitService)); })
  ]
};
```

It now produces proper imports:

```ts
import { ApplicationConfig, provideZoneChangeDetection, inject, provideAppInitializer } from '@angular/core';
```

PR Close #58456
2024-11-04 18:15:00 +01:00
Miles Malerba
996593809c build: Update prettierrc to always use trailing commas (#58266)
This updates the prettierrc to reflect how the code seems to already be
formatted. I noticed that without this my IDE seemed to be introducing
formatting changes on save.

PR Close #58266
2024-11-04 18:14:05 +01:00
Koyejo
e6b05c72ea docs: fix grammatical error in template binding documentation (#58491)
This update corrects a grammatical error in the "CSS style properties" section of the template binding documentation. The sentence "You must create a new object instance when you modify these values in order to Angular to apply any updates" was updated to read correctly as "You must create a new object instance when you modify these values in order for Angular to apply any updates." This clarification helps improve readability and ensures the documentation communicates instructions accurately for readers.
PR Close #58491
2024-11-04 17:15:39 +01:00
Kristiyan Kostadinov
6e0af6dbbb 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
36f4457b69 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
61565eafee 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:38 +01:00
Alan Agius
23b1316822 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
c5e676bb87 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
86d8f6bda8 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
3f82c3f0eb 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:28 +00:00
Alan Agius
5278f194e5 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
efa7baa976 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:09 +00:00
Alan Agius
f87a773278 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
da1cd6fc59 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:59 +00:00
Jordan Hall
257d5b9979 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:58 +00:00
Shannon V.C.
8a38b68561 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:31 +00:00
Kristiyan Kostadinov
3b130087e9 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
22cd6869ef 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:56 +00:00
Kristiyan Kostadinov
abd0da7265 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
b25121ee4a 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
d7a7c80066 docs: update ng-template guide to include NgTemplateOutlet import and correct syntax (#58443)
PR Close #58443
2024-10-31 19:59:19 +01:00
Pawel Kozlowski
f1aab73189 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
1a919034a1 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:20 +01:00
Alan Agius
44a7257303 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
600ef5eff2 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
0ca14e2c72 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
8d00d0fe85 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
ea9bfff739 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
bb6e0aab1b 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
b5b0b4af29 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
ea086905c3 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:36 +01:00
Alex Rickabaugh
ee1d06c8fa release: cut the v19.0.0-rc.0 release 2024-10-30 13:20:44 -07:00
Matthieu Riegler
dcd16b43f3 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
3230d78c54 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
616b411a6d 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