@@ -2,6 +2,8 @@ load("@aio_npm//@angular-devkit/architect-cli:index.bzl", "architect", "architec
22load ("@build_bazel_rules_nodejs//:index.bzl" , "npm_package_bin" )
33load ("//aio/tools:defaults.bzl" , "nodejs_binary" )
44load ("@aspect_bazel_lib//lib:copy_to_directory.bzl" , "copy_to_directory" )
5+ load (":local_packages_util.bzl" , "link_local_packages" , "substitute_local_packages" )
6+ load ("@bazel_skylib//rules:common_settings.bzl" , "bool_flag" )
57
68# The write_source_files macro is used to write bazel outputs to the source tree and test that they are up to date.
79# See: https://docs.aspect.build/aspect-build/bazel-lib/v0.5.0/docs/docs/write_source_files-docgen.html
@@ -12,6 +14,19 @@ exports_files([
1214 "ngsw-config.template.json" ,
1315])
1416
17+ # If set will use first party angular deps for aio targets instead of their npm equivalent
18+ bool_flag (
19+ name = "flag_aio_local_deps" ,
20+ build_setting_default = False ,
21+ )
22+
23+ config_setting (
24+ name = "aio_local_deps" ,
25+ flag_values = {
26+ ":flag_aio_local_deps" : "true" ,
27+ },
28+ )
29+
1530# Generate ngsw-config
1631npm_package_bin (
1732 name = "ngsw-config" ,
@@ -153,6 +168,10 @@ E2E_DEPS = APPLICATION_DEPS + [
153168 "@aio_npm//ts-node" ,
154169]
155170
171+ # Stamp npm_link targets for all dependencies that correspond to a
172+ # first-party equivalent pacakge in angular.
173+ link_local_packages (deps = APPLICATION_DEPS )
174+
156175architect (
157176 name = "build" ,
158177 args = [
@@ -161,7 +180,10 @@ architect(
161180 ],
162181 chdir = package_name (),
163182 configuration_env_vars = ["NG_BUILD_CACHE" ],
164- data = APPLICATION_FILES + APPLICATION_DEPS ,
183+ data = APPLICATION_FILES + select ({
184+ ":aio_local_deps" : substitute_local_packages (APPLICATION_DEPS ),
185+ "//conditions:default" : APPLICATION_DEPS ,
186+ }),
165187 output_dir = True ,
166188)
167189
@@ -173,7 +195,10 @@ architect_test(
173195 ],
174196 chdir = package_name (),
175197 configuration_env_vars = ["NG_BUILD_CACHE" ],
176- data = TEST_FILES + TEST_DEPS ,
198+ data = TEST_FILES + select ({
199+ ":aio_local_deps" : substitute_local_packages (TEST_DEPS ),
200+ "//conditions:default" : TEST_DEPS ,
201+ }),
177202 env = {
178203 "CHROME_BIN" : "../$(CHROMIUM)" ,
179204 },
@@ -187,10 +212,14 @@ architect_test(
187212 args = [
188213 "site:e2e" ,
189214 "--no-webdriver-update" ,
215+ "--port=0" ,
190216 ],
191217 chdir = package_name (),
192218 configuration_env_vars = ["NG_BUILD_CACHE" ],
193- data = E2E_FILES + E2E_DEPS ,
219+ data = E2E_FILES + select ({
220+ ":aio_local_deps" : substitute_local_packages (E2E_DEPS ),
221+ "//conditions:default" : E2E_DEPS ,
222+ }),
194223 env = {
195224 "CHROME_BIN" : "../$(CHROMIUM)" ,
196225 "CHROMEDRIVER_BIN" : "../$(CHROMEDRIVER)" ,
@@ -207,20 +236,28 @@ architect(
207236 "site:serve" ,
208237 ],
209238 chdir = package_name (),
210- data = APPLICATION_DEPS + APPLICATION_FILES ,
239+ data = APPLICATION_FILES + select ({
240+ ":aio_local_deps" : substitute_local_packages (APPLICATION_DEPS ),
241+ "//conditions:default" : APPLICATION_DEPS ,
242+ }),
211243 tags = ["ibazel_notify_changes" ],
212244)
213245
214246# Build and serve the app, watch for changes, and run a fast but low-fidelity
215247# rebuild when docs change. Watching and serving is a part of the node script,
216248# so there is no need to run with ibazel, which would be slow as it would redo
217249# the full dgeni build on each change.
250+
218251nodejs_binary (
219252 name = "fast-serve" ,
220253 chdir = package_name (),
221- data = APPLICATION_DEPS + APPLICATION_FILES + [
254+ data = APPLICATION_FILES + [
222255 "//aio/scripts:fast-serve-and-watch" ,
223- ],
256+ ] + select ({
257+ ":aio_local_deps" : substitute_local_packages (APPLICATION_DEPS ),
258+ "//conditions:default" : APPLICATION_DEPS ,
259+ }),
260+ enable_linker = True ,
224261 entry_point = "//aio/scripts:fast-serve-and-watch.js" ,
225262 env = {
226263 # Tell dgeni packages where the project root is since we used chdir
0 commit comments