Skip to content

Commit ed5a5bc

Browse files
authored
Merge pull request #10098 from oharboe/npm-fixes
bazel: make npm/node a dev_dependency, invisible to downstream
2 parents 3ab4b4a + b43a09a commit ed5a5bc

7 files changed

Lines changed: 43 additions & 49 deletions

File tree

MODULE.bazel

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ bazel_dep(name = "tcmalloc", version = "0.0.0-20250927-12f2552")
7171
bazel_dep(name = "yaml-cpp", version = "0.9.0")
7272
bazel_dep(name = "zlib", version = "1.3.1.bcr.5")
7373

74-
# JavaScript / web UI (src/web uses @npm for bundled assets)
75-
bazel_dep(name = "aspect_rules_js", version = "3.0.2")
76-
bazel_dep(name = "rules_nodejs", version = "6.7.3")
74+
# JavaScript / web UI — only used for JS unit tests in src/web/test
75+
bazel_dep(name = "aspect_rules_js", version = "3.0.2", dev_dependency = True)
76+
bazel_dep(name = "rules_nodejs", version = "6.7.3", dev_dependency = True)
7777

7878
# A from source build of QT that allows it to link into OpenROAD.
7979
# Building like any other bazel project. scripts in the docker folder
@@ -171,17 +171,18 @@ use_repo(pip, "openroad-pip")
171171
node = use_extension(
172172
"@rules_nodejs//nodejs:extensions.bzl",
173173
"node",
174+
dev_dependency = True,
174175
)
175176
node.toolchain(node_version = "22.14.0")
176177

177178
npm = use_extension(
178179
"@aspect_rules_js//npm:extensions.bzl",
179180
"npm",
180-
isolate = True,
181+
dev_dependency = True,
181182
)
182183
npm.npm_translate_lock(
183184
name = "npm",
184-
pnpm_lock = "//src/web:pnpm-lock.yaml",
185+
pnpm_lock = "//src/web/test:pnpm-lock.yaml",
185186
)
186187
use_repo(npm, "npm")
187188

MODULE.bazel.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/web/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
*~
22
test/results
3+
test/node_modules
34
TAGS
4-
node_modules

src/web/BUILD

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2026, The OpenROAD Authors
33

4-
load("@aspect_rules_js//js:defs.bzl", "js_library")
5-
load("@npm//:defs.bzl", "npm_link_all_packages")
64
load("@rules_cc//cc:cc_library.bzl", "cc_library")
75
load("//bazel:tcl_encode_or.bzl", "tcl_encode")
86
load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc")
@@ -12,8 +10,6 @@ package(
1210
features = ["layering_check"],
1311
)
1412

