diff --git a/MODULE.bazel b/MODULE.bazel index 9d66bbe5ae..495911fc28 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -71,9 +71,9 @@ bazel_dep(name = "tcmalloc", version = "0.0.0-20250927-12f2552") bazel_dep(name = "yaml-cpp", version = "0.9.0") bazel_dep(name = "zlib", version = "1.3.1.bcr.5") -# JavaScript / web UI (src/web uses @npm for bundled assets) -bazel_dep(name = "aspect_rules_js", version = "3.0.2") -bazel_dep(name = "rules_nodejs", version = "6.7.3") +# JavaScript / web UI — only used for JS unit tests in src/web/test +bazel_dep(name = "aspect_rules_js", version = "3.0.2", dev_dependency = True) +bazel_dep(name = "rules_nodejs", version = "6.7.3", dev_dependency = True) # A from source build of QT that allows it to link into OpenROAD. # Building like any other bazel project. scripts in the docker folder @@ -171,17 +171,18 @@ use_repo(pip, "openroad-pip") node = use_extension( "@rules_nodejs//nodejs:extensions.bzl", "node", + dev_dependency = True, ) node.toolchain(node_version = "22.14.0") npm = use_extension( "@aspect_rules_js//npm:extensions.bzl", "npm", - isolate = True, + dev_dependency = True, ) npm.npm_translate_lock( name = "npm", - pnpm_lock = "//src/web:pnpm-lock.yaml", + pnpm_lock = "//src/web/test:pnpm-lock.yaml", ) use_repo(npm, "npm") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index e5387605fb..006d550152 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -1826,7 +1826,7 @@ "@@rules_nodejs+//nodejs:extensions.bzl%node": { "general": { "bzlTransitiveDigest": "4pUxCNc22K4I+6+4Nxu52Hur12tFRfa1JMsN5mdDv60=", - "usagesDigest": "XgjGMMVhkRNv0fH22CXQccYVXE+qXDnSDWsfaLvKd4o=", + "usagesDigest": "2/WrxRCEcTRlp/R9YNdf2FCycgT32EsVVJqIe9crUIg=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, diff --git a/src/web/.gitignore b/src/web/.gitignore index f5ed9f7c4f..8dbedfd910 100644 --- a/src/web/.gitignore +++ b/src/web/.gitignore @@ -1,4 +1,4 @@ *~ test/results +test/node_modules TAGS -node_modules diff --git a/src/web/BUILD b/src/web/BUILD index b01fcc4b73..cda586fe27 100644 --- a/src/web/BUILD +++ b/src/web/BUILD @@ -1,8 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2026, The OpenROAD Authors -load("@aspect_rules_js//js:defs.bzl", "js_library") -load("@npm//:defs.bzl", "npm_link_all_packages") load("@rules_cc//cc:cc_library.bzl", "cc_library") load("//bazel:tcl_encode_or.bzl", "tcl_encode") load("//bazel:tcl_wrap_cc.bzl", "tcl_wrap_cc") @@ -12,8 +10,6 @@ package( features = ["layering_check"], ) -npm_link_all_packages(name = "node_modules") - cc_library( name = "web", srcs = [ @@ -92,6 +88,11 @@ tcl_encode( namespace = "web", ) +filegroup( + name = "js_files", + srcs = glob(["src/*.js"]), +) + tcl_wrap_cc( name = "swig", srcs = [ @@ -108,9 +109,3 @@ tcl_wrap_cc( "//src/odb:swig", ], ) - -js_library( - name = "js_sources", - srcs = glob(["src/*.js"]), - visibility = ["//src/web:__subpackages__"], -) diff --git a/src/web/test/BUILD b/src/web/test/BUILD index 7972d6f27d..ff0c92de54 100644 --- a/src/web/test/BUILD +++ b/src/web/test/BUILD @@ -1,4 +1,5 @@ load("@aspect_rules_js//js:defs.bzl", "js_test") +load("@npm//:defs.bzl", "npm_link_all_packages") # SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2022-2026, The OpenROAD Authors @@ -7,6 +8,8 @@ load("//test:regression.bzl", "regression_test") package(features = ["layering_check"]) +npm_link_all_packages(name = "node_modules") + TESTS = [ ] @@ -33,86 +36,81 @@ filegroup( data = [":test_resources"], ) for test_name in TESTS] +JS_FILES = ["//src/web:js_files"] + +DOM_TEST_DATA = [ + "js/setup-dom.js", + ":node_modules/jsdom", +] + JS_FILES + js_test( name = "coordinates_test", - data = ["//src/web:js_sources"], + data = JS_FILES, entry_point = "js/test-coordinates.js", - no_copy_to_bin = ["//src/web:js_sources"], + no_copy_to_bin = JS_FILES, ) js_test( name = "vis_tree_test", - data = [ - "js/setup-dom.js", - "//src/web:js_sources", - "//src/web:node_modules/jsdom", - ], + data = DOM_TEST_DATA, entry_point = "js/test-vis-tree.js", - no_copy_to_bin = ["//src/web:js_sources"], + no_copy_to_bin = JS_FILES, ) js_test( name = "websocket_manager_test", - data = ["//src/web:js_sources"], + data = JS_FILES, entry_point = "js/test-websocket-manager.js", - no_copy_to_bin = ["//src/web:js_sources"], + no_copy_to_bin = JS_FILES, ) js_test( name = "checkbox_tree_model_test", - data = ["//src/web:js_sources"], + data = JS_FILES, entry_point = "js/test-checkbox-tree-model.js", - no_copy_to_bin = ["//src/web:js_sources"], + no_copy_to_bin = JS_FILES, ) js_test( name = "display_controls_test", - data = ["//src/web:js_sources"], + data = JS_FILES, entry_point = "js/test-display-controls.js", - no_copy_to_bin = ["//src/web:js_sources"], + no_copy_to_bin = JS_FILES, ) js_test( name = "clock_tree_widget_test", - data = ["//src/web:js_sources"], + data = JS_FILES, entry_point = "js/test-clock-tree-widget.js", - no_copy_to_bin = ["//src/web:js_sources"], + no_copy_to_bin = JS_FILES, ) js_test( name = "charts_widget_test", - data = ["//src/web:js_sources"], + data = JS_FILES, entry_point = "js/test-charts-widget.js", - no_copy_to_bin = ["//src/web:js_sources"], + no_copy_to_bin = JS_FILES, ) js_test( name = "inspector_test", - data = [ - "js/setup-dom.js", - "//src/web:js_sources", - "//src/web:node_modules/jsdom", - ], + data = DOM_TEST_DATA, entry_point = "js/test-inspector.js", - no_copy_to_bin = ["//src/web:js_sources"], + no_copy_to_bin = JS_FILES, ) js_test( name = "ruler_test", - data = ["//src/web:js_sources"], + data = JS_FILES, entry_point = "js/test-ruler.js", - no_copy_to_bin = ["//src/web:js_sources"], + no_copy_to_bin = JS_FILES, ) js_test( name = "tcl_completer_test", - data = [ - "js/setup-dom.js", - "//src/web:js_sources", - "//src/web:node_modules/jsdom", - ], + data = DOM_TEST_DATA, entry_point = "js/test-tcl-completer.js", - no_copy_to_bin = ["//src/web:js_sources"], + no_copy_to_bin = JS_FILES, ) cc_test( diff --git a/src/web/package.json b/src/web/test/package.json similarity index 100% rename from src/web/package.json rename to src/web/test/package.json diff --git a/src/web/pnpm-lock.yaml b/src/web/test/pnpm-lock.yaml similarity index 100% rename from src/web/pnpm-lock.yaml rename to src/web/test/pnpm-lock.yaml