Skip to content

Commit daf0d2f

Browse files
committed
build: support linking of Angular libraries with rules_js
For linking of Angular packages we are using something more clever than what we are doing with `rules_nodejs`. Instead of maintaing complexity where we pre-link FESM bundles and somehow inject them into other Bazel bundling steps (with complex linker mappings), we pre-link as part of individual package postinstall steps, exposing the linked bundles via a NodeJS exports condition. This is possible vis this package/script: https://github.com/devversion/angular-linking Clearly this is not at a good location, but it's necessary right now to ship this code via npm because `rules_js` struggles to use pnpm extensions onto workspace 1st-party packages. Long-term we can either decide to keep it that way, move it into e.g. dev-infra repository, or we can explore shipping pre-linked bundles via APF. TBD.
1 parent 90d5efd commit daf0d2f

File tree

5 files changed

+2174
-2025
lines changed

5 files changed

+2174
-2025
lines changed

Diff for: .aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Input hashes for repository rule npm_translate_lock(name = "npm2", pnpm_lock = "@//:pnpm-lock.yaml").
33
# This file should be checked into version control along with the pnpm-lock.yaml file.
44
.npmrc=-2023857461
5-
package.json=-1614639524
6-
pnpm-lock.yaml=-1446385328
5+
package.json=-713547691
6+
pnpm-lock.yaml=-26661838
77
pnpm-workspace.yaml=1711114604
88
yarn.lock=824621907

Diff for: WORKSPACE

+9
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ yarn_install(
115115
"//:tools/postinstall/patches/@angular+bazel+20.0.0-next.1.patch",
116116
"//:tools/postinstall/patches/@angular+build-tooling+0.0.0-1ebf18a3a60b182a3dbad12e9a149fd93af5c29b.patch",
117117
"//:tools/postinstall/patches/@bazel+concatjs+5.8.1.patch",
118+
"//:tools/postinstall/patches/tsec+0.2.2.patch",
118119
],
119120
# Currently disabled due to:
120121
# 1. Missing Windows support currently.
@@ -163,6 +164,14 @@ load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")
163164

164165
npm_translate_lock(
165166
name = "npm2",
167+
custom_postinstalls = {
168+
"@angular/animations": "node ../../@nginfra/angular-linking/index.mjs",
169+
"@angular/common": "node ../../@nginfra/angular-linking/index.mjs",
170+
"@angular/forms": "node ../../@nginfra/angular-linking/index.mjs",
171+
"@angular/platform-browser": "node ../../@nginfra/angular-linking/index.mjs",
172+
"@angular/router": "node ../../@nginfra/angular-linking/index.mjs",
173+
"@angular/localize": "node ../../@nginfra/angular-linking/index.mjs",
174+
},
166175
data = [
167176
"//:package.json",
168177
"//:pnpm-workspace.yaml",

Diff for: package.json

+33-1
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,38 @@
186186
"wrap-ansi": "7.0.0"
187187
},
188188
"pnpm": {
189-
"onlyBuiltDependencies": []
189+
"onlyBuiltDependencies": [],
190+
"packageExtensions": {
191+
"@angular/animations": {
192+
"dependencies": {
193+
"@nginfra/angular-linking": "1.0.0"
194+
}
195+
},
196+
"@angular/common": {
197+
"dependencies": {
198+
"@nginfra/angular-linking": "1.0.0"
199+
}
200+
},
201+
"@angular/forms": {
202+
"dependencies": {
203+
"@nginfra/angular-linking": "1.0.0"
204+
}
205+
},
206+
"@angular/platform-browser": {
207+
"dependencies": {
208+
"@nginfra/angular-linking": "1.0.0"
209+
}
210+
},
211+
"@angular/router": {
212+
"dependencies": {
213+
"@nginfra/angular-linking": "1.0.0"
214+
}
215+
},
216+
"@angular/localize": {
217+
"dependencies": {
218+
"@nginfra/angular-linking": "1.0.0"
219+
}
220+
}
221+
}
190222
}
191223
}

0 commit comments

Comments
 (0)