Many companies are successfully building with rules_js.
If you're getting value from the project, please let us know!
Just comment on our Adoption Discussion.
Using Bzlmod with Bazel 6:
Add to your MODULE.bazel
file:
bazel_dep(name = "aspect_rules_js", version = "2.2.0")
####### Node.js version #########
# By default you get the node version from DEFAULT_NODE_VERSION in @rules_nodejs//nodejs:repositories.bzl
# Optionally you can pin a different node version:
bazel_dep(name = "rules_nodejs", version = "6.3.0")
node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node", dev_dependency = True)
node.toolchain(node_version = "16.14.2")
#################################
npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)
npm.npm_translate_lock(
name = "npm",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)
use_repo(npm, "npm")
pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm")
# Allows developers to use the matching pnpm version, for example:
# bazel run -- @pnpm --dir /home/runner/work/rules_js/rules_js install
use_repo(pnpm, "pnpm")
Using WORKSPACE
Paste this snippet into your WORKSPACE
file:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "aspect_rules_js",
sha256 = "d66f8abf914a0454a69181b7b17acaae56d7b0e2784cb26b40cb3273c4d836d1",
strip_prefix = "rules_js-2.2.0",
url = "https://github.com/aspect-build/rules_js/releases/download/v2.2.0/rules_js-v2.2.0.tar.gz",
)
load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")
rules_js_dependencies()
load("@aspect_rules_js//js:toolchains.bzl", "DEFAULT_NODE_VERSION", "rules_js_register_toolchains")
rules_js_register_toolchains(node_version = DEFAULT_NODE_VERSION)
load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")
npm_translate_lock(
name = "npm",
npmrc = "//:.npmrc",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
)
load("@npm//:repositories.bzl", "npm_repositories")
npm_repositories()
What's Changed
- refactor: fix locale spam from tar by @alexeagle in #2079
- Use Label.repo_name instead of Label.workspace_name by @EdSchouten in #2082
- feat: add exclude patterns for npm packages by @Mivr in #2078
- refactor(bazel 8): point out ignore_directories function by @alexeagle in #2053
- chore: add latest pnpm 9.15.{3,4,5} versions by @github-actions in #2058
- chore(deps): update aspect to v1.1.0 by @renovate in #2007
- chore: mirror external pnpm v10 releases by @jbedard in #2102
- chore: remove unused rules_go dev dep by @jbedard in #2087
- Add example pnpm workspace configuration by @sbussard in #2105
- fix(coverage): ensure js_library#srcs are instrumented for coverage by @alexeagle in #2106
- Changes by create-pull-request action by @github-actions in #2104
- chore(deps): update dependency buildifier_prebuilt to v8 by @renovate in #2097
- devserver: use readline instead of reading from raw stdin by @dmiller-figma in #2099
- chore(deps): update dependency bazel to v7.5.0 by @renovate in #2084
New Contributors
- @EdSchouten made their first contribution in #2082
- @sbussard made their first contribution in #2105
- @dmiller-figma made their first contribution in #2099
Full Changelog: v2.1.3...v2.2.0