mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Creates, a currently still unused, Bazel transition that will control a build setting that is enabling the partial compilation mode for `ng_module` rule targets. This is in preparation of implementing the Angular Package Format v13 (which should ship in partial compilation). Note: Various other approaches aside from the `transition` has been considered. Here is a small summary of the largest ideas that have been tried for the APF v13 partial compilation refactor. **Using an aspect for partial compilation in `ng_package`** Similar to how we had an aspect for ESM5 compilation in the past, an aspect could be used to create partial compilation prodmode output for packaging. The aspect would take the existing prodmode compilation details and "replay" the compilation with a modified tsconfig that enables partial compilation. This _can_ work but requires lots of caution and is very prone to issues. In order to avoid conflicts with the existing prodmode output, the partial compilation outputs would need to be written to a sub-directory. This makes module resolution extremely difficult when `ng_package` creates the FESM bundles. Also it is difficult to merge multiple of these aspect-compiled folders into a single one for exposing the non-bundled ESM output. It becomes especially difficult to ensure that such an aspect target will actually use the _correct_ dependency type definition when compiled. e.g. consider a case where a partial compiled target relies on another Angular target. The dependency will be compiled partially first, but the other target _needs_ to rely on the partial compilation `d.ts` output of the dependency (and *NOT* the devmode `.d.ts` output). This is incorrect and can cause other type-checking issues / or invalid output. To make this work, the module resolution when invoking tsc_wrapped would also need to be updated/patched. This is out of scope and not reasonable to maintain. **Exposing a third output flavor directly in the rule** Instead of replying a compilation, we could expose an output flavor next to `devmode` and `prodmode`. This sounded like the easiest solution at first, but it will have the same problems as the aspect approach (in terms of module resoltion and avoiding conflicts of files). We cannot control how TS emits `.d.ts` or `.js` files (without patching into the compiler host), so we would need to store the compilation output in a sub-folder similar to the aspect.. resulting in the same issues. This is do-able but would require module resolution to be patched and we do not have control over `@bazel/typescript`. Also, `@bazel/typescript` does not forsee a third output flavor, so that logic would need to be changed significantly as well. PR Close #43431
16 lines
404 B
Text
16 lines
404 B
Text
load("//packages/bazel/src/ng_module:partial_compilation.bzl", "ng_partial_compilation_flag")
|
|
|
|
# BEGIN-DEV-ONLY
|
|
package(default_visibility = ["//packages/bazel:__subpackages__"])
|
|
|
|
filegroup(
|
|
name = "package_assets",
|
|
srcs = glob(["*"]),
|
|
)
|
|
# END-DEV-ONLY
|
|
|
|
ng_partial_compilation_flag(
|
|
name = "partial_compilation",
|
|
build_setting_default = False,
|
|
visibility = ["//visibility:public"],
|
|
)
|