As a performance optimization, this commit splits the single __ngtypecheck__.ts file which was previously added to the user's program as a container for all template type-checking code into multiple .ngtypecheck shim files, one for each original file in the user's program. In larger applications, the generation, parsing, and checking of this single type-checking file was a huge performance bottleneck, with the file often exceeding 1 MB in text content. Particularly in incremental builds, regenerating this single file for the entire application proved especially expensive. This commit introduces a new strategy for template type-checking code which makes use of a new interface, the `TypeCheckingProgramStrategy`. This interface abstracts the process of creating a new `ts.Program` to type-check a particular compilation, and allows the mechanism there to be kept separate from the more complex logic around dealing with multiple .ngtypecheck files. A new `TemplateTypeChecker` hosts that logic and interacts with the `TypeCheckingProgramStrategy` to actually generate and return diagnostics. The `TypeCheckContext` class, previously the workhorse of template type- checking, is now solely focused on collecting and generating type-checking file contents. A side effect of implementing the new `TypeCheckingProgramStrategy` in this way is that the API is designed to be suitable for use by the Angular Language Service as well. The LS also needs to type-check components, but has its own method for constructing a `ts.Program` with type-checking code. Note that this commit does not make the actual checking of templates at all _incremental_ just yet. That will happen in a future commit. PR Close #36211
83 lines
2.2 KiB
Python
83 lines
2.2 KiB
Python
package(default_visibility = ["//visibility:public"])
|
|
|
|
load("//tools:defaults.bzl", "pkg_npm", "ts_api_guardian_test", "ts_library")
|
|
load("@npm_bazel_typescript//:index.bzl", "ts_config")
|
|
|
|
ts_config(
|
|
name = "tsconfig",
|
|
src = "tsconfig-build.json",
|
|
deps = ["//packages:tsconfig-build.json"],
|
|
)
|
|
|
|
ts_library(
|
|
name = "compiler-cli",
|
|
srcs = glob(
|
|
[
|
|
"*.ts",
|
|
"src/**/*.ts",
|
|
],
|
|
exclude = [
|
|
"src/integrationtest/**/*.ts",
|
|
],
|
|
),
|
|
tsconfig = ":tsconfig",
|
|
deps = [
|
|
"//packages/compiler",
|
|
"//packages/compiler-cli/src/ngtsc/core",
|
|
"//packages/compiler-cli/src/ngtsc/core:api",
|
|
"//packages/compiler-cli/src/ngtsc/diagnostics",
|
|
"//packages/compiler-cli/src/ngtsc/file_system",
|
|
"//packages/compiler-cli/src/ngtsc/indexer",
|
|
"//packages/compiler-cli/src/ngtsc/perf",
|
|
"//packages/compiler-cli/src/ngtsc/typecheck",
|
|
"@npm//@bazel/typescript",
|
|
"@npm//@types/node",
|
|
"@npm//chokidar",
|
|
"@npm//fs-extra",
|
|
"@npm//minimist",
|
|
"@npm//reflect-metadata",
|
|
"@npm//tsickle",
|
|
"@npm//typescript",
|
|
],
|
|
)
|
|
|
|
pkg_npm(
|
|
name = "npm_package",
|
|
srcs = [
|
|
"package.json",
|
|
],
|
|
tags = [
|
|
"release-with-framework",
|
|
],
|
|
# Do not add more to this list.
|
|
# Dependencies on the full npm_package cause long re-builds.
|
|
visibility = [
|
|
"//integration:__pkg__",
|
|
"//packages/compiler-cli/integrationtest:__pkg__",
|
|
],
|
|
deps = [
|
|
":compiler-cli",
|
|
"//packages/compiler-cli/ngcc",
|
|
],
|
|
)
|
|
|
|
ts_api_guardian_test(
|
|
name = "error_code_api",
|
|
actual = "angular/packages/compiler-cli/npm_package/src/ngtsc/diagnostics/src/error_code.d.ts",
|
|
data = [
|
|
":npm_package",
|
|
"//goldens:public-api",
|
|
],
|
|
golden = "angular/goldens/public-api/compiler-cli/error_code.d.ts",
|
|
)
|
|
|
|
ts_api_guardian_test(
|
|
name = "compiler_options_api",
|
|
actual = "angular/packages/compiler-cli/npm_package/src/ngtsc/core/api/src/public_options.d.ts",
|
|
data = [
|
|
":npm_package",
|
|
"//goldens:public-api",
|
|
],
|
|
golden = "angular/goldens/public-api/compiler-cli/compiler_options.d.ts",
|
|
)
|