Skip to content

Commit 0496438

Browse files
committed
build: fix yarn install with angular-linking and avoid tsec errors
* Tsec expects all rules to have `deps`. This is not true for the new RJS `//:node_modules/x` targets. * Yarn currently doesn't know about the `angular-linking` workspace, so we need to configure that properly.
1 parent c1306c1 commit 0496438

File tree

7 files changed

+47
-13
lines changed

7 files changed

+47
-13
lines changed

.aspect/rules/external_repository_action_cache/npm_translate_lock_MzA5NzUwNzMx

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
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=-1210026051
6-
pnpm-lock.yaml=-803790935
5+
.pnpmfile.cjs=1191807371
6+
package.json=1476467266
7+
pnpm-lock.yaml=1713526192
78
pnpm-workspace.yaml=-1443514472
89
tools/bazel/angular-linking/index.mjs=475293377
910
tools/bazel/angular-linking/package.json=-115142019
10-
yarn.lock=-770490238
11+
yarn.lock=824621907

.pnpmfile.cjs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = {
2+
hooks: {
3+
readPackage: pkg => {
4+
if (pkg.name === 'components-srcs') {
5+
// Add the linking dependency so that `rules_js` makes it available.
6+
// Note that we can't directly add it to the `package.json` due to our hybrid Yarn setup.
7+
// TODO(devversion): Remove this when yarn.lock is removed.
8+
pkg.dependencies['@devinfra/angular-linking'] = 'workspace:*';
9+
}
10+
return pkg;
11+
},
12+
},
13+
};

WORKSPACE

+5-2
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ 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",
119+
"//tools/bazel/angular-linking:package.json",
118120
],
119121
# Currently disabled due to:
120122
# 1. Missing Windows support currently.
@@ -164,14 +166,15 @@ load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")
164166
npm_translate_lock(
165167
name = "npm2",
166168
custom_postinstalls = {
167-
"@angular/animations": "node ../../@devinfra/angular-linking/index.mjs",
168-
"@angular/common": "node ../../@devinfra/angular-linking/index.mjs",
169+
"@angular/animations": "ls . && ls ../ && ls ../.. && node ../../@devinfra/angular-linking/index.mjs",
170+
"@angular/common": "ls -alh ../.. && node ../../@devinfra/angular-linking/index.mjs",
169171
"@angular/forms": "node ../../@devinfra/angular-linking/index.mjs",
170172
"@angular/platform-browser": "node ../../@devinfra/angular-linking/index.mjs",
171173
"@angular/router": "node ../../@devinfra/angular-linking/index.mjs",
172174
"@angular/localize": "node ../../@devinfra/angular-linking/index.mjs",
173175
},
174176
data = [
177+
"//:.pnpmfile.cjs",
175178
"//:package.json",
176179
"//:pnpm-workspace.yaml",
177180
"//tools/bazel/angular-linking:index.mjs",

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@
9797
"@bazel/runfiles": "5.8.1",
9898
"@bazel/terser": "5.8.1",
9999
"@bazel/worker": "5.8.1",
100-
"@devinfra/angular-linking": "link:tools/bazel/angular-linking",
101100
"@firebase/app-types": "^0.7.0",
102101
"@material/material-color-utilities": "^0.3.0",
103102
"@octokit/rest": "18.3.5",

pnpm-lock.yaml

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/node_modules/tsec/index.bzl b/node_modules/tsec/index.bzl
2+
index d2c2df7..f5bde10 100644
3+
--- a/node_modules/tsec/index.bzl
4+
+++ b/node_modules/tsec/index.bzl
5+
@@ -16,7 +16,7 @@ def _capture_tsec_attrs_aspect_impl(target, ctx):
6+
node_modules_root = None
7+
if module_name:
8+
paths[module_name] = target.label.package
9+
- for d in ctx.rule.attr.deps:
10+
+ for d in getattr(ctx.rule.attr, "deps", []):
11+
if TsecTargetInfo in d:
12+
paths.update(d[TsecTargetInfo].paths)
13+
if DeclarationInfo in d:
14+
@@ -25,7 +25,7 @@ def _capture_tsec_attrs_aspect_impl(target, ctx):
15+
node_modules_root = "/".join(["external", d[NpmPackageInfo].workspace, "node_modules"])
16+
return [
17+
TsecTargetInfo(
18+
- srcs = ctx.rule.attr.srcs,
19+
+ srcs = getattr(ctx.rule.attr, "srcs", []),
20+
deps = depset(transitive = deps),
21+
module_name = module_name,
22+
paths = paths,

yarn.lock

-4
Original file line numberDiff line numberDiff line change
@@ -1585,10 +1585,6 @@
15851585
enabled "2.0.x"
15861586
kuler "^2.0.0"
15871587

1588-
"@devinfra/angular-linking@link:tools/bazel/angular-linking":
1589-
version "0.0.0"
1590-
uid ""
1591-
15921588
"@discoveryjs/[email protected]":
15931589
version "0.6.3"
15941590
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.6.3.tgz#f13c7c205915eb91ae54c557f5e92bddd8be0e83"

0 commit comments

Comments
 (0)