|
| 1 | +"aspect-build/rules_js" |
| 2 | + |
| 3 | +module( |
| 4 | + name = "aspect_rules_js", |
| 5 | + bazel_compatibility = [">=6.0.0"], |
| 6 | + compatibility_level = 1, |
| 7 | + version = "2.8.1", |
| 8 | +) |
| 9 | + |
| 10 | +# Lower-bounds (minimum) versions for direct runtime dependencies. |
| 11 | +# Do not bump these unless rules_js requires a newer version to function. |
| 12 | +bazel_dep(name = "aspect_bazel_lib", version = "2.17.1") # TODO(alexeagle): remove |
| 13 | +bazel_dep(name = "aspect_tools_telemetry", version = "0.2.8") |
| 14 | +bazel_dep(name = "bazel_features", version = "1.9.0") |
| 15 | +bazel_dep(name = "bazel_lib", version = "3.0.0") |
| 16 | +bazel_dep(name = "bazel_skylib", version = "1.5.0") |
| 17 | +bazel_dep(name = "platforms", version = "0.0.5") |
| 18 | +bazel_dep(name = "rules_nodejs", version = "6.3.0") |
| 19 | + |
| 20 | +tel = use_extension("@aspect_tools_telemetry//:extension.bzl", "telemetry") |
| 21 | +use_repo(tel, "aspect_tools_telemetry_report") |
| 22 | + |
| 23 | +node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node") |
| 24 | +use_repo(node, "nodejs_toolchains") |
| 25 | +use_repo(node, "nodejs_darwin_amd64") |
| 26 | +use_repo(node, "nodejs_darwin_arm64") |
| 27 | +use_repo(node, "nodejs_linux_amd64") |
| 28 | +use_repo(node, "nodejs_linux_arm64") |
| 29 | +use_repo(node, "nodejs_linux_ppc64le") |
| 30 | +use_repo(node, "nodejs_linux_s390x") |
| 31 | +use_repo(node, "nodejs_windows_amd64") |
| 32 | + |
| 33 | +# The default + public version of pnpm used by default. |
| 34 | +pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm") |
| 35 | +pnpm.pnpm(name = "pnpm") |
| 36 | +use_repo(pnpm, "pnpm", "pnpm__links") |
| 37 | + |
| 38 | +bazel_lib_toolchains = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "toolchains") |
| 39 | +bazel_lib_toolchains.tar() |
| 40 | +use_repo( |
| 41 | + bazel_lib_toolchains, |
| 42 | + "bsd_tar_darwin_amd64", |
| 43 | + "bsd_tar_darwin_arm64", |
| 44 | + "bsd_tar_linux_amd64", |
| 45 | + "bsd_tar_linux_arm64", |
| 46 | + "bsd_tar_toolchains", |
| 47 | + "bsd_tar_windows_amd64", |
| 48 | + "bsd_tar_windows_arm64", |
| 49 | + "coreutils_toolchains", |
| 50 | + "yq_darwin_amd64", |
| 51 | + "yq_darwin_arm64", |
| 52 | + "yq_linux_amd64", |
| 53 | + "yq_linux_arm64", |
| 54 | + "yq_linux_ppc64le", |
| 55 | + "yq_linux_s390x", |
| 56 | + "yq_windows_amd64", |
| 57 | +) |
| 58 | + |
| 59 | +####### Dev dependencies ######## |
| 60 | + |
| 61 | +# Dev-only pnpm used for local testing |
| 62 | +pnpm9 = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm", dev_dependency = True) |
| 63 | +pnpm9.pnpm( |
| 64 | + name = "pnpm9", |
| 65 | + pnpm_version = "9.15.9", |
| 66 | + pnpm_version_integrity = "sha512-aARhQYk8ZvrQHAeSMRKOmvuJ74fiaR1p5NQO7iKJiClf1GghgbrlW1hBjDolO95lpQXsfF+UA+zlzDzTfc8lMQ==", |
| 67 | +) |
| 68 | +use_repo(pnpm9, "pnpm9") |
| 69 | + |
| 70 | +bazel_dep(name = "bazelrc-preset.bzl", version = "1.3.0", dev_dependency = True) |
| 71 | +bazel_dep(name = "aspect_rules_lint", version = "1.1.0", dev_dependency = True) |
| 72 | +bazel_dep(name = "buildifier_prebuilt", version = "8.0.1", dev_dependency = True) |
| 73 | +bazel_dep(name = "rules_shell", version = "0.6.1", dev_dependency = True) |
| 74 | + |
| 75 | +# Overrides of non-dev deps for local testing using recent versions |
| 76 | +archive_override( |
| 77 | + module_name = "rules_nodejs", |
| 78 | + integrity = "sha256-OY23vNcf28WAxvjReCrpn1JQeRFypf/jHS+dgTjzOC4=", |
| 79 | + strip_prefix = "rules_nodejs-7cbb1fb5378fb4739e4d9698a14abd9eada900f0", |
| 80 | + urls = [ |
| 81 | + "https://github.com/bazel-contrib/rules_nodejs/archive/7cbb1fb5378fb4739e4d9698a14abd9eada900f0.tar.gz", |
| 82 | + ], |
| 83 | +) |
| 84 | + |
| 85 | +host = use_extension( |
| 86 | + "@aspect_bazel_lib//lib:extensions.bzl", |
| 87 | + "host", |
| 88 | + dev_dependency = True, |
| 89 | +) |
| 90 | +host.host() |
| 91 | +use_repo(host, "aspect_bazel_lib_host") |
| 92 | + |
| 93 | +node_dev = use_extension( |
| 94 | + "@rules_nodejs//nodejs:extensions.bzl", |
| 95 | + "node", |
| 96 | + dev_dependency = True, |
| 97 | +) |
| 98 | +use_repo(node_dev, "node16_linux_amd64") |
| 99 | +use_repo(node_dev, "node16_darwin_arm64") |
| 100 | +use_repo(node_dev, "node16_darwin_amd64") |
| 101 | +use_repo(node_dev, "node16_linux_arm64") |
| 102 | +use_repo(node_dev, "node16_linux_s390x") |
| 103 | +use_repo(node_dev, "node16_linux_ppc64le") |
| 104 | +use_repo(node_dev, "node16_windows_amd64") |
| 105 | +use_repo(node_dev, "node18_linux_amd64") |
| 106 | +use_repo(node_dev, "node18_darwin_arm64") |
| 107 | +use_repo(node_dev, "node18_darwin_amd64") |
| 108 | +use_repo(node_dev, "node18_linux_arm64") |
| 109 | +use_repo(node_dev, "node18_linux_s390x") |
| 110 | +use_repo(node_dev, "node18_linux_ppc64le") |
| 111 | +use_repo(node_dev, "node18_windows_amd64") |
| 112 | +use_repo(node_dev, "node20_linux_amd64") |
| 113 | +use_repo(node_dev, "node20_darwin_arm64") |
| 114 | +use_repo(node_dev, "node20_darwin_amd64") |
| 115 | +use_repo(node_dev, "node20_linux_arm64") |
| 116 | +use_repo(node_dev, "node20_linux_s390x") |
| 117 | +use_repo(node_dev, "node20_linux_ppc64le") |
| 118 | +use_repo(node_dev, "node20_windows_amd64") |
| 119 | +use_repo(node_dev, "node22_linux_amd64") |
| 120 | +use_repo(node_dev, "node22_darwin_arm64") |
| 121 | +use_repo(node_dev, "node22_darwin_amd64") |
| 122 | +use_repo(node_dev, "node22_linux_arm64") |
| 123 | +use_repo(node_dev, "node22_linux_s390x") |
| 124 | +use_repo(node_dev, "node22_linux_ppc64le") |
| 125 | +use_repo(node_dev, "node22_windows_amd64") |
| 126 | +use_repo(node_dev, "node24_linux_amd64") |
| 127 | +use_repo(node_dev, "node24_darwin_arm64") |
| 128 | +use_repo(node_dev, "node24_darwin_amd64") |
| 129 | +use_repo(node_dev, "node24_linux_arm64") |
| 130 | +use_repo(node_dev, "node24_linux_s390x") |
| 131 | +use_repo(node_dev, "node24_linux_ppc64le") |
| 132 | +use_repo(node_dev, "node24_windows_amd64") |
| 133 | +node_dev.toolchain(node_version = "18.20.4") |
| 134 | +node_dev.toolchain( |
| 135 | + name = "node16", |
| 136 | + node_version = "16.20.0", |
| 137 | +) |
| 138 | +node_dev.toolchain( |
| 139 | + name = "node18", |
| 140 | + node_version = "18.20.4", |
| 141 | +) |
| 142 | +node_dev.toolchain( |
| 143 | + name = "node20", |
| 144 | + node_version = "20.17.0", |
| 145 | +) |
| 146 | +node_dev.toolchain( |
| 147 | + name = "node22", |
| 148 | + node_version = "22.20.0", |
| 149 | +) |
| 150 | +node_dev.toolchain( |
| 151 | + name = "node24", |
| 152 | + node_version = "24.9.0", |
| 153 | +) |
| 154 | + |
| 155 | +############################################ |
| 156 | +# npm dependencies used by examples |
| 157 | + |
| 158 | +npm = use_extension( |
| 159 | + "@aspect_rules_js//npm:extensions.bzl", |
| 160 | + "npm", |
| 161 | + dev_dependency = True, |
| 162 | +) |
| 163 | +npm.npm_translate_lock( |
| 164 | + name = "npm", |
| 165 | + bins = { |
| 166 | + # derived from "bin" attribute in node_modules/typescript/package.json |
| 167 | + "typescript": [ |
| 168 | + "tsc=./bin/tsc", |
| 169 | + "tsserver=./bin/tsserver", |
| 170 | + ], |
| 171 | + }, |
| 172 | + custom_postinstalls = { |
| 173 | + "@aspect-test/c": "echo moo > cow.txt", |
| 174 | + "@aspect-test/[email protected]": "echo mooo >> cow.txt", |
| 175 | + "pngjs": "chmod -R a+X *", # fixes malformed tarball content file permissions in this package after extraction (see https://github.com/aspect-build/rules_js/issues/1637 for more details) |
| 176 | + }, |
| 177 | + data = [ |
| 178 | + "//:examples/npm_deps/patches/[email protected]", |
| 179 | + "//:package.json", |
| 180 | + "//:pnpm-workspace.yaml", |
| 181 | + "//examples/js_binary:package.json", |
| 182 | + "//examples/js_lib_pkg/a:package.json", |
| 183 | + "//examples/js_lib_pkg/b:package.json", |
| 184 | + "//examples/linked_consumer:package.json", |
| 185 | + "//examples/linked_empty_node_modules:package.json", |
| 186 | + "//examples/linked_lib:package.json", |
| 187 | + "//examples/linked_pkg:package.json", |
| 188 | + "//examples/macro:package.json", |
| 189 | + "//examples/nextjs:package.json", |
| 190 | + "//examples/npm_deps:package.json", |
| 191 | + "//examples/npm_package/libs/lib_a:package.json", |
| 192 | + "//examples/npm_package/packages/pkg_a:package.json", |
| 193 | + "//examples/npm_package/packages/pkg_b:package.json", |
| 194 | + "//examples/npm_package/packages/pkg_d:package.json", |
| 195 | + "//examples/npm_package/packages/pkg_e:package.json", |
| 196 | + "//examples/runfiles:package.json", |
| 197 | + "//examples/stack_traces:package.json", |
| 198 | + "//examples/webpack_cli:package.json", |
| 199 | + "//js/private/coverage/bundle:package.json", |
| 200 | + "//js/private/devserver/src:package.json", |
| 201 | + "//js/private/test/image:package.json", |
| 202 | + "//js/private/test/js_run_devserver:package.json", |
| 203 | + "//js/private/worker/src:package.json", |
| 204 | + "//npm/private/test:package.json", |
| 205 | + "//npm/private/test:vendored/lodash-4.17.21.tgz", |
| 206 | + "//npm/private/test/npm_package:package.json", |
| 207 | + "//npm/private/test/npm_package_publish:package.json", |
| 208 | + "//npm/private/test/vendored/is-odd:package.json", |
| 209 | + "//npm/private/test/vendored/semver-max:package.json", |
| 210 | + ], |
| 211 | + generate_bzl_library_targets = True, |
| 212 | + lifecycle_hooks = { |
| 213 | + # We fetch @kubernetes/client-node from source and it has a `prepare` lifecycle hook that needs to be run |
| 214 | + # which runs the `build` package.json script: https://github.com/kubernetes-client/javascript/blob/fc681991e61c6808dd26012a2331f83671a11218/package.json#L28. |
| 215 | + # Here we run run build so we just run `tsc` instead of `npm run build` which ends up just running `tsc`. |
| 216 | + "@kubernetes/client-node": ["build"], |
| 217 | + # 'install' hook fails as it assumes the following path to `node-pre-gyp`: ./node_modules/.bin/node-pre-gyp |
| 218 | + # https://github.com/stultuss/protoc-gen-grpc-ts/blob/53d52a9d0e1fe3cbe930dec5581eca89b3dde807/package.json#L28 |
| 219 | + |
| 220 | + }, |
| 221 | + lifecycle_hooks_execution_requirements = { |
| 222 | + "*": [ |
| 223 | + "no-sandbox", |
| 224 | + ], |
| 225 | + # If @kubernetes/client-node is not sandboxed, will fail with |
| 226 | + # ``` |
| 227 | + # src/azure_auth.ts(97,43): error TS2575: No overload expects 2 arguments, but overloads do exist that expect either 1 or 4 arguments. |
| 228 | + # src/azure_auth.ts(98,34): error TS2575: No overload expects 2 arguments, but overloads do exist that expect either 1 or 4 arguments. |
| 229 | + # src/gcp_auth.ts(93,43): error TS2575: No overload expects 2 arguments, but overloads do exist that expect either 1 or 4 arguments. |
| 230 | + # src/gcp_auth.ts(94,34): error TS2575: No overload expects 2 arguments, but overloads do exist that expect either 1 or 4 arguments. |
| 231 | + # ``` |
| 232 | + # since a `[email protected]` that is newer then the transitive dep `[email protected]` is found outside of the sandbox that |
| 233 | + # includes typings that don't match the 0.19.0 "any" usage. |
| 234 | + "@kubernetes/client-node": [], |
| 235 | + "@figma/nodegit": [ |
| 236 | + "no-sandbox", |
| 237 | + "requires-network", |
| 238 | + ], |
| 239 | + "esbuild": [ |
| 240 | + "no-sandbox", |
| 241 | + "requires-network", |
| 242 | + ], |
| 243 | + "segfault-handler": [ |
| 244 | + "no-sandbox", |
| 245 | + "requires-network", |
| 246 | + ], |
| 247 | + "puppeteer": [ |
| 248 | + "no-remote", |
| 249 | + "no-sandbox", |
| 250 | + "requires-network", |
| 251 | + ], |
| 252 | + }, |
| 253 | + npmrc = "//:.npmrc", |
| 254 | + package_visibility = { |
| 255 | + "unused": ["//npm/private/test:__subpackages__"], |
| 256 | + "@mycorp/pkg-a": [ |
| 257 | + "//examples:__subpackages__", |
| 258 | + "//js/private/test/image:__subpackages__", |
| 259 | + ], |
| 260 | + "@mycorp/pkg-d": [ |
| 261 | + "//examples:__subpackages__", |
| 262 | + "//js/private/test/image:__subpackages__", |
| 263 | + ], |
| 264 | + "@mycorp/pkg-e": ["//examples:__subpackages__"], |
| 265 | + }, |
| 266 | + pnpm_lock = "//:pnpm-lock.yaml", |
| 267 | + public_hoist_packages = { |
| 268 | + # Instructs the linker to hoist the [email protected] npm package to `node_modules/ms` in the `examples/npm_deps` package. |
| 269 | + # Similar to adding `public-hoist-pattern[]=ms` in .npmrc but with control over which version to hoist and where |
| 270 | + # to hoist it. This hoisted package can be referenced by the label `//examples/npm_deps:node_modules/ms` same as |
| 271 | + # other direct dependencies in the `examples/npm_deps/package.json`. |
| 272 | + "[email protected]": [ "examples/npm_deps"], |
| 273 | + }, |
| 274 | + update_pnpm_lock = True, |
| 275 | + use_pnpm = "@pnpm9//:package/bin/pnpm.cjs", |
| 276 | + verify_node_modules_ignored = "//:.bazelignore", |
| 277 | + verify_patches = "//examples/npm_deps/patches:patches", |
| 278 | +) |
| 279 | + |
| 280 | +# Configure package exclusions using tag class |
| 281 | +npm.npm_exclude_package_contents( |
| 282 | + package = "chalk", |
| 283 | + patterns = ["**/README*"], |
| 284 | +) |
| 285 | +use_repo( |
| 286 | + npm, |
| 287 | + "npm", |
| 288 | + "npm__fsevents__2.3.3__links", |
| 289 | + "npm__rollup__2.70.2", |
| 290 | + "npm__rollup__2.70.2__links", |
| 291 | + "npm__unused__0.2.2__links", |
| 292 | + "npm__webpack-bundle-analyzer__4.5.0_bufferutil_4.0.8", |
| 293 | +) |
| 294 | + |
| 295 | +# As an example, manually import a package using explicit coordinates. |
| 296 | +# Just a demonstration of the syntax de-sugaring. |
| 297 | +npm.npm_import( |
| 298 | + name = "acorn__8.4.0", |
| 299 | + bins = {"acorn": "./bin/acorn"}, |
| 300 | + integrity = "sha512-ULr0LDaEqQrMFGyQ3bhJkLsbtrQ8QibAseGZeaSUiT/6zb9IvIkomWHJIvgvwad+hinRAgsI51JcWk2yvwyL+w==", |
| 301 | + package = "acorn", |
| 302 | + # Root package where to link the package store |
| 303 | + root_package = "", |
| 304 | + version = "8.4.0", |
| 305 | +) |
| 306 | +use_repo( |
| 307 | + npm, |
| 308 | + "acorn__8.4.0", |
| 309 | + "acorn__8.4.0__links", |
| 310 | +) |
0 commit comments