Commit graph

166 commits

Author SHA1 Message Date
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
8bf97d1370 build: remove all usages of the interop_deps attr for ts_project and ng_project (#62732)
Remove all of the usages of interop_deps as attributes in the repo

PR Close #62732
2025-07-21 13:03:09 -04:00
Kristiyan Kostadinov
745ea44394 feat(core): support TypeScript 5.9 (#62541)
Updates the repo to support TypeScript 5.9 and expands the allowed version range.

PR Close #62541
2025-07-14 14:04:58 -07:00
Paul Gschwendtner
902121ebc0 refactor(migrations): ensure tsurge can properly emit references in g3 (#62447)
Currently when Tsurge runs in g3, it creates a bare bones Angular
compiler plugin. The tsconfigs from compilation units may set options
like "useHostForImportGeneration", but the Ngtsc logic doesn't enable
because the `fileNameToModuleName` method is not defined on the host.

This can break reference emission for Tsurge analyzers/programs and
result in subtle differences to real `ng_module` compilations. This
commit fixes this by making the method available in 1P Tsurge.

Notably, reference emission can occur during analysis— so even if
migrations aren't "emitting TS -> JS" output.

PR Close #62447
2025-07-03 09:36:16 +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
Joey Perrott
b37fd9753f build: migrate language service to use rules_js (#61568)
Migrate language service to build using ts_project

PR Close #61568
2025-05-21 17:05:14 +00:00
Paul Gschwendtner
08f7d21d5c refactor(migrations): ensure tsurge configures file system properly (#61553)
Currently in 1P, without this commit, the tsconfig parsing picks up the
default file system (InvalidFS) and results in runtime errors.

PR Close #61553
2025-05-21 10:01:18 +00:00
Alan Agius
cf8c853523 build: remove @types/diff (#61447)
The latest diff package includes the TS types.

PR Close #61447
2025-05-19 09:17:47 +00:00
Paul Gschwendtner
4a3d39cd5a refactor: ensure tsurge migrations have clear ownership of files (#61421)
Currently there can be cases, exlusively in 3P, where multiple tsconfig
projects have overlap of source files. This is the default setup of new
CLI applications as well.

When this is the case, Tsurge will treat each tsconfig as an isolated
compilation unit (given the concepts and mental model to support
scalable batching). This is wrong though, and the same `.ts` source file
can appear in two migration invocations; resulting in duplicate
replacements or analysis (depending on the migration).

We've worked around this problem in the past by deduplicating
replacements, or migrating to an ID-based approach with natural
deduplication. This worked, but it's just working around the root cause.

This commit attempts to fix the root cause by adjusting Tsurge to ensure
that no source file ever appears in two compilation units. This is
naively achieved by not adding a source file to a migration unit, if it
was part of a previous one. This is expected to be fine given the nature
of Tsurge migrations that are built to operate on isolated pieces
anyway— so it shouldn't be problematic if e.g. `app.component.ts` ends
up being part of the test tsconfig compilation unit (we avoid this order
though by visiting build targets first).

PR Close #61421
2025-05-16 15:56:44 +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
Paul Gschwendtner
3d0ecb2273 refactor: remove unused beam pipeline code (#61272)
We don't need this logic anymore as we combine in batches and don't deal
with bulk data files that combine all units.

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
JoostK
3d85d9363c fix(core): reduce total memory usage of various migration schematics (#60774)
This commit changes Tsurge's operation within angular-devkit (i.e. the CLI) to
no longer retain all programs across all migrations. This isn't necessary for
so-called "funnel" migrations so not retaining the programs for those migrations
is a pure performance win. The "complex" migrations may see increased execution time
given that the program is now being recreated for the actual migration phase to run,
although reduced memory pressure may help alleviate this overhead. Since this new
approach should help prevent Node from running out of memory and failing entirely
this is preferred over a potentially increased execution time.

Fixes #59813

PR Close #60774
2025-04-07 13:13:33 -07:00
Kristiyan Kostadinov
92c4123a74 refactor(compiler): integrate new AST nodes into visitors (#60724)
Updates the various visitors to add placeholders for the new AST nodes.

PR Close #60724
2025-04-04 11:28:47 -07:00
Kristiyan Kostadinov
c147a0d6de refactor(migrations): simplify integration of tsurge migrations into the CLI (#60386)
Currently when we reuse a Tsurge migration is reused externally, there's some glue code that needs to be executed in a specific order. The code gets copied between the different migrations which is error-prone and means that bugs may have to be fixed several times.

These changes move the common steps out into a separate function so that only the migration-specific logic (mostly instantiation and logging) is left in the schematic.

PR Close #60386
2025-03-14 14:44:26 +01:00
Kristiyan Kostadinov
e170d24240 fix(core): add migration away from InjectFlags (#60318)
Adds an automated migration that will switch users from the deprecated `InjectFlags` API to its non-deprecated equivalent.

PR Close #60318
2025-03-11 11:33:09 -07:00
Enea Jahollari
1cd3a7db83 feat(migrations): add migration to convert templates to use self-closing tags (#57342)
This schematic helps developers to convert their templates to use self-closing tags mostly as a aesthetic change.

PR Close #57342
2025-02-18 17:33:59 +00:00
RafaelJCamara
5c9e84acd6 docs: update license URL from angular.io to angular.dev and year of license to 2025 (#59407)
PR Close #59407
2025-01-09 10:27:54 -05:00
Kristiyan Kostadinov
d6ca669bc9 refactor(migrations): allow compiler options to be customized in tsurge (#59353)
Allows for user-defined options to be passed in when creating a program in tsurge.

PR Close #59353
2025-01-06 16:21:26 +00:00
hawkgs
0513fbc9fc docs: set syntax highlighting of code examples MD code blocks (#59026)
Set the syntax highlighting based on the code examples' language.

PR Close #59026
2024-12-04 17:30:28 +01:00
Kristiyan Kostadinov
4f1f4a1728 refactor(migrations): skip TS version check in tsurge (#58866)
Skips the TS version check in tsurge since it's blocking some internal changes and generally isn't necessary since the app will be checked when it's built anyways.

PR Close #58866
2024-11-25 15:26:18 +00:00
Paul Gschwendtner
55fde8dbac refactor(migrations): support running existing migrations with plain TS programs (#58541)
Previously we always ran Tsurge migrations with an Angular program, even
if it's a plain `ts_library` target. This has changed now, so we also
need to properly handle the case where a `ts_library` is analyzed, but
no Angular program is available.

PR Close #58541
2024-11-08 17:22:06 +00:00
Paul Gschwendtner
1a0cee543e refactor(migrations): conditionally create plain TS programs for Tsurge analyzers (#58541)
Tsurge can run against the full Google3 depot, and will often also deal
with plain `ts_library` targets. Those shouldn't be constructed with the
Angular compiler as this could cause out of memory breakages etc. The
targets are simply not "proven" to be compatible with the Angular
compiler; so we shouldn't use them when not necessary.

PR Close #58541
2024-11-08 17:22:06 +00:00
Paul Gschwendtner
121b340916 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
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
Paul Gschwendtner
35d7ca55b2 test: support parallel tsurge unit combining in batch test infra (#58280)
This allows the batch test for the signal input migration to pass.

PR Close #58280
2024-10-25 18:47:41 +00:00
Paul Gschwendtner
8143016b91 refactor(migrations): support parallel tsurge metadata merging (#58280)
This is helpful and important for large scale migrations where a single
call for merging _all_ unit data's can be subject to memory / disk
resource constraints. Consider a compilation unit data for every target
in Google3, and those being merged in a single program.

PR Close #58280
2024-10-25 18:47:41 +00:00
Andrew Kushnir
888657a12e Revert "refactor(migrations): support parallel tsurge metadata merging (#58280)" (#58313)
This reverts commit 21b6613b90.

PR Close #58313
2024-10-22 12:27:53 -07:00
Andrew Kushnir
9aa686896d Revert "test: support parallel tsurge unit combining in batch test infra (#58280)" (#58313)
This reverts commit cb34e406ba.

PR Close #58313
2024-10-22 12:27:53 -07:00
Paul Gschwendtner
cb34e406ba test: support parallel tsurge unit combining in batch test infra (#58280)
This allows the batch test for the signal input migration to pass.

PR Close #58280
2024-10-22 11:29:16 -07:00
Paul Gschwendtner
21b6613b90 refactor(migrations): support parallel tsurge metadata merging (#58280)
This is helpful and important for large scale migrations where a single
call for merging _all_ unit data's can be subject to memory / disk
resource constraints. Consider a compilation unit data for every target
in Google3, and those being merged in a single program.

PR Close #58280
2024-10-22 11:29:15 -07:00
Paul Gschwendtner
c1aa411cf1 fix(migrations): properly resolve tsconfig paths on windows (#58137)
The Angular CLI devkit and Tsurge, as well as TypeScript only deal with
Posix paths. We also normalize paths into posix paths, and try to
implement a devkit compatible virtual file system for the compiler-cli.

This commit fixes an issue where we accidentally resolved `/` to the
system root on Windows. e.g. `C:/`. This broke the posix and devkit
paths throughout tsconfig parsing.

This commit fixes this.

Fixes #58132.

PR Close #58137
2024-10-09 15:23:33 +00:00
Paul Gschwendtner
754a857f8c refactor(migrations): support extra return info for TsurgeMigration#migrate (#58106)
This allows us to return extra properties along with `#migrate`
replacements. Useful for language service integration or other
integrations of Tsurge migrations in special runners.

PR Close #58106
2024-10-08 06:19:37 +00:00
Paul Gschwendtner
9ce839fc7d test(migrations): add test for statistic collection tsurge (#58019)
Adds a test for statistic testing of Tsurge

PR Close #58019
2024-10-01 11:29:00 +00:00
Paul Gschwendtner
273444ab9a refactor(migrations): support getting statistics in tsurge testing (#58019)
This allows us to test statistics in future commits.

PR Close #58019
2024-10-01 11:28:59 +00:00
Paul Gschwendtner
9f08ff2baf refactor(migrations): support statistic tracking in tsurge migrations (#58019)
We should support tracking statistics in Tsurge migrations. This allows
us to print them after migration, or run migrations periodically as
large scale changes to track to progress.

TODO is an internal implementation that eventually runs periodcally
in LSC modes.

PR Close #58019
2024-10-01 11:28:59 +00:00
Paul Gschwendtner
806db68556 refactor(migrations): skip query migration if problematic QueryList usages are discovered (#57992)
If we see a reference to e.g. `QueryList#changes`, we should skip
migration to be on the safe side. Similar for other fields of query
lists.

PR Close #57992
2024-09-30 13:33:45 -07:00
Paul Gschwendtner
2fe393ac60 refactor(migrations): improve tsurge diff helper to simplify output (#57961)
Instead of printing the full diff, which may be a super large file or
golden, we only print context around lines with diff. This makes the
diffs much more actionable and readable.

PR Close #57961
2024-09-26 14:29:03 -07:00
Joey Perrott
9dbe6fc18b refactor: update license text to point to angular.dev (#57901)
Update license text to point to angular.dev instead of angular.io

PR Close #57901
2024-09-24 15:33:00 +02:00
Paul Gschwendtner
04a48736b1 refactor(migrations): add TODO for special output of signal input migration (#57918)
Sometimes we may insert `undefined!` or `any`. We should add a TODO in
those cases.

PR Close #57918
2024-09-23 13:41:48 +02:00
Paul Gschwendtner
505c0f788e refactor(migrations): add better explanation on what color diff represents in testing (#57919)
This clarifies what colors mean in the Tsurge text diff Jasmine matcher.

PR Close #57919
2024-09-23 12:43:17 +02:00
cexbrayat
eb77b533b8 refactor(migrations): avoid TS error 18003 when no files found (#57899)
When running a migration, tsurge creates a TS program from the tsconfig files found.
This can result in a 18003 error when no files are found (based on the includes/files of the config).

For example, the signal input migration throws in a CLI project that has no spec files:

```
ng g @angular/core:signal-inputs --defaults
Tsconfig could not be parsed or is invalid:

No inputs were found in config file '/tsconfig.spec.json'. Specified 'include' paths were '["src/**/*.spec.ts","src/**/*.d.ts"]' and 'exclude' paths were '["/out-tsc/spec"]'.
```

A similar issue has already been raised in the CDK migration (see https://github.com/angular/components/issues/27055).

This was solved in the CDK (credits to @crisbeto) by ignoring the 18003 error (see 9c1112d408361a47c98dfd470b8e990cbd1753db).

This PR does the same in tsurge.

PR Close #57899
2024-09-23 12:42:33 +02:00
Paul Gschwendtner
5bb7050c59 refactor(migrations): add common helpers for inserting TODOs (#57898)
Adds a common helper for inserting TODOs to Tsurge.

PR Close #57898
2024-09-23 12:41:34 +02:00
Paul Gschwendtner
ef5412c9bc refactor(migrations): fix virtual devkit file system not detecting directories (#57897)
The compiler and its file system implementation expects `fs.exists` to
return `true` even for directories. This caused issues with the TSConfig
resolution as `/` was looked up.

We fix this by making use of `stat` which is equally expensive to
`tree.exists`. The devkit tree's don't expose directory existance checks
out of the box.

Fixes #57887.

PR Close #57897
2024-09-20 15:06:33 +02:00
Paul Gschwendtner
8ecafce2d9 refactor(migrations): do not run optional TCB operations in input migration (#57835)
Optional operations that don't run in the actual application compilation
would then cause fatal diagnostic errors breaking the compiler
initialization at runtime.

We should try to keep the migration as close as possible to the
application build.

PR Close #57835
2024-09-17 11:08:37 +02:00
Paul Gschwendtner
fd081e8ee4 refactor(migrations): add compiler filesystem for devkit virtual tree (#57794)
The file system will be used for dev-kit wiring up of Tsurge migrations
in e.g. `ng generate` and `ng update`

PR Close #57794
2024-09-13 14:13:58 +02:00
Paul Gschwendtner
2591b988ce refactor(migrations): add jasmine diff matcher to tsurge testing utilities (#57777)
Commonly when testing Tsurge migrations, we need to diff text content of
files. This commit adds a colored diff helper that makes writing tests
much easier.

PR Close #57777
2024-09-11 17:48:29 +00:00
Paul Gschwendtner
1c663ca820 refactor(migrations): add helper for dedenting to tsurge (#57777)
Dedenting the smallest leading whitespace is useful for conveniently
testing the output of a migration. This commit includes the helper in
Tsurge.

PR Close #57777
2024-09-11 17:48:29 +00:00
Paul Gschwendtner
acafa3b91d refactor(migrations): add own build file for tsurge AST helpers (#57766)
This separates tsurge from its optional AST helpers more cleanly.

PR Close #57766
2024-09-11 14:26:58 +00:00