angular/packages/core/schematics/utils
Paul Gschwendtner 2e60eb08f4 refactor(migrations): ensure project paths respect root directories (#57677)
Migrations may resolve files in e.g. `blaze-out` and try to compute a
path for the file that is "recognizable" across workers. E.g. in one
worker, it may be the actual `.ts` file inside the source tree, while in
the other, the file may be inside `blaze-out`.

Tsurge currently expects project relative paths to be passed around.
Those project relative paths are currently only based on the single root
directory. Hence paths inside `blaze-out` would actually not be
recognizable.

The fix idea here is that we introduce a structure for Project files.
This structure will contain two fields:

- an ID of a file. This is similar to a module ID in the project. Those
  are resolved with respect to all root directories. This matches the
  conceptual virtual roots of `tsconfig#rootDirs`. The IDs can be used
  for matching files across workers, assuming those are executing using
  the same root directories, and handle the same overall project (e.g.
  google3).

- a path relative to the primary project root. Multiple roots may be
  configured, but the primary project root, is the directory that
  contains all others. See: `tsconfig.rootDir`. This path is NOT
  necessarily useful for matching files between stages etc, but it's
  useful for writing replacements for a given file to disk.

Note that those two things cannot be combind into one conceptual
"project relative path" because a path relative to the most appropriate
root directory cannot be used for safe replacements. E.g. consider a
replacement matches a file from a root directory like `/sub/`. The path
inside `/sub/` would then omit the `/sub/` and later on when writing
replacements, we wouldn't know which root directory it actually was part
of. Hence the concept of a "project root relative path" and the "ID".

ds

PR Close #57677
2024-09-06 19:44:07 +00:00
..
tslint refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
tsurge refactor(migrations): ensure project paths respect root directories (#57677) 2024-09-06 19:44:07 +00:00
typescript feat(migrations): add migration to convert standalone component routes to be lazy loaded (#56428) 2024-07-30 20:00:37 +00:00
BUILD.bazel build: make devmode a noop and ensure it never runs (#48521) 2022-12-19 19:50:45 +00:00
change_tracker.ts refactor(migrations): add the ability to remove imports in the change tracker (#57179) 2024-07-29 13:47:14 -07:00
extract_metadata.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
line_mappings.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
load_esm.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
ng_component_template.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
ng_decorators.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
parse_html.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
project_tsconfig_paths.ts refactor: migrate core to prettier formatting (#55488) 2024-04-29 09:49:19 -07:00
template_ast_visitor.ts refactor(compiler): implement let declarations in render3 ast (#55848) 2024-05-30 14:55:36 +00:00