15-
npm_link_all_packages(name = "node_modules")
16-
1713
cc_library(
1814
name = "web",
1915
srcs = [
@@ -92,6 +88,11 @@ tcl_encode(
9288
namespace = "web",
9389
)
9490

91+
filegroup(
92+
name = "js_files",
93+
srcs = glob(["src/*.js"]),
94+
)
95+
9596
tcl_wrap_cc(
9697
name = "swig",
9798
srcs = [
@@ -108,9 +109,3 @@ tcl_wrap_cc(
108109
"//src/odb:swig",
109110
],
110111
)
111-
112-
js_library(
113-
name = "js_sources",
114-
srcs = glob(["src/*.js"]),
115-
visibility = ["//src/web:__subpackages__"],
116-
)

src/web/test/BUILD

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@aspect_rules_js//js:defs.bzl", "js_test")
2+
load("@npm//:defs.bzl", "npm_link_all_packages")
23

34
# SPDX-License-Identifier: BSD-3-Clause
45
# Copyright (c) 2022-2026, The OpenROAD Authors
@@ -7,6 +8,8 @@ load("//test:regression.bzl", "regression_test")
78

89
package(features = ["layering_check"])
910

11+
npm_link_all_packages(name = "node_modules")
12+
1013
TESTS = [
1114
]
1215

@@ -33,86 +36,81 @@ filegroup(
3336
data = [":test_resources"],
3437
) for test_name in TESTS]
3538

39+
JS_FILES = ["//src/web:js_files"]
40+
41+
DOM_TEST_DATA = [
42+
"js/setup-dom.js",
43+
":node_modules/jsdom",
44+
] + JS_FILES
45+
3646
js_test(
3747
name = "coordinates_test",
38-
data = ["//src/web:js_sources"],
48+
data = JS_FILES,
3949
entry_point = "js/test-coordinates.js",
40-
no_copy_to_bin = ["//src/web:js_sources"],
50+
no_copy_to_bin = JS_FILES,
4151
)
4252

4353
js_test(
4454
name = "vis_tree_test",
45-
data = [
46-
"js/setup-dom.js",
47-
"//src/web:js_sources",
48-
"//src/web:node_modules/jsdom",
49-
],
55+
data = DOM_TEST_DATA,
5056
entry_point = "js/test-vis-tree.js",
51-
no_copy_to_bin = ["//src/web:js_sources"],
57+
no_copy_to_bin = JS_FILES,
5258
)
5359

5460
js_test(
5561
name = "websocket_manager_test",
56-
data = ["//src/web:js_sources"],
62+
data = JS_FILES,
5763
entry_point = "js/test-websocket-manager.js",
58-
no_copy_to_bin = ["//src/web:js_sources"],
64+
no_copy_to_bin = JS_FILES,
5965
)
6066

6167
js_test(
6268
name = "checkbox_tree_model_test",
63-
data = ["//src/web:js_sources"],
69+
data = JS_FILES,
6470
entry_point = "js/test-checkbox-tree-model.js",
65-
no_copy_to_bin = ["//src/web:js_sources"],
71+
no_copy_to_bin = JS_FILES,
6672
)
6773

6874
js_test(
6975
name = "display_controls_test",
70-
data = ["//src/web:js_sources"],
76+
data = JS_FILES,
7177
entry_point = "js/test-display-controls.js",
72-
no_copy_to_bin = ["//src/web:js_sources"],
78+
no_copy_to_bin = JS_FILES,
7379
)
7480

7581
js_test(
7682
name = "clock_tree_widget_test",
77-
data = ["//src/web:js_sources"],
83+
data = JS_FILES,
7884
entry_point = "js/test-clock-tree-widget.js",
79-
no_copy_to_bin = ["//src/web:js_sources"],
85+
no_copy_to_bin = JS_FILES,
8086
)
8187

8288
js_test(
8389
name = "charts_widget_test",
84-
data = ["//src/web:js_sources"],
90+
data = JS_FILES,
8591
entry_point = "js/test-charts-widget.js",
86-
no_copy_to_bin = ["//src/web:js_sources"],
92+
no_copy_to_bin = JS_FILES,
8793
)
8894

8995
js_test(
9096
name = "inspector_test",
91-
data = [
92-
"js/setup-dom.js",
93-
"//src/web:js_sources",
94-
"//src/web:node_modules/jsdom",
95-
],
97+
data = DOM_TEST_DATA,
9698
entry_point = "js/test-inspector.js",
97-
no_copy_to_bin = ["//src/web:js_sources"],
99+
no_copy_to_bin = JS_FILES,
98100
)
99101

100102
js_test(
101103
name = "ruler_test",
102-
data = ["//src/web:js_sources"],
104+
data = JS_FILES,
103105
entry_point = "js/test-ruler.js",
104-
no_copy_to_bin = ["//src/web:js_sources"],
106+
no_copy_to_bin = JS_FILES,
105107
)
106108

107109
js_test(
108110
name = "tcl_completer_test",
109-
data = [
110-
"js/setup-dom.js",
111-
"//src/web:js_sources",
112-
"//src/web:node_modules/jsdom",
113-
],
111+
data = DOM_TEST_DATA,
114112
entry_point = "js/test-tcl-completer.js",
115-
no_copy_to_bin = ["//src/web:js_sources"],
113+
no_copy_to_bin = JS_FILES,
116114
)
117115

118116
cc_test(

0 commit comments

Comments
 (0)