diff --git a/BUILD.bazel b/BUILD.bazel index 06ade523..e07f5e4a 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -3,6 +3,7 @@ load("@bazel_skylib//lib:dicts.bzl", "dicts") load("@bazel_skylib//rules:build_test.bzl", "build_test") load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm") load("@npm//@bazel/typescript:index.bzl", "ts_config") +load("@npm_rules_js//:defs.bzl", "npm_link_all_packages") load("//tools:publish.bzl", "publish_files") load("//:index.bzl", "prerender_component", "prerender_component_publish_files") @@ -15,6 +16,8 @@ ts_config( deps = ["tsconfig.json"], ) +npm_link_all_packages(name = "node_modules") + bzl_library( name = "rules_prerender", srcs = [ diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index 6ccb6700..6e012205 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -18,11 +18,20 @@ http_archive( sha256 = "2b2004784358655f334925e7eadc7ba80f701144363df949b3293e1ae7a2fb7b", urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.4.0/rules_nodejs-5.4.0.tar.gz"], ) - -# Load `rules_nodejs` dependencies. load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies") build_bazel_rules_nodejs_dependencies() +# Load `@aspect_rules_js`. +http_archive( + name = "aspect_rules_js", + sha256 = "80e168f9cd62f3640de429b70b34ff817d0d94ada2abaf2cffeef46e35434e1d", + strip_prefix = "rules_js-1.0.0-rc.1", + url = "https://github.com/aspect-build/rules_js/archive/refs/tags/v1.0.0-rc.1.tar.gz", +) + +load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies") +rules_js_dependencies() + # Set the NodeJS version. load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains") nodejs_register_toolchains( @@ -44,6 +53,19 @@ npm_install( exports_directories_only = False, ) +# Load the `@aspect_rules_js` version of the `@npm` workspace. Named `@npm_rules_js` to avoid +# conflicting with the existing workspace from `@build_bazel_rules_nodejs`. +# TODO(#48): Rename to `@npm` once migrated off `@build_bazel_rules_nodejs`. +load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock") +npm_translate_lock( + name = "npm_rules_js", + pnpm_lock = "//:pnpm-lock.yaml", + verify_node_modules_ignored = "//:.bazelignore", +) + +load("@npm_rules_js//:repositories.bzl", "npm_repositories") +npm_repositories() + # Load bazel_skylib. http_archive( name = "bazel_skylib",