feat(bazel): speed up dev-turnaround by bundling types only when packaging (#45405)

Speeds up the dev-turnaround by only bundling types when packaging. Currently
bundling occurs for all the `ng_module` targets in devmode.

This has various positive benefits:

* Avoidance of this rather slower operation in development
* Makes APF-built packages also handle types for `ts_library` targets consistently.
* Allows us to ensure APF entry-points have `d.ts` _always_ bundled (working with ESM
module resolution in TypeScript -- currently experimental)
* Allows us to remove the secondary `package.json` files from APF (maybe APF v14? - seems
low-impact). This would clean-up the APF even more and fix resolution issues (like in Vite)

PR Close #45405
This commit is contained in:
Paul Gschwendtner
2022-03-21 12:24:52 +01:00
committed by Andrew Scott
parent 3dee3d107b
commit 68597bb0ca
54 changed files with 392 additions and 605 deletions
+5 -2
View File
@@ -9,7 +9,7 @@ pkg_npm(
) + [
"//packages/bazel/src:package_assets",
"//packages/bazel/src/ng_module:package_assets",
"//packages/bazel/src/api-extractor:package_assets",
"//packages/bazel/src/types_bundle:package_assets",
"//packages/bazel/src/ng_package:package_assets",
"//packages/bazel/src/ngc-wrapped:package_assets",
"//packages/bazel/third_party/github.com/bazelbuild/bazel/src/main/protobuf:package_assets",
@@ -20,6 +20,9 @@ pkg_npm(
# users having to define the build setting, so we directly point the flag label to the place where
# we expect `@angular/bazel` being located. Note: This expects the `@npm//` workspace to be used.
"//packages/bazel/src:partial_compilation": "@npm//@angular/bazel/src:partial_compilation",
# Substitutions to account for label changes when `@angular/bazel` is consumed externally.
# NodeJS binaries are pre-built and should be consumed through the NPM bin scripts of the package.
"//packages/bazel/src/types_bundle:types_bundler": "@npm//@angular/bazel/bin:types_bundler",
"//packages/bazel/": "//@angular/bazel/",
"@npm//@bazel/concatjs/internal:": "//@bazel/concatjs/internal:",
},
@@ -28,9 +31,9 @@ pkg_npm(
# Dependencies on the full npm_package cause long re-builds.
visibility = ["//integration:__subpackages__"],
deps = [
"//packages/bazel/src/api-extractor:lib",
"//packages/bazel/src/ng_package:lib",
"//packages/bazel/src/ngc-wrapped:ngc_lib",
"//packages/bazel/src/types_bundle:lib",
],
)
# END-DEV-ONLY