2019-01-16 04:19:01 -05:00
|
|
|
load("//tools:defaults.bzl", "ts_library")
|
2018-07-16 03:49:56 -04:00
|
|
|
|
2019-01-16 04:19:01 -05:00
|
|
|
package(default_visibility = ["//visibility:public"])
|
2018-07-16 03:49:56 -04:00
|
|
|
|
|
|
|
ts_library(
|
|
|
|
name = "ngcc",
|
|
|
|
srcs = glob([
|
|
|
|
"*.ts",
|
|
|
|
"**/*.ts",
|
|
|
|
]),
|
2019-06-06 15:22:32 -04:00
|
|
|
tsconfig = "//packages/compiler-cli:tsconfig",
|
2018-07-16 03:49:56 -04:00
|
|
|
deps = [
|
|
|
|
"//packages:types",
|
|
|
|
"//packages/compiler",
|
2020-03-20 18:09:40 -04:00
|
|
|
"//packages/compiler-cli",
|
2018-07-16 03:49:56 -04:00
|
|
|
"//packages/compiler-cli/src/ngtsc/annotations",
|
feat(ivy): detect cycles and use remote scoping of components if needed (#28169)
By its nature, Ivy alters the import graph of a TS program, adding imports
where template dependencies exist. For example, if ComponentA uses PipeB
in its template, Ivy will insert an import of PipeB into the file in which
ComponentA is declared.
Any insertion of an import into a program has the potential to introduce a
cycle into the import graph. If for some reason the file in which PipeB is
declared imports the file in which ComponentA is declared (maybe it makes
use of a service or utility function that happens to be in the same file as
ComponentA) then this could create an import cycle. This turns out to
happen quite regularly in larger Angular codebases.
TypeScript and the Ivy runtime have no issues with such cycles. However,
other tools are not so accepting. In particular the Closure Compiler is
very anti-cycle.
To mitigate this problem, it's necessary to detect when the insertion of
an import would create a cycle. ngtsc can then use a different strategy,
known as "remote scoping", instead of directly writing a reference from
one component to another. Under remote scoping, a function
'setComponentScope' is called after the declaration of the component's
module, which does not require the addition of new imports.
FW-647 #resolve
PR Close #28169
2019-01-15 15:32:10 -05:00
|
|
|
"//packages/compiler-cli/src/ngtsc/cycles",
|
2019-07-18 16:05:32 -04:00
|
|
|
"//packages/compiler-cli/src/ngtsc/diagnostics",
|
2019-06-06 15:22:32 -04:00
|
|
|
"//packages/compiler-cli/src/ngtsc/file_system",
|
2018-12-18 12:48:15 -05:00
|
|
|
"//packages/compiler-cli/src/ngtsc/imports",
|
perf(ivy): reuse prior analysis work during incremental builds (#34288)
Previously, the compiler performed an incremental build by analyzing and
resolving all classes in the program (even unchanged ones) and then using
the dependency graph information to determine which .js files were stale and
needed to be re-emitted. This algorithm produced "correct" rebuilds, but the
cost of re-analyzing the entire program turned out to be higher than
anticipated, especially for component-heavy compilations.
To achieve performant rebuilds, it is necessary to reuse previous analysis
results if possible. Doing this safely requires knowing when prior work is
viable and when it is stale and needs to be re-done.
The new algorithm implemented by this commit is such:
1) Each incremental build starts with knowledge of the last known good
dependency graph and analysis results from the last successful build,
plus of course information about the set of files changed.
2) The previous dependency graph's information is used to determine the
set of source files which have "logically" changed. A source file is
considered logically changed if it or any of its dependencies have
physically changed (on disk) since the last successful compilation. Any
logically unchanged dependencies have their dependency information copied
over to the new dependency graph.
3) During the `TraitCompiler`'s loop to consider all source files in the
program, if a source file is logically unchanged then its previous
analyses are "adopted" (and their 'register' steps are run). If the file
is logically changed, then it is re-analyzed as usual.
4) Then, incremental build proceeds as before, with the new dependency graph
being used to determine the set of files which require re-emitting.
This analysis reuse avoids template parsing operations in many circumstances
and significantly reduces the time it takes ngtsc to rebuild a large
application.
Future work will increase performance even more, by tackling a variety of
other opportunities to reuse or avoid work.
PR Close #34288
2019-12-05 19:03:17 -05:00
|
|
|
"//packages/compiler-cli/src/ngtsc/incremental:api",
|
2020-05-14 15:06:12 -04:00
|
|
|
"//packages/compiler-cli/src/ngtsc/logging",
|
2019-03-26 17:02:16 -04:00
|
|
|
"//packages/compiler-cli/src/ngtsc/metadata",
|
2018-12-18 12:48:15 -05:00
|
|
|
"//packages/compiler-cli/src/ngtsc/partial_evaluator",
|
2019-03-18 14:16:38 -04:00
|
|
|
"//packages/compiler-cli/src/ngtsc/perf",
|
2018-12-18 12:48:15 -05:00
|
|
|
"//packages/compiler-cli/src/ngtsc/reflection",
|
2019-02-19 15:05:03 -05:00
|
|
|
"//packages/compiler-cli/src/ngtsc/scope",
|
2018-07-16 03:49:56 -04:00
|
|
|
"//packages/compiler-cli/src/ngtsc/transform",
|
2018-09-21 15:15:06 -04:00
|
|
|
"//packages/compiler-cli/src/ngtsc/translator",
|
2019-02-14 12:59:46 -05:00
|
|
|
"//packages/compiler-cli/src/ngtsc/util",
|
2019-02-20 12:54:42 -05:00
|
|
|
"@npm//@types/convert-source-map",
|
|
|
|
"@npm//@types/node",
|
2019-10-04 06:54:33 -04:00
|
|
|
"@npm//@types/semver",
|
2019-02-20 12:54:42 -05:00
|
|
|
"@npm//@types/yargs",
|
|
|
|
"@npm//canonical-path",
|
|
|
|
"@npm//dependency-graph",
|
|
|
|
"@npm//magic-string",
|
2019-10-04 06:54:33 -04:00
|
|
|
"@npm//semver",
|
2019-02-20 12:54:42 -05:00
|
|
|
"@npm//source-map",
|
2020-02-16 15:07:30 -05:00
|
|
|
"@npm//sourcemap-codec",
|
2019-02-20 12:54:42 -05:00
|
|
|
"@npm//typescript",
|
2018-07-16 03:49:56 -04:00
|
|
|
],
|
|
|
|
)
|