Skip to content

Commit 1e5e679

Browse files
committed
build: enable aspect-configure in pnpm-workspaces, adopt recommendations
1 parent 88c28db commit 1e5e679

File tree

8 files changed

+80
-41
lines changed

8 files changed

+80
-41
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
configure:
2+
languages:
3+
javascript: true

pnpm-workspaces/BUILD.bazel

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
1+
load("@aspect_rules_js//js:defs.bzl", "js_library")
12
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
23
load("@npm//:defs.bzl", "npm_link_all_packages")
34
load("@npm//:tsconfig-to-swcconfig/package_json.bzl", tsconfig_to_swcconfig = "bin")
45

5-
# link all dependencies from root package.json
6+
# aspect:generation_mode update
7+
8+
# aspect:map_kind ts_project ts_project //:defs.bzl
9+
10+
# aspect:js enabled
11+
# aspect:js_tsconfig enabled
12+
# aspect:js_npm_package enabled
13+
14+
# aspect:js_files **/*.{js,ts}
15+
# aspect:js_npm_package_target_name pkg
16+
# aspect:js_package_rule_kind js_library
17+
# aspect:js_project_naming_convention tsc
18+
619
npm_link_all_packages(name = "node_modules")
720

821
ts_config(
922
name = "tsconfig",
1023
src = "tsconfig.json",
1124
visibility = ["//visibility:public"],
12-
deps = ["//:node_modules/@tsconfig/node16-strictest"],
25+
deps = [
26+
"//:node_modules/@tsconfig/node16-strictest", #keep
27+
],
1328
)
1429

1530
tsconfig_to_swcconfig.t2s(
@@ -18,3 +33,8 @@ tsconfig_to_swcconfig.t2s(
1833
stdout = ".swcrc",
1934
visibility = ["//:__subpackages__"],
2035
)
36+
37+
js_library(
38+
name = "pkg",
39+
srcs = ["package.json"],
40+
)

pnpm-workspaces/apps/alpha/BUILD.bazel

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
1-
load("@aspect_rules_js//js:defs.bzl", "js_binary")
1+
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_library")
22
load("@npm//:defs.bzl", "npm_link_all_packages")
33
load("//:defs.bzl", "ts_project")
44

55
npm_link_all_packages(name = "node_modules")
66

77
ts_project(
8-
name = "pkg",
8+
name = "tsc",
99
srcs = ["src/main.ts"],
1010
declaration = True,
1111
tsconfig = "//:tsconfig",
1212
deps = [
1313
":node_modules/inspirational-quotes", # this uses the version defined in the local package.json
1414
"//:node_modules/@bazel-poc/one",
1515
"//:node_modules/@bazel-poc/shared",
16-
"//:node_modules/@types/node",
16+
"//:node_modules/@types/node", # keep
1717
"//:node_modules/star-wars-quotes",
1818
],
1919
)
2020

21+
js_library(
22+
name = "pkg",
23+
srcs = ["package.json"],
24+
deps = [":tsc"],
25+
)
26+
2127
js_binary(
2228
name = "main",
2329
data = [":pkg"],

pnpm-workspaces/apps/beta/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_library")
22

33
js_library(
4-
name = "pkg",
4+
name = "tsc",
55
srcs = ["src/main.js"],
66
deps = [
77
"//:node_modules/@bazel-poc/shared",
@@ -13,6 +13,6 @@ js_library(
1313

1414
js_binary(
1515
name = "main",
16-
data = [":pkg"],
16+
data = [":tsc"],
1717
entry_point = "src/main.js",
1818
)
Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
1+
load("@aspect_rules_js//js:defs.bzl", "js_library")
2+
load("@npm//:defs.bzl", "npm_link_all_packages")
23

3-
# make this library available via node_modules
4-
npm_package(
4+
npm_link_all_packages(name = "node_modules")
5+
6+
js_library(
7+
name = "tsc",
8+
srcs = ["src/main.js"],
9+
)
10+
11+
js_library(
512
name = "pkg",
6-
srcs = [
7-
"package.json",
8-
"src/main.js",
9-
],
13+
srcs = ["package.json"],
1014
visibility = ["//visibility:public"],
15+
deps = [":tsc"],
1116
)
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
1+
load("@aspect_rules_js//js:defs.bzl", "js_library")
2+
load("@npm//:defs.bzl", "npm_link_all_packages")
23
load("//:defs.bzl", "ts_project")
34

5+
npm_link_all_packages(name = "node_modules")
6+
47
ts_project(
5-
name = "one_lib",
8+
name = "tsc",
69
srcs = ["src/main.ts"],
710
declaration = True,
811
tsconfig = "//:tsconfig",
912
deps = [
10-
"//:node_modules/@types/node",
13+
"//:node_modules/@types/node", # keep
1114
],
1215
)
1316

14-
# make this library available via node_modules
15-
npm_package(
17+
js_library(
1618
name = "pkg",
17-
srcs = [
18-
"package.json",
19-
":one_lib",
20-
],
19+
srcs = ["package.json"],
2120
visibility = ["//visibility:public"],
21+
deps = [":tsc"],
2222
)
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
1+
load("@aspect_rules_js//js:defs.bzl", "js_library")
2+
load("@npm//:defs.bzl", "npm_link_all_packages")
23
load("//:defs.bzl", "ts_project")
34

5+
npm_link_all_packages(name = "node_modules")
6+
47
ts_project(
5-
name = "shared_lib",
8+
name = "tsc",
69
srcs = ["src/main.ts"],
710
declaration = True,
811
tsconfig = "//:tsconfig",
912
deps = [
10-
"//:node_modules/@types/node",
13+
"//:node_modules/@types/node", # keep
1114
],
1215
)
1316

14-
# make this library available via node_modules
15-
npm_package(
17+
js_library(
1618
name = "pkg",
17-
srcs = [
18-
"package.json",
19-
"src/main.js",
20-
],
19+
srcs = ["package.json"],
2120
visibility = ["//visibility:public"],
21+
deps = [":tsc"],
2222
)
Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
1+
load("@aspect_rules_js//js:defs.bzl", "js_library")
2+
load("@npm//:defs.bzl", "npm_link_all_packages")
23

3-
# make this library available via node_modules
4-
npm_package(
5-
name = "pkg",
6-
srcs = [
7-
"package.json",
8-
"src/main.js",
9-
],
10-
data = [
4+
npm_link_all_packages(name = "node_modules")
5+
6+
js_library(
7+
name = "tsc",
8+
srcs = ["src/main.js"],
9+
deps = [
1110
"//:node_modules/@bazel-poc/first",
1211
"//:node_modules/cowsay",
1312
],
13+
)
14+
15+
js_library(
16+
name = "pkg",
17+
srcs = ["package.json"],
1418
visibility = ["//visibility:public"],
19+
deps = [":tsc"],
1520
)

0 commit comments

Comments
 (0)