Skip to content

Migrating to 5.0

Alex Eagle edited this page Dec 23, 2021 · 21 revisions

rules_nodejs dependencies

Prior to 5.0, the build_bazel_rules_nodejs workspace had zero starlark dependencies, because transitive handling of them in WORKSPACE was so difficult for users to get right. However now that Bazel 5.0 has bzlmod to manage these transitive dependencies, we feel it's the right time to add dependencies. (Documentation for using rules_nodejs with bzlmod will be added soon)

You need to update your WORKSPACE file to install the dependencies. Note that WORKSPACE ordering is critical, so if you need to override versions of rules_nodejs dependencies, you must do it before this code.

load("@build_bazel_rules_nodejs//nodejs:repositories.bzl", "rules_nodejs_dependencies")

rules_nodejs_dependencies()

Next, you can remove usage of node_repositories, which is now deprecated.

load("@build_bazel_rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains", "rules_nodejs_dependencies")

nodejs_register_toolchains( # You can choose whatever name you like for the node toolchains, or register more than one version. name = "nodejs", )


## Users of vendored_yarn

You'll have to continue using `node_repositories` for now. Follow https://github.com/bazelbuild/rules_nodejs/issues/3175 for a migration path.

## Users of "user managed dependencies"

You`ll have to continue using `node_repositories` for now. We would like to remove this feature. Please tell us in https://github.com/bazelbuild/rules_nodejs/issues/3176 if you still rely on it.

# Updated defaults

Default version of Node is now X
and Yarn is Y
to continue using the previous default:
Z

# Moved

## Toolchain definition

The toolchain name is now controlled by the WORKSPACE file. The hard-coded `@nodejs` repo no longer exists.

In the examples below, we assume you used `name "my_node"` in your call to `nodejs_register_toolchains`.

If you explicitly used a label like `@nodejs//:node`, you can find a platform-specific variant at `@my_node_linux_amd64//:node`.

Custom rules should now use `@rules_nodejs//nodejs:toolchain_type` to request a nodejs toolchain.
Genrules should now use `@my_node_toolchains//:resolved_toolchain`.

See e2e/core for example of using the toolchain.

## angular

`@bazel/angular` is a minimal plugin for the Angular CLI builders system (aka. architect) teaching the `ng` command how to spawn `bazel` for build and test steps.

It has been moved from this repo and can now be found in https://github.com/just-jeb/angular-builders
Thanks to @just-jeb for taking on maintenance of this code!

## labs

The `@bazel/labs` package has been removed, and is no longer published to npm. This repo doesn't contain support for protocol buffers or gRPC.

## ts_library

The `ts_library` rule is now in the `@bazel/concatjs` package.

# Reduced maintenance scope

The concatjs package is now in "maintenance mode". Since no one from Google participates in rules_nodejs, it has been impossible for us to keep this code up-to-date with what Google develops internally, and it is a complex package that OSS maintainers don't have time for.



Clone this wiki locally