|
| 1 | +"aspect-build/rules_js" |
| 2 | + |
| 3 | +module( |
| 4 | + name = "aspect_rules_js", |
| 5 | + version = "1.39.1", |
| 6 | + compatibility_level = 1, |
| 7 | +) |
| 8 | + |
| 9 | +# Lower-bounds for runtime dependencies. |
| 10 | +# Do not bump these unless rules_js requires a newer version to function. |
| 11 | +bazel_dep(name = "aspect_bazel_lib", version = "1.40.3") |
| 12 | +bazel_dep(name = "aspect_rules_lint", version = "0.12.0") |
| 13 | +bazel_dep(name = "bazel_features", version = "0.1.0") |
| 14 | +bazel_dep(name = "bazel_skylib", version = "1.5.0") |
| 15 | + |
| 16 | +# Keep v5 in to avoid breaking changes. |
| 17 | +# TODO(2.0): change minimum to v6 |
| 18 | +bazel_dep(name = "rules_nodejs", version = "5.8.2") |
| 19 | + |
| 20 | +# Override rules_nodejs to v6 to test the latest and recommended version internally. |
| 21 | +single_version_override( |
| 22 | + module_name = "rules_nodejs", |
| 23 | + version = "6.0.5", |
| 24 | +) |
| 25 | + |
| 26 | +bazel_dep(name = "platforms", version = "0.0.5") |
| 27 | + |
| 28 | +node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node") |
| 29 | +use_repo(node, "nodejs_darwin_amd64") |
| 30 | +use_repo(node, "nodejs_darwin_arm64") |
| 31 | +use_repo(node, "nodejs_linux_amd64") |
| 32 | +use_repo(node, "nodejs_linux_arm64") |
| 33 | +use_repo(node, "nodejs_linux_ppc64le") |
| 34 | +use_repo(node, "nodejs_linux_s390x") |
| 35 | +use_repo(node, "nodejs_windows_amd64") |
| 36 | + |
| 37 | +pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm") |
| 38 | +pnpm.pnpm( |
| 39 | + name = "pnpm", |
| 40 | + pnpm_version = "8.6.7", |
| 41 | + pnpm_version_integrity = "sha512-vRIWpD/L4phf9Bk2o/O2TDR8fFoJnpYrp2TKqTIZF/qZ2/rgL3qKXzHofHgbXsinwMoSEigz28sqk3pQ+yMEQQ==", |
| 42 | +) |
| 43 | +use_repo(pnpm, "pnpm", "pnpm__links") |
| 44 | + |
| 45 | +bazel_lib_toolchains = use_extension("@aspect_bazel_lib//lib:extensions.bzl", "toolchains") |
| 46 | +use_repo(bazel_lib_toolchains, "coreutils_toolchains") |
| 47 | +use_repo(bazel_lib_toolchains, "yq_darwin_amd64") |
| 48 | +use_repo(bazel_lib_toolchains, "yq_darwin_arm64") |
| 49 | +use_repo(bazel_lib_toolchains, "yq_linux_amd64") |
| 50 | +use_repo(bazel_lib_toolchains, "yq_linux_arm64") |
| 51 | +use_repo(bazel_lib_toolchains, "yq_linux_ppc64le") |
| 52 | +use_repo(bazel_lib_toolchains, "yq_linux_s390x") |
| 53 | +use_repo(bazel_lib_toolchains, "yq_windows_amd64") |
| 54 | + |
| 55 | +####### Dev dependencies ######## |
| 56 | + |
| 57 | +bazel_dep(name = "gazelle", version = "0.35.0", dev_dependency = True, repo_name = "bazel_gazelle") |
| 58 | +bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True) |
| 59 | +bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.5.0", dev_dependency = True) |
| 60 | +bazel_dep(name = "rules_go", version = "0.41.0", dev_dependency = True) |
| 61 | + |
| 62 | +host = use_extension( |
| 63 | + "@aspect_bazel_lib//lib:extensions.bzl", |
| 64 | + "host", |
| 65 | + dev_dependency = True, |
| 66 | +) |
| 67 | +host.host() |
| 68 | +use_repo(host, "aspect_bazel_lib_host") |
| 69 | + |
| 70 | +node_dev = use_extension( |
| 71 | + "@rules_nodejs//nodejs:extensions.bzl", |
| 72 | + "node", |
| 73 | + dev_dependency = True, |
| 74 | +) |
| 75 | +use_repo(node_dev, "nodejs_toolchains") |
| 76 | +use_repo(node_dev, "node20_linux_amd64") |
| 77 | +use_repo(node_dev, "node20_darwin_arm64") |
| 78 | +use_repo(node_dev, "node20_darwin_amd64") |
| 79 | +use_repo(node_dev, "node20_linux_arm64") |
| 80 | +use_repo(node_dev, "node20_linux_s390x") |
| 81 | +use_repo(node_dev, "node20_linux_ppc64le") |
| 82 | +use_repo(node_dev, "node20_windows_amd64") |
| 83 | +use_repo(node_dev, "node18_linux_amd64") |
| 84 | +use_repo(node_dev, "node18_darwin_arm64") |
| 85 | +use_repo(node_dev, "node18_darwin_amd64") |
| 86 | +use_repo(node_dev, "node18_linux_arm64") |
| 87 | +use_repo(node_dev, "node18_linux_s390x") |
| 88 | +use_repo(node_dev, "node18_linux_ppc64le") |
| 89 | +use_repo(node_dev, "node18_windows_amd64") |
| 90 | +use_repo(node_dev, "node16_linux_amd64") |
| 91 | +use_repo(node_dev, "node16_darwin_arm64") |
| 92 | +use_repo(node_dev, "node16_darwin_amd64") |
| 93 | +use_repo(node_dev, "node16_linux_arm64") |
| 94 | +use_repo(node_dev, "node16_linux_s390x") |
| 95 | +use_repo(node_dev, "node16_linux_ppc64le") |
| 96 | +use_repo(node_dev, "node16_windows_amd64") |
| 97 | +node_dev.toolchain(node_version = "16.14.2") |
| 98 | +node_dev.toolchain( |
| 99 | + name = "node16", |
| 100 | + node_version = "16.13.1", |
| 101 | +) |
| 102 | +node_dev.toolchain( |
| 103 | + name = "node18", |
| 104 | + node_version = "18.13.0", |
| 105 | +) |
| 106 | +node_dev.toolchain( |
| 107 | + name = "node20", |
| 108 | + node_version = "20.11.1", |
| 109 | +) |
| 110 | + |
| 111 | +############################################ |
| 112 | +# npm dependencies used by examples |
| 113 | + |
| 114 | +npm = use_extension( |
| 115 | + "@aspect_rules_js//npm:extensions.bzl", |
| 116 | + "npm", |
| 117 | + dev_dependency = True, |
| 118 | +) |
| 119 | +npm.npm_translate_lock( |
| 120 | + name = "npm", |
| 121 | + bins = { |
| 122 | + # derived from "bin" attribute in node_modules/typescript/package.json |
| 123 | + "typescript": [ |
| 124 | + "tsc=./bin/tsc", |
| 125 | + "tsserver=./bin/tsserver", |
| 126 | + ], |
| 127 | + }, |
| 128 | + custom_postinstalls = { |
| 129 | + "@aspect-test/c": "echo moo > cow.txt", |
| 130 | + "@aspect-test/[email protected]": "echo mooo >> cow.txt", |
| 131 | + }, |
| 132 | + data = [ |
| 133 | + "//:examples/npm_deps/patches/[email protected]", |
| 134 | + "//:package.json", |
| 135 | + "//:pnpm-workspace.yaml", |
| 136 | + "//examples/js_binary:package.json", |
| 137 | + "//examples/macro:package.json", |
| 138 | + "//examples/npm_deps:package.json", |
| 139 | + "//examples/npm_package/libs/lib_a:package.json", |
| 140 | + "//examples/npm_package/packages/pkg_a:package.json", |
| 141 | + "//examples/npm_package/packages/pkg_b:package.json", |
| 142 | + "//examples/webpack_cli:package.json", |
| 143 | + "//js/private/coverage/bundle:package.json", |
| 144 | + "//js/private/worker/src:package.json", |
| 145 | + "//npm/private/test:package.json", |
| 146 | + "//npm/private/test:vendored/lodash-4.17.21.tgz", |
| 147 | + "//npm/private/test/npm_package:package.json", |
| 148 | + "//npm/private/test/vendored/is-odd:package.json", |
| 149 | + "//npm/private/test/vendored/semver-max:package.json", |
| 150 | + ], |
| 151 | + generate_bzl_library_targets = True, |
| 152 | + lifecycle_hooks = { |
| 153 | + # We fetch @kubernetes/client-node from source and it has a `prepare` lifecycle hook that needs to be run |
| 154 | + # which runs the `build` package.json script: https://github.com/kubernetes-client/javascript/blob/fc681991e61c6808dd26012a2331f83671a11218/package.json#L28. |
| 155 | + # Here we run run build so we just run `tsc` instead of `npm run build` which ends up just running `tsc`. |
| 156 | + "@kubernetes/client-node": ["build"], |
| 157 | + # 'install' hook fails as it assumes the following path to `node-pre-gyp`: ./node_modules/.bin/node-pre-gyp |
| 158 | + # https://github.com/stultuss/protoc-gen-grpc-ts/blob/53d52a9d0e1fe3cbe930dec5581eca89b3dde807/package.json#L28 |
| 159 | + |
| 160 | + }, |
| 161 | + lifecycle_hooks_execution_requirements = { |
| 162 | + "*": [ |
| 163 | + "no-sandbox", |
| 164 | + ], |
| 165 | + # If @kubernetes/client-node is not sandboxed, will fail with |
| 166 | + # ``` |
| 167 | + # src/azure_auth.ts(97,43): error TS2575: No overload expects 2 arguments, but overloads do exist that expect either 1 or 4 arguments. |
| 168 | + # src/azure_auth.ts(98,34): error TS2575: No overload expects 2 arguments, but overloads do exist that expect either 1 or 4 arguments. |
| 169 | + # src/gcp_auth.ts(93,43): error TS2575: No overload expects 2 arguments, but overloads do exist that expect either 1 or 4 arguments. |
| 170 | + # src/gcp_auth.ts(94,34): error TS2575: No overload expects 2 arguments, but overloads do exist that expect either 1 or 4 arguments. |
| 171 | + # ``` |
| 172 | + # since a `[email protected]` that is newer then the transitive dep `[email protected]` is found outside of the sandbox that |
| 173 | + # includes typings that don't match the 0.19.0 "any" usage. |
| 174 | + "@kubernetes/client-node": [], |
| 175 | + "@figma/nodegit": [ |
| 176 | + "no-sandbox", |
| 177 | + "requires-network", |
| 178 | + ], |
| 179 | + "esbuild": [ |
| 180 | + "no-sandbox", |
| 181 | + "requires-network", |
| 182 | + ], |
| 183 | + "segfault-handler": [ |
| 184 | + "no-sandbox", |
| 185 | + "requires-network", |
| 186 | + ], |
| 187 | + "puppeteer": [ |
| 188 | + "no-sandbox", |
| 189 | + "requires-network", |
| 190 | + ], |
| 191 | + }, |
| 192 | + npmrc = "//:.npmrc", |
| 193 | + package_visibility = { |
| 194 | + "unused": ["//visibility:private"], |
| 195 | + "@mycorp/pkg-a": ["//examples:__subpackages__"], |
| 196 | + }, |
| 197 | + patch_args = { |
| 198 | + "*": ["-p1"], |
| 199 | + }, |
| 200 | + patches = { |
| 201 | + "[email protected]": [ "//examples/npm_deps:patches/[email protected]_pnpm.patch"], |
| 202 | + }, |
| 203 | + pnpm_lock = "//:pnpm-lock.yaml", |
| 204 | + public_hoist_packages = { |
| 205 | + # Instructs the linker to hoist the [email protected] npm package to `node_modules/ms` in the `examples/npm_deps` package. |
| 206 | + # Similar to adding `public-hoist-pattern[]=ms` in .npmrc but with control over which version to hoist and where |
| 207 | + # to hoist it. This hoisted package can be referenced by the label `//examples/npm_deps:node_modules/ms` same as |
| 208 | + # other direct dependencies in the `examples/npm_deps/package.json`. |
| 209 | + "[email protected]": [ "examples/npm_deps"], |
| 210 | + }, |
| 211 | + replace_packages = { |
| 212 | + "[email protected]": "@chalk_501//:pkg", |
| 213 | + }, |
| 214 | + update_pnpm_lock = True, |
| 215 | + verify_node_modules_ignored = "//:.bazelignore", |
| 216 | + verify_patches = "//examples/npm_deps/patches:patches", |
| 217 | +) |
| 218 | +use_repo(npm, "npm", "npm__rollup__2.70.2", "npm__webpack-bundle-analyzer__4.5.0__bufferutil_4.0.7") |
| 219 | + |
| 220 | +# As an example, manually import a package using explicit coordinates. |
| 221 | +# Just a demonstration of the syntax de-sugaring. |
| 222 | +npm.npm_import( |
| 223 | + name = "acorn__8.4.0", |
| 224 | + bins = {"acorn": "./bin/acorn"}, |
| 225 | + integrity = "sha512-ULr0LDaEqQrMFGyQ3bhJkLsbtrQ8QibAseGZeaSUiT/6zb9IvIkomWHJIvgvwad+hinRAgsI51JcWk2yvwyL+w==", |
| 226 | + package = "acorn", |
| 227 | + # Root package where to link the virtual store |
| 228 | + root_package = "", |
| 229 | + version = "8.4.0", |
| 230 | +) |
| 231 | +use_repo(npm, "acorn__8.4.0") |
| 232 | +use_repo(npm, "acorn__8.4.0__links") |
| 233 | + |
| 234 | +# Used by formatter |
| 235 | +go_sdk = use_extension( |
| 236 | + "@rules_go//go:extensions.bzl", |
| 237 | + "go_sdk", |
| 238 | + dev_dependency = True, |
| 239 | +) |
| 240 | +go_sdk.download( |
| 241 | + name = "go_sdk", |
| 242 | + version = "1.20.3", |
| 243 | +) |
| 244 | +use_repo(go_sdk, "go_sdk") |
0 commit comments