Commit graph

396 commits

Author SHA1 Message Date
tomer953
8fd896e99a fix(core): resolve component import by exact specifier in route lazy-loading schematic
Avoid substring matching on importClause.getText() which caused suffix collisions (e.g., BarComponent vs FooBarComponent). Use AST-based matching for default and named (including aliased) imports to reliably resolve the correct import path when generating loadComponent.

(cherry picked from commit 8fa6617352)
2026-04-01 09:24:13 +02:00
aparziale
73d6b01b47 fix(migrations): inject migration not work in multi-project workspace with option path
Fix inject migration in multi-project workspace. The inject migration doesn't work when targeting one of the projects due to either not finding any files in other projects or considering them external thus it throws a SchematicsException

Fixes: #66074
(cherry picked from commit a73b4b7c30)
2026-03-19 15:20:46 -07:00
aparziale
076d41c3f6 fix(migrations): prevent trailing comma syntax errors after removing NgStyle
This fixes an issue where when removing NgStyle from the imports array of a component, an extra trailing comma would be left behind if it was the last element in that component`.

(cherry picked from commit 730684b9ce)
2026-03-17 17:01:28 -07:00
Angular Robot
11767cabe4 build: update Jasmine to 6.0.0
Jasmine enables `forbidDuplicateNames: true` by default. So we also need to desambiguate duplicate spec names.
2026-02-09 12:15:57 -08:00
tomer953
008e20ca56 fix(migrations): prevent duplicate imports in common-to-standalone migration
The common-to-standalone migration did not check for existing imports
when adding needed imports after removing CommonModule. This change adds deduplication
logic to filter out imports that already exist in the imports array
before adding them, ensuring each import appears only once.
2026-01-09 14:30:47 -08:00
Tomer953
a4f50bdd54 fix(migrations): detect structural ngTemplateOutlet and ngComponentOutlet
the common-to-standalone migration only matched [ngTemplateOutlet] and
[ngComponentOutlet] bindings and missed their structural forms
(*ngTemplateOutlet and *ngComponentOutlet). This caused missing imports
when removing CommonModule. This change adds structural directive
patterns so the migration correctly identifies needed imports.
2025-11-24 12:40:57 -05:00
Lukas Matta
5b210e97af fix(migrations): Prevent removal of templates referenced with preceding whitespace characters
In https://github.com/angular/angular/pull/64745, a fix was introduced for templates referenced with a trailing semicolon. However, templates are still incorrectly removed when there are whitespace characters before the template name.

This commit updates the control flow migration logic to ensure templates referenced with preceding whitespace are not removed.

Fixes #64854
2025-11-04 23:25:59 +00:00
Lukas Matta
64cb08529d fix(migrations): Do not remove a template if it is referenced even with a trailing semilocon
This commit fixes a behavior where under certain conditions, the migration script ignored
a template reference with a trailing semicolon and incorrectly removed the definition
of a referenced template.

Fixes #64741
2025-10-29 10:50:56 +01:00
Alan Agius
b4e798ed87 refactor(migrations): exclude all @angular/* packages from schematics bundle
This change updates the rollup configuration for the core schematics to exclude all `@angular/*` packages from the bundle. This is possible following https://github.com/angular/angular/pull/64703

This significantly reduces the size of the `@angular/core` schematics bundle, resulting in a size reduction to 5.8mb.
2025-10-28 20:51:50 +01:00
Alan Agius
9d00c6892f build: reduce package size of @angular/core
The schematics bundle size is reduced by externalizing @angular/compiler. This reduces the package size from 11mb to 9.1mb.
2025-10-27 17:12:48 +01:00
aparziale
338ac3b2ef refactor(migrations): unit test signal migration adjustment (#64393)
Move unit test from spec file to golden test

PR Close #64393
2025-10-15 10:38:57 -07:00
SkyZeroZx
75fc16b261 feat(migrations): Adds support for CommonModule to standalone migration (#64138)
Introduces a migration that replaces CommonModule usage with individual imports from @angular/common, aligning with Angular's standalone component approach and improving module import clarity

PR Close #64138
2025-10-15 10:37:37 -07:00
SkyZeroZx
861cee34e0 feat(migrations): Adds migration for deprecated router testing module (#64217)
Introduces a schematic to replace deprecated router testing imports

PR Close #64217
2025-10-13 11:09:29 -07:00
SkyZeroZx
1ffcfb625a feat(migrations): Adds migration for deprecated router testing module (#64217)
Introduces a schematic to replace deprecated router testing imports

PR Close #64217
2025-10-13 11:09:29 -07:00
Kristiyan Kostadinov
62bbce63b7 fix(migrations): remove error for no matching files in control flow migration (#64253)
Now that the control flow migration is running as a part of `ng update`, we need to be a bit forgiving about there not being any matching files since it can break the entire update process.

These changes switch the error to a warning and it counts the files for the entire workspace, not the individual projects.

PR Close #64253
2025-10-06 15:29:25 -04:00
SkyZeroZx
d3e76b1956 fix(migrations): preserve component imports when pruning NgModules in standalone migration (#64186)
This fix preserves component imports by adding missing  statements and replacing module references with the correct component

PR Close #64186
2025-10-02 13:54:14 -07:00
SkyZeroZx
51a0b59389 fix(migrations): handle shorthand property declarations in NgModule (#64160)
The migration now correctly detects shorthand declarations in NgModule metadata

PR Close #64160
2025-10-01 10:41:15 -04:00
aparziale
31bc9e4111 fix(migrations): skip migration for inputs with 'this' references (#64142)
Prevents migration of @input() properties that contain references to 'this' in their initializer functions. This ensures that functions accessing class members via 'this' remain unchanged, preventing potential build errors.

PR Close #64142
2025-09-30 15:32:44 -04:00
Joey Perrott
758f0883f5 test(core): remove shelljs from core schematics tests (#64042)
Remove shelljs usage from core schematic tests and use builtins instead

PR Close #64042
2025-09-26 13:14:09 -04:00
aparziale
b96afb4bfc fix(migrations): handle reused templates in control flow migration (#63996)
The control flow migration was incorrectly removing `ng-template` elements in scenarios where they were referenced by multiple `*ngIf` directives' `else` clauses and also used independently via `ngTemplateOutlet`.

PR Close #63996
2025-09-24 16:01:58 +00:00
Matt Lewis
aeb3e6c6a5 fix(migrations): handle import aliases to the same module name (#63934)
Fixes a bug in the standalone migration where 2 imported modules have the same class name but 1 is imported with an alias and would not be added to the component imports array when migrating

Fixes #63913

PR Close #63934
2025-09-19 14:48:32 +00:00
aparziale
307e4eafef refactor(migrations): remove common module if there are no references (#63892)
ngclass-to-class migration removes commonModule if there are no references that use it

PR Close #63892
2025-09-18 20:18:43 +00:00
aparziale
4133b08d93 fix(migrations): fix route-lazy-loading migration (#63818)
route-lazy-loading migration now supports routes when exported by default

PR Close #63818
2025-09-16 15:53:47 +00:00
aparziale
8dc8914c8a feat(migrations): add migration to convert ngStyle to use style (#63517)
Add migration to convert ngStyle to use style

PR Close #63517
2025-09-15 20:16:16 +00:00
Alan Agius
28926ba92c feat(core): introduce BootstrapContext for improved server bootstrapping (#63562)
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.

PR Close #63562
2025-09-09 10:57:09 -07:00
aparziale
655a99d0c6 fix(migrations): fix bug in ngclass-to-class migration (#63617)
Fix bug in ngclass-to-class migration. The migrateSpaceSeparatedKey option was configured incorrectly and I added a test case

PR Close #63617
2025-09-08 12:30:00 -07:00
Alan Agius
ce8db665f9 refactor(platform-browser): remove deprecated ApplicationConfig export (#63529)
Removes the deprecated `ApplicationConfig` export from `@angular/platform-browser`.
This export was deprecated in a prior version and developers should import `ApplicationConfig` from `@angular/core` instead.

BREAKING CHANGE:

The deprecated `ApplicationConfig` export from `@angular/platform-browser` has been removed.
Please import `ApplicationConfig` from `@angular/core` instead.

PR Close #63529
2025-09-02 11:48:19 -07:00
aparziale
06f4fd4456 fix(core): Fixed inject migration schematics for migrate destructured properties (#62832)
Fixes #62626 - Properties used with the destructor are also managed during migration.

PR Close #62832
2025-09-02 10:59:46 -07:00
Joey Perrott
2fcafb65c5 build: rename defaults2.bzl to defaults.bzl (#63383)
Use defaults.bzl for the common macros

PR Close #63383
2025-08-25 15:45:01 -07:00
aparziale
6ddb250391 feat(migrations): add migration to convert ngClass to use class (#62983)
feat #61661 - add migration to convert ngClass to use class

PR Close #62983
2025-08-21 11:41:32 -07:00
Alan Agius
d0d6079f54 refactor: remove version 20 migrations (#63207)
This commit remove the non optional migrations for version 20 as these have already been executed.

PR Close #63207
2025-08-18 09:06:51 +02:00
Matthieu Riegler
4e0fc81491 feat(router): convert lastSuccessfulNavigation to signal (#63057)
This commit also include an `ng update` migration to ensure `lastSuccessfulNavigation` is invoked.

BREAKING CHANGE: `lastSuccessfulNavigation` is now a signal and needs to be invoked

PR Close #63057
2025-08-13 11:29:01 -07:00
Matthieu Riegler
687c374826 feat(router): add a currentNavigation signal to the Router service. (#63011)
This new signal property is convenient to derive a `isNavigating` state.

`isNavigating = computed(() => !!this.router.currentNavigation())`

DEPRECATED: The Router.getCurrentNavigation method is deprecated. Use the Router.currentNavigation signal instead.

fixes #62958

PR Close #63011
2025-08-06 09:54:53 -07:00
Kristiyan Kostadinov
ddf779e18f Revert "feat(router): add a currentNavigation signal to the Router service. (#62971)" (#63010)
This reverts commit d00b3fed58.

PR Close #63010
2025-08-05 18:02:56 +02:00
Matthieu Riegler
d00b3fed58 feat(router): add a currentNavigation signal to the Router service. (#62971)
This new signal property is convenient to derive a `isNavigating` state.

`isNavigating = computed(() => !!this.router.currentNavigation())`

DEPRECATED: The Router.getCurrentNavigation method is deprecated. Use the Router.currentNavigation signal instead.

fixes #62958

PR Close #62971
2025-08-05 10:05:49 +02:00
Kristiyan Kostadinov
b1514d512e fix(migrations): incorrect filtering in inject migration (#62913)
The inject migration wasn't implementing file filtering properly which resulted in it passing an invalid tsconfig path to TypeScript.

Fixes #62866.

PR Close #62913
2025-07-31 09:15:42 +00:00
Joey Perrott
cbc258eec8 build: remove ts_project_interop infrastructure (#62908)
Remove the interop macros and final usages

PR Close #62908
2025-07-31 09:12:58 +00:00
Joey Perrott
caee6ff8e7 build: remove all usages of @bazel/runfiles (#62804)
Remove usages of @bazel/runfiles throughout the repository

PR Close #62804
2025-07-25 10:04:55 +02:00
Joey Perrott
f5d9d084b6 build: move nodejs_test to js_test (#62709)
Move nodejs_test to js_test and remove unnecessary files after move

PR Close #62709
2025-07-22 10:07:13 -04:00
Joey Perrott
b84859073b build: migrate to use web test runner rules (#62292)
Migrate karma tests throughout the repo to use the new web test runner based rule instead

PR Close #62292
2025-06-26 17:19:10 +00:00
Joey Perrott
557ac51c32 build: migrate to using new jasmine_test (#62131)
Migrate additional targets to jasmine_test

PR Close #62131
2025-06-19 10:06:27 +02:00
Kristiyan Kostadinov
34adfdea82 fix(migrations): more robust trailing comma removal in unused imports migration (#62118)
Fixes the following issues with the logic in the unused imports migration that deals with trailing commas:
1. It was generating overlapping text ranges which can break internally.
2. It wasn't handling some cases that produce trailing commas.

PR Close #62118
2025-06-18 15:57:12 +02:00
Joey Perrott
3a0cfd544d build: migrate to using new jasmine_test (#62086)
Use the new jasmine_test based on rules_js instead of jasmine_node_test from rules_nodejs

PR Close #62086
2025-06-18 08:27:26 +02:00
Matthieu Riegler
4040a6ba5d refactor(migrations): support local string tokens for inject migration (#62013)
The `localTypeChecker` allows us to at least support locally defined strings in addition to string literals.

PR Close #62013
2025-06-12 15:53:20 +02:00
Matthieu Riegler
9630d79d1a refactor(migrations): keep the control flow migration as ng generate. (#61773)
this way `ng generate @angular/core:control-flow` which has been fairly documented, remains valid.

PR Close #61773
2025-06-03 07:12:59 -04:00
Kristiyan Kostadinov
bb88b3f22f fix(migrations): avoid trailing whitespaces in unused imports migration (#61698)
Follow-up to #61674 where we were leaving behind some whitespace, e.g. `[One, Two, Three]` would turn into `[One ]`. These changes only preserve the whitespace if the node is preceded by a newline.

This wasn't caught by tests, because they were stripping away whitespaces before asserting. I've also reworked the tests to be sensitive to formatting changes.

PR Close #61698
2025-05-30 11:07:20 -04:00
Kristiyan Kostadinov
04656d0b6e fix(migrations): preserve comments when removing unused imports (#61674)
Updates the unused imports schematic to preserve comments inside the array. THis is necessary for some internal use cases.

PR Close #61674
2025-05-26 10:26:20 +00:00
Paul Gschwendtner
b763059bdd build: migrate packages/core/schematics to ts_project (#61370)
Migrates `packages/core/schematics` to `ts_project`. As part of this,
this commit cleans up some of the mixed module types and tsconfigs in
the folder. A single tsconfig (and it's test variant) are now used.

For the shipped schematics, we explicitly use the `.cjs` extension, so
that the bundles are properly recognized as CommonJS; even if they are
part of the `type: module` `@angular/core` package.

The `package.json` with `type: commonjs` is removed from
`packages/core/schematics` as it's no longer needed given the explicit
extension & caused issues as schematics are compiled with ESM but are
only later bundled for shipping & some tests as ESM.

PR Close #61370
2025-05-16 11:02:07 +00:00
Paul Gschwendtner
84d50d205a refactor: support arbitrary stats/metrics in tsurge (#61272)
Supports arbitrary stats/metrics in Tsurge. This will make
complex analysis easier as we aren't bound to just `Record<string,
number>` counters.

PR Close #61272
2025-05-14 11:05:55 +02:00
Kristiyan Kostadinov
4dc7136c49 refactor(migrations): remove unused code (#61260)
The `waitForAsync` rule has been disabled internally which allows us to delete its code, as well as some unused adjacent code.

PR Close #61260
2025-05-12 15:34:07 -07:00