Skip to content

bazel: make npm/node a dev_dependency, invisible to downstream#10098

Merged
maliberty merged 2 commits intoThe-OpenROAD-Project:masterfrom
oharboe:npm-fixes
Apr 11, 2026
Merged

bazel: make npm/node a dev_dependency, invisible to downstream#10098
maliberty merged 2 commits intoThe-OpenROAD-Project:masterfrom
oharboe:npm-fixes

Conversation

@oharboe
Copy link
Copy Markdown
Collaborator

@oharboe oharboe commented Apr 10, 2026

The aspect_rules_js, rules_nodejs, and their use_extension calls (node toolchain, npm translate_lock) exist solely for JavaScript unit tests in src/web/test/. No production cc_library target depends on npm packages — the JS files are served from disk by the C++ web server.

Changes:

  • Mark bazel_dep entries for aspect_rules_js and rules_nodejs as dev_dependency = True in MODULE.bazel
  • Mark node and npm use_extension calls as dev_dependency = True
  • Remove isolate = True from npm extension (unnecessary when dev_dependency, and it required --experimental_isolated_extension_usages in downstream consumers)
  • Move package.json and pnpm-lock.yaml from src/web/ to src/web/test/
  • Move npm_link_all_packages from src/web/BUILD to src/web/test/BUILD
  • Replace js_library with a plain filegroup for cross-package JS file references (no @aspect_rules_js dependency in production BUILD)

Downstream Bazel consumers no longer inherit npm/node infrastructure, eliminating the need for patches like openroad-remove-isolate.patch.

Tested:

  • All 10 js_test targets in //src/web/test pass
  • Downstream consumer builds without any npm-related patches

The aspect_rules_js, rules_nodejs, and their use_extension calls
(node toolchain, npm translate_lock) exist solely for JavaScript
unit tests in src/web/test/. No production cc_library target
depends on npm packages — the JS files are served from disk by
the C++ web server.

Changes:
- Mark bazel_dep entries for aspect_rules_js and rules_nodejs as
  dev_dependency = True in MODULE.bazel
- Mark node and npm use_extension calls as dev_dependency = True
- Remove isolate = True from npm extension (unnecessary when
  dev_dependency, and it required --experimental_isolated_extension_usages
  in downstream consumers)
- Move package.json and pnpm-lock.yaml from src/web/ to src/web/test/
- Move npm_link_all_packages from src/web/BUILD to src/web/test/BUILD
- Replace js_library with a plain filegroup for cross-package JS
  file references (no @aspect_rules_js dependency in production BUILD)

Downstream Bazel consumers no longer inherit npm/node infrastructure,
eliminating the need for patches like openroad-remove-isolate.patch.

Tested:
- All 10 js_test targets in //src/web/test pass
- Downstream consumer builds without any npm-related patches

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe
Copy link
Copy Markdown
Collaborator Author

oharboe commented Apr 10, 2026

@hzeller FYI

@oharboe oharboe requested a review from maliberty April 10, 2026 08:53
@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the JavaScript build configuration by moving npm dependencies to the test directory and marking them as development dependencies. It replaces the js_library target with a filegroup and updates test targets to use local node modules. A suggestion was made to use variables in the test BUILD file to reduce redundancy and improve maintainability.

Define JS_FILES and DOM_TEST_DATA variables to avoid repeating
the same data and no_copy_to_bin lists across all js_test targets.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe
Copy link
Copy Markdown
Collaborator Author

oharboe commented Apr 10, 2026

/gemini review

@github-actions
Copy link
Copy Markdown
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the JavaScript build and test infrastructure by moving NPM dependencies and the lockfile to the src/web/test directory and marking them as development dependencies. It also simplifies the js_test definitions in src/web/test/BUILD using shared variables. A review comment suggests restricting the visibility of the new js_files filegroup in src/web/BUILD to only the test package for better encapsulation.

Comment on lines +91 to +94
filegroup(
name = "js_files",
srcs = glob(["src/*.js"]),
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better encapsulation, consider restricting the visibility of this filegroup. Since these JavaScript files are only used for tests in //src/web/test, a more specific visibility like visibility = ["//src/web/test:__pkg__"] would be more appropriate than the package's default visibility.

Suggested change
filegroup(
name = "js_files",
srcs = glob(["src/*.js"]),
)
filegroup(
name = "js_files",
srcs = glob(["src/*.js"]),
visibility = ["//src/web/test:__pkg__"],
)

@maliberty maliberty merged commit ed5a5bc into The-OpenROAD-Project:master Apr 11, 2026
16 of 17 checks passed
@oharboe
Copy link
Copy Markdown
Collaborator Author

oharboe commented Apr 11, 2026

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants