@@ -8,13 +8,17 @@ workspace(
88
99load ("@bazel_tools//tools/build_defs/repo:http.bzl" , "http_archive" )
1010
11- # Fetch rules_nodejs so we can install our npm dependencies
11+ # Fetch rules_nodejs and install its dependencies so we can install our npm dependencies.
1212http_archive (
1313 name = "build_bazel_rules_nodejs" ,
14- sha256 = "2644a66772938db8d8c760334a252f1687455daa7e188073f2d46283f2f6fbb7 " ,
15- urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.6.2 /rules_nodejs-4.6.2 .tar.gz" ],
14+ sha256 = "965ee2492a2b087cf9e0f2ca472aeaf1be2eb650e0cfbddf514b9a7d3ea4b02a " ,
15+ urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.2.0 /rules_nodejs-5.2.0 .tar.gz" ],
1616)
1717
18+ load ("@build_bazel_rules_nodejs//:repositories.bzl" , "build_bazel_rules_nodejs_dependencies" )
19+
20+ build_bazel_rules_nodejs_dependencies ()
21+
1822# The PKG rules are needed to build tar packages for integration tests. The builtin
1923# rule in `@bazel_tools` is not Windows compatible and outdated.
2024http_archive (
@@ -34,35 +38,61 @@ http_archive(
3438 url = "https://github.com/aspect-build/bazel-lib/archive/refs/tags/v0.5.0.tar.gz" ,
3539)
3640
37- # Check the rules_nodejs version and download npm dependencies
38- # Note: bazel (version 2 and after) will check the .bazelversion file so we don't need to
39- # assert on that.
40- load ("@build_bazel_rules_nodejs//:index.bzl" , "check_rules_nodejs_version" , "node_repositories" , "yarn_install" )
41+ # Setup the Node.js toolchain.
42+ load ("@rules_nodejs//nodejs:repositories.bzl" , "nodejs_register_toolchains" )
4143
42- check_rules_nodejs_version (minimum_version_string = "2.2.0" )
43-
44- # Setup the Node.js toolchain
45- node_repositories (
44+ nodejs_register_toolchains (
45+ name = "nodejs" ,
4646 node_version = "16.10.0" ,
47- package_json = ["//:package.json" ],
4847)
4948
49+ # Download npm dependencies.
50+ load ("@build_bazel_rules_nodejs//:index.bzl" , "yarn_install" )
5051load ("//integration:npm_package_archives.bzl" , "npm_package_archives" )
5152
5253yarn_install (
5354 name = "npm" ,
54- # Note that we add the postinstall script here so that the dependencies are re-installed
55+ # Note that we add the postinstall scripts here so that the dependencies are re-installed
5556 # when the postinstall patches are modified.
56- data = ["//tools:postinstall-patches.js" ],
57+ data = [
58+ "//:.yarn/releases/yarn-1.22.17.cjs" ,
59+ "//:.yarnrc" ,
60+ "//:scripts/puppeteer-chromedriver-versions.js" ,
61+ "//:scripts/webdriver-manager-update.js" ,
62+ "//tools:postinstall-patches.js" ,
63+ ],
64+ # Currently disabled due to:
65+ # 1. Missing Windows support currently.
66+ # 2. Incompatibilites with the `ts_library` rule.
67+ exports_directories_only = False ,
5768 manual_build_file_contents = npm_package_archives (),
5869 package_json = "//:package.json" ,
70+ # We prefer to symlink the `node_modules` to only maintain a single install.
71+ # See https://github.com/angular/dev-infra/pull/446#issuecomment-1059820287 for details.
72+ symlink_node_modules = True ,
73+ yarn = "//:.yarn/releases/yarn-1.22.17.cjs" ,
5974 yarn_lock = "//:yarn.lock" ,
6075)
6176
6277yarn_install (
6378 name = "aio_npm" ,
79+ # Note that we add the postinstall scripts here so that the dependencies are re-installed
80+ # when the postinstall patches are modified.
81+ data = [
82+ "//:.yarn/releases/yarn-1.22.17.cjs" ,
83+ "//:.yarnrc" ,
84+ "//aio:tools/cli-patches/patch.js" ,
85+ ],
86+ # Currently disabled due to:
87+ # 1. Missing Windows support currently.
88+ # 2. Incompatibilites with the `ts_library` rule.
89+ exports_directories_only = False ,
6490 manual_build_file_contents = npm_package_archives (),
6591 package_json = "//aio:package.json" ,
92+ # We prefer to symlink the `node_modules` to only maintain a single install.
93+ # See https://github.com/angular/dev-infra/pull/446#issuecomment-1059820287 for details.
94+ symlink_node_modules = True ,
95+ yarn = "//:.yarn/releases/yarn-1.22.17.cjs" ,
6696 yarn_lock = "//aio:yarn.lock" ,
6797)
6898
@@ -86,7 +116,9 @@ browser_repositories()
86116
87117load ("@build_bazel_rules_nodejs//toolchains/esbuild:esbuild_repositories.bzl" , "esbuild_repositories" )
88118
89- esbuild_repositories ()
119+ esbuild_repositories (
120+ npm_repository = "npm" ,
121+ )
90122
91123load ("@rules_pkg//:deps.bzl" , "rules_pkg_dependencies" )
92124
0 commit comments