diff --git a/.bazelrc b/.bazelrc index ca2c522f0..966b96e0f 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,4 +1,5 @@ common --enable_bzlmod +common --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig build --test_output=errors --action_env="GTEST_COLOR=1" diff --git a/.gitignore b/.gitignore index ed680598e..b0e011f04 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,6 @@ bazel-* .vscode/ .history/ -bazel-* - **/.DS_Store **/*.orig @@ -18,6 +16,4 @@ go.sum secret.json bigquery.json -yarn-error.log - tmp/ diff --git a/BUILD b/BUILD index 3f9020806..98b8b277b 100644 --- a/BUILD +++ b/BUILD @@ -1,69 +1,63 @@ +load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin") +load("@bazel_gazelle//:def.bzl", "gazelle") +load("@npm//:defs.bzl", "npm_link_all_packages") +load("@npm//:eslint/package_json.bzl", eslint_bin = "bin") +load("@npm//:prettier/package_json.bzl", prettier_bin = "bin") + package(default_visibility = ["//visibility:public"]) -load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") +npm_link_all_packages(name = "node_modules") + +copy_to_bin( + name = "tsconfig", + srcs = ["tsconfig.json"], + visibility = ["//visibility:public"], +) + +copy_to_bin( + name = "tsconfig_esm", + srcs = ["tsconfig.esm.json"], + visibility = ["//visibility:public"], +) + +copy_to_bin( + name = "package_json", + srcs = ["package.json"], + visibility = ["//visibility:public"], +) exports_files([ "tsconfig.json", + "tsconfig.esm.json", "package.json", "readme.md", "version.bzl", ]) -PROTOBUF_DEPS = [ - "@npm//protobufjs", - "@npm//protobufjs-cli", - # these deps are needed even though they are not automatic transitive deps of - # protobufjs since if they are not in the runfiles then protobufjs attempts to - # run `npm install` at runtime to get thhem which fails as it tries to access - # the npm cache outside of the sandbox - "@npm//semver", - "@npm//chalk", - "@npm//glob", - "@npm//jsdoc", - "@npm//minimist", - "@npm//tmp", - "@npm//uglify-js", - "@npm//uglify-es", - "@npm//espree", - "@npm//escodegen", - "@npm//estraverse", -] - -nodejs_binary( - name = "pbjs", - data = PROTOBUF_DEPS, - entry_point = "@npm//:node_modules/protobufjs-cli/bin/pbjs", -) - -nodejs_binary( - name = "pbts", - data = PROTOBUF_DEPS, - entry_point = "@npm//:node_modules/protobufjs-cli/bin/pbts", -) - -nodejs_binary( +eslint_bin.eslint_binary( name = "eslint", data = [ "eslint.config.js", - "@npm//@typescript-eslint/parser", - "@npm//eslint", + "//testing:resolver-patch", + "//:node_modules/@typescript-eslint/parser", + "//:node_modules/eslint", ] + glob(["eslint-rules/**"]), - entry_point = "@npm//:node_modules/eslint/bin/eslint.js", + node_options = [ + "--require=./testing/resolver-patch.js", + ], + visibility = ["//visibility:public"], ) -load("@bazel_gazelle//:def.bzl", "gazelle") +prettier_bin.prettier_binary( + name = "prettier", + data = [ + ".prettierignore", + "//:node_modules/prettier", + ], + visibility = ["//visibility:public"], +) # gazelle:prefix github.com/dataform-co/dataform # gazelle:proto package # gazelle:proto_group go_package gazelle(name = "gazelle") - -load("//tools:ts_library.bzl", "ts_library") - -# TODO: This is only here in order to workaround a bug in the way bazel resolves -# workspace imports when in nested repositories, and can be removed once that is fixed. -ts_library( - name = "modules-fix", - srcs = [], - module_name = "df", -) diff --git a/MODULE.bazel b/MODULE.bazel index cc4c7af5b..1a8a09c07 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -3,17 +3,60 @@ module( version = "1.0.0", ) -# 1. bazel_skylib +# Core Aspect Build Rules +bazel_dep(name = "aspect_rules_js", version = "2.0.1") +bazel_dep(name = "aspect_rules_ts", version = "3.0.0") +bazel_dep(name = "aspect_rules_webpack", version = "0.16.0") +bazel_dep(name = "aspect_rules_rollup", version = "2.0.0") +bazel_dep(name = "aspect_bazel_lib", version = "2.7.7") + +# Node.js Toolchain Configuration +bazel_dep(name = "rules_nodejs", version = "6.2.0") +bazel_dep(name = "platforms", version = "0.0.10") + +node_ext = use_extension("//tools:node_extension.bzl", "node_ext") +use_repo( + node_ext, + "nodejs", + "nodejs_darwin_amd64", + "nodejs_darwin_arm64", + "nodejs_linux_amd64", + "nodejs_linux_arm64", + "nodejs_windows_amd64", + node_toolchains = "nodejs_toolchains", +) + +register_toolchains( + "@node_toolchains//:all", +) + +# NPM Lock File Translation to Bzlmod Package Trees +npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True) +npm.npm_translate_lock( + name = "npm", + pnpm_lock = "//:pnpm-lock.yaml", + use_home_npmrc = True, +) +use_repo(npm, "npm") + +pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm") +use_repo(pnpm, "pnpm") + +# TypeScript Compiler Repository Setup +rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext") +rules_ts_ext.deps() +use_repo(rules_ts_ext, "npm_typescript") + +# bazel_skylib bazel_dep(name = "bazel_skylib", version = "1.7.1") -# 2. com_google_protobuf +# com_google_protobuf bazel_dep(name = "protobuf", version = "27.3", repo_name = "com_google_protobuf") - -# 4. rules_go +# rules_go bazel_dep(name = "rules_go", version = "0.49.0", repo_name = "io_bazel_rules_go") -# 5. bazel_gazelle +# bazel_gazelle bazel_dep(name = "gazelle", version = "0.37.0", repo_name = "bazel_gazelle") # Go dependencies via Gazelle's go_deps extension @@ -40,6 +83,6 @@ use_repo( "org_golang_x_text", ) -# 6. Custom gcloud SDK extension +# Custom gcloud SDK extension gcloud_sdk_ext = use_extension("//tools/gcloud:extensions.bzl", "gcloud_sdk_extension") use_repo(gcloud_sdk_ext, "gcloud_sdk") diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index b14d15b88..7c0cd2216 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -9,11 +9,23 @@ "https://bcr.bazel.build/modules/abseil-cpp/20230802.0.bcr.1/source.json": "14892cc698e02ffedf4967546e6bedb7245015906888d3465fcf27c90a26da10", "https://bcr.bazel.build/modules/apple_support/1.5.0/MODULE.bazel": "50341a62efbc483e8a2a6aec30994a58749bd7b885e18dd96aa8c33031e558ef", "https://bcr.bazel.build/modules/apple_support/1.5.0/source.json": "eb98a7627c0bc486b57f598ad8da50f6625d974c8f723e9ea71bd39f709c9862", + "https://bcr.bazel.build/modules/aspect_bazel_lib/2.7.7/MODULE.bazel": "491f8681205e31bb57892d67442ce448cda4f472a8e6b3dc062865e29a64f89c", + "https://bcr.bazel.build/modules/aspect_bazel_lib/2.7.7/source.json": "87f12b449cd1d27d3e83840a59a6966d557e7c3c5f19e7b2e0361da5edc6b397", + "https://bcr.bazel.build/modules/aspect_rules_js/2.0.0/MODULE.bazel": "b45b507574aa60a92796e3e13c195cd5744b3b8aff516a9c0cb5ae6a048161c5", + "https://bcr.bazel.build/modules/aspect_rules_js/2.0.1/MODULE.bazel": "a09d32aa997ad899fcd88dc6e629188f03351994f0698bc32a9979c5bcfd5c31", + "https://bcr.bazel.build/modules/aspect_rules_js/2.0.1/source.json": "62bda0d34f3817af165d1903b890ecbf6e50d652492f8bb83682636e997b5619", + "https://bcr.bazel.build/modules/aspect_rules_rollup/2.0.0/MODULE.bazel": "314e883f0584036a97c6d55d9843e344c5cfdcac6477aac3e1e816b6337788b9", + "https://bcr.bazel.build/modules/aspect_rules_rollup/2.0.0/source.json": "ee54a32a7c4792581371f5cdcda74083be32dedecd90692d2f59691e2c454dac", + "https://bcr.bazel.build/modules/aspect_rules_ts/3.0.0/MODULE.bazel": "0e7ac8ff86454e4f7564242b66c27401b384798400170474bef5554087a256ec", + "https://bcr.bazel.build/modules/aspect_rules_ts/3.0.0/source.json": "077e4dd4b3e8cf2332bc4604a34a64442ab09c96373420f4eadb0fd56a8d4b0e", + "https://bcr.bazel.build/modules/aspect_rules_webpack/0.16.0/MODULE.bazel": "b6df9c0bc3d39e98e970751b9c8a5cfe12105a89d9a88160fc78a83cda6f7640", + "https://bcr.bazel.build/modules/aspect_rules_webpack/0.16.0/source.json": "e6010a0b6c2d41d1763026794d45d107e23bfc44ad2603343ef60bb6f96d96c4", "https://bcr.bazel.build/modules/bazel_features/1.1.0/MODULE.bazel": "cfd42ff3b815a5f39554d97182657f8c4b9719568eb7fded2b9135f084bf760b", "https://bcr.bazel.build/modules/bazel_features/1.1.1/MODULE.bazel": "27b8c79ef57efe08efccbd9dd6ef70d61b4798320b8d3c134fd571f78963dbcd", "https://bcr.bazel.build/modules/bazel_features/1.11.0/MODULE.bazel": "f9382337dd5a474c3b7d334c2f83e50b6eaedc284253334cf823044a26de03e8", "https://bcr.bazel.build/modules/bazel_features/1.11.0/source.json": "c9320aa53cd1c441d24bd6b716da087ad7e4ff0d9742a9884587596edfe53015", "https://bcr.bazel.build/modules/bazel_features/1.4.1/MODULE.bazel": "e45b6bb2350aff3e442ae1111c555e27eac1d915e77775f6fdc4b351b758b5d7", + "https://bcr.bazel.build/modules/bazel_features/1.9.0/MODULE.bazel": "885151d58d90d8d9c811eb75e3288c11f850e1d6b481a8c9f766adee4712358b", "https://bcr.bazel.build/modules/bazel_features/1.9.1/MODULE.bazel": "8f679097876a9b609ad1f60249c49d68bfab783dd9be012faf9d82547b14815a", "https://bcr.bazel.build/modules/bazel_skylib/1.0.3/MODULE.bazel": "bcb0fd896384802d1ad283b4e4eb4d718eebd8cb820b0a2c3a347fb971afd9d8", "https://bcr.bazel.build/modules/bazel_skylib/1.2.0/MODULE.bazel": "44fe84260e454ed94ad326352a698422dbe372b21a1ac9f3eab76eb531223686", @@ -72,6 +84,8 @@ "https://bcr.bazel.build/modules/rules_license/0.0.3/MODULE.bazel": "627e9ab0247f7d1e05736b59dbb1b6871373de5ad31c3011880b4133cafd4bd0", "https://bcr.bazel.build/modules/rules_license/0.0.7/MODULE.bazel": "088fbeb0b6a419005b89cf93fe62d9517c0a2b8bb56af3244af65ecfe37e7d5d", "https://bcr.bazel.build/modules/rules_license/0.0.7/source.json": "355cc5737a0f294e560d52b1b7a6492d4fff2caf0bef1a315df5a298fca2d34a", + "https://bcr.bazel.build/modules/rules_nodejs/6.2.0/MODULE.bazel": "ec27907f55eb34705adb4e8257952162a2d4c3ed0f0b3b4c3c1aad1fac7be35e", + "https://bcr.bazel.build/modules/rules_nodejs/6.2.0/source.json": "a77c307175a82982f0847fd6a8660db5b21440d8a9d073642cb4afa7a18612ff", "https://bcr.bazel.build/modules/rules_pkg/0.7.0/MODULE.bazel": "df99f03fc7934a4737122518bb87e667e62d780b610910f0447665a7e2be62dc", "https://bcr.bazel.build/modules/rules_pkg/0.7.0/source.json": "c2557066e0c0342223ba592510ad3d812d4963b9024831f7f66fd0584dd8c66c", "https://bcr.bazel.build/modules/rules_proto/4.0.0/MODULE.bazel": "a7a7b6ce9bee418c1a760b3d84f83a299ad6952f9903c67f19e4edd964894e06", @@ -84,7 +98,8 @@ "https://bcr.bazel.build/modules/rules_python/0.4.0/MODULE.bazel": "9208ee05fd48bf09ac60ed269791cf17fb343db56c8226a720fbb1cdf467166c", "https://bcr.bazel.build/modules/stardoc/0.5.1/MODULE.bazel": "1a05d92974d0c122f5ccf09291442580317cdd859f07a8655f1db9a60374f9f8", "https://bcr.bazel.build/modules/stardoc/0.5.3/MODULE.bazel": "c7f6948dae6999bf0db32c1858ae345f112cacf98f174c7a8bb707e41b974f1c", - "https://bcr.bazel.build/modules/stardoc/0.5.3/source.json": "cd53fe968dc8cd98197c052db3db6d82562960c87b61e7a90ee96f8e4e0dda97", + "https://bcr.bazel.build/modules/stardoc/0.5.4/MODULE.bazel": "6569966df04610b8520957cb8e97cf2e9faac2c0309657c537ab51c16c18a2a4", + "https://bcr.bazel.build/modules/stardoc/0.5.4/source.json": "a961f58a71e735aa9dcb2d79b288e06b0a2d860ba730302c8f11be411b76631e", "https://bcr.bazel.build/modules/upb/0.0.0-20220923-a547704/MODULE.bazel": "7298990c00040a0e2f121f6c32544bab27d4452f80d9ce51349b1a28f3005c43", "https://bcr.bazel.build/modules/zlib/1.2.11/MODULE.bazel": "07b389abc85fdbca459b69e2ec656ae5622873af3f845e1c9d80fe179f3effa0", "https://bcr.bazel.build/modules/zlib/1.2.12/MODULE.bazel": "3b1a8834ada2a883674be8cbd36ede1b6ec481477ada359cd2d3ddc562340b27", @@ -93,6 +108,325 @@ }, "selectedYankedVersions": {}, "moduleExtensions": { + "//tools:node_extension.bzl%node_ext": { + "general": { + "bzlTransitiveDigest": "E66sFxkXRi0qJK3tyjaIjetpGyka9woZZFUWjj8/hTw=", + "usagesDigest": "Av6UyMhJt65LNphW9Nh4x1pHtOXvxiDwKkUO2sGZbtU=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "nodejs_host": { + "bzlFile": "@@rules_nodejs~//nodejs/private:nodejs_repo_host_os_alias.bzl", + "ruleClassName": "nodejs_repo_host_os_alias", + "attributes": { + "user_node_repository_name": "nodejs" + } + }, + "nodejs_linux_s390x": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": { + "24.13.0-darwin_amd64": [ + "node-v24.13.0-darwin-x64.tar.xz", + "node-v24.13.0-darwin-x64", + "4ca0a48233f091a2a69ec28dd58e59f394a1b2d4f052b6c6b10f760377fe266f" + ], + "24.13.0-darwin_arm64": [ + "node-v24.13.0-darwin-arm64.tar.xz", + "node-v24.13.0-darwin-arm64", + "c59a517e9147f25c6167426875a571432f1478c1d7ee7ecc10baa46b0d0e8545" + ], + "24.13.0-linux_amd64": [ + "node-v24.13.0-linux-x64.tar.xz", + "node-v24.13.0-linux-x64", + "e798599612f4bb71333a3397ab0d095fd62214e115aea45aa858a145fc72d67e" + ], + "24.13.0-linux_arm64": [ + "node-v24.13.0-linux-arm64.tar.xz", + "node-v24.13.0-linux-arm64", + "e798599612f4bb71333a3397ab0d095fd62214e115aea45aa858a145fc72d67e" + ], + "24.13.0-windows_amd64": [ + "node-v24.13.0-win-x64.zip", + "node-v24.13.0-win-x64", + "ca2742695be8de44027d71b3f53a4bdb36009b95575fe1ae6f7f0b5ce091cb88" + ] + }, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "24.13.0", + "include_headers": false, + "platform": "linux_s390x" + } + }, + "nodejs_windows_amd64": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": { + "24.13.0-darwin_amd64": [ + "node-v24.13.0-darwin-x64.tar.xz", + "node-v24.13.0-darwin-x64", + "4ca0a48233f091a2a69ec28dd58e59f394a1b2d4f052b6c6b10f760377fe266f" + ], + "24.13.0-darwin_arm64": [ + "node-v24.13.0-darwin-arm64.tar.xz", + "node-v24.13.0-darwin-arm64", + "c59a517e9147f25c6167426875a571432f1478c1d7ee7ecc10baa46b0d0e8545" + ], + "24.13.0-linux_amd64": [ + "node-v24.13.0-linux-x64.tar.xz", + "node-v24.13.0-linux-x64", + "e798599612f4bb71333a3397ab0d095fd62214e115aea45aa858a145fc72d67e" + ], + "24.13.0-linux_arm64": [ + "node-v24.13.0-linux-arm64.tar.xz", + "node-v24.13.0-linux-arm64", + "e798599612f4bb71333a3397ab0d095fd62214e115aea45aa858a145fc72d67e" + ], + "24.13.0-windows_amd64": [ + "node-v24.13.0-win-x64.zip", + "node-v24.13.0-win-x64", + "ca2742695be8de44027d71b3f53a4bdb36009b95575fe1ae6f7f0b5ce091cb88" + ] + }, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "24.13.0", + "include_headers": false, + "platform": "windows_amd64" + } + }, + "nodejs_toolchains": { + "bzlFile": "@@rules_nodejs~//nodejs/private:nodejs_toolchains_repo.bzl", + "ruleClassName": "nodejs_toolchains_repo", + "attributes": { + "user_node_repository_name": "nodejs" + } + }, + "nodejs_linux_amd64": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": { + "24.13.0-darwin_amd64": [ + "node-v24.13.0-darwin-x64.tar.xz", + "node-v24.13.0-darwin-x64", + "4ca0a48233f091a2a69ec28dd58e59f394a1b2d4f052b6c6b10f760377fe266f" + ], + "24.13.0-darwin_arm64": [ + "node-v24.13.0-darwin-arm64.tar.xz", + "node-v24.13.0-darwin-arm64", + "c59a517e9147f25c6167426875a571432f1478c1d7ee7ecc10baa46b0d0e8545" + ], + "24.13.0-linux_amd64": [ + "node-v24.13.0-linux-x64.tar.xz", + "node-v24.13.0-linux-x64", + "e798599612f4bb71333a3397ab0d095fd62214e115aea45aa858a145fc72d67e" + ], + "24.13.0-linux_arm64": [ + "node-v24.13.0-linux-arm64.tar.xz", + "node-v24.13.0-linux-arm64", + "e798599612f4bb71333a3397ab0d095fd62214e115aea45aa858a145fc72d67e" + ], + "24.13.0-windows_amd64": [ + "node-v24.13.0-win-x64.zip", + "node-v24.13.0-win-x64", + "ca2742695be8de44027d71b3f53a4bdb36009b95575fe1ae6f7f0b5ce091cb88" + ] + }, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "24.13.0", + "include_headers": false, + "platform": "linux_amd64" + } + }, + "nodejs_linux_ppc64le": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": { + "24.13.0-darwin_amd64": [ + "node-v24.13.0-darwin-x64.tar.xz", + "node-v24.13.0-darwin-x64", + "4ca0a48233f091a2a69ec28dd58e59f394a1b2d4f052b6c6b10f760377fe266f" + ], + "24.13.0-darwin_arm64": [ + "node-v24.13.0-darwin-arm64.tar.xz", + "node-v24.13.0-darwin-arm64", + "c59a517e9147f25c6167426875a571432f1478c1d7ee7ecc10baa46b0d0e8545" + ], + "24.13.0-linux_amd64": [ + "node-v24.13.0-linux-x64.tar.xz", + "node-v24.13.0-linux-x64", + "e798599612f4bb71333a3397ab0d095fd62214e115aea45aa858a145fc72d67e" + ], + "24.13.0-linux_arm64": [ + "node-v24.13.0-linux-arm64.tar.xz", + "node-v24.13.0-linux-arm64", + "e798599612f4bb71333a3397ab0d095fd62214e115aea45aa858a145fc72d67e" + ], + "24.13.0-windows_amd64": [ + "node-v24.13.0-win-x64.zip", + "node-v24.13.0-win-x64", + "ca2742695be8de44027d71b3f53a4bdb36009b95575fe1ae6f7f0b5ce091cb88" + ] + }, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "24.13.0", + "include_headers": false, + "platform": "linux_ppc64le" + } + }, + "nodejs_darwin_amd64": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": { + "24.13.0-darwin_amd64": [ + "node-v24.13.0-darwin-x64.tar.xz", + "node-v24.13.0-darwin-x64", + "4ca0a48233f091a2a69ec28dd58e59f394a1b2d4f052b6c6b10f760377fe266f" + ], + "24.13.0-darwin_arm64": [ + "node-v24.13.0-darwin-arm64.tar.xz", + "node-v24.13.0-darwin-arm64", + "c59a517e9147f25c6167426875a571432f1478c1d7ee7ecc10baa46b0d0e8545" + ], + "24.13.0-linux_amd64": [ + "node-v24.13.0-linux-x64.tar.xz", + "node-v24.13.0-linux-x64", + "e798599612f4bb71333a3397ab0d095fd62214e115aea45aa858a145fc72d67e" + ], + "24.13.0-linux_arm64": [ + "node-v24.13.0-linux-arm64.tar.xz", + "node-v24.13.0-linux-arm64", + "e798599612f4bb71333a3397ab0d095fd62214e115aea45aa858a145fc72d67e" + ], + "24.13.0-windows_amd64": [ + "node-v24.13.0-win-x64.zip", + "node-v24.13.0-win-x64", + "ca2742695be8de44027d71b3f53a4bdb36009b95575fe1ae6f7f0b5ce091cb88" + ] + }, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "24.13.0", + "include_headers": false, + "platform": "darwin_amd64" + } + }, + "nodejs_linux_arm64": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": { + "24.13.0-darwin_amd64": [ + "node-v24.13.0-darwin-x64.tar.xz", + "node-v24.13.0-darwin-x64", + "4ca0a48233f091a2a69ec28dd58e59f394a1b2d4f052b6c6b10f760377fe266f" + ], + "24.13.0-darwin_arm64": [ + "node-v24.13.0-darwin-arm64.tar.xz", + "node-v24.13.0-darwin-arm64", + "c59a517e9147f25c6167426875a571432f1478c1d7ee7ecc10baa46b0d0e8545" + ], + "24.13.0-linux_amd64": [ + "node-v24.13.0-linux-x64.tar.xz", + "node-v24.13.0-linux-x64", + "e798599612f4bb71333a3397ab0d095fd62214e115aea45aa858a145fc72d67e" + ], + "24.13.0-linux_arm64": [ + "node-v24.13.0-linux-arm64.tar.xz", + "node-v24.13.0-linux-arm64", + "e798599612f4bb71333a3397ab0d095fd62214e115aea45aa858a145fc72d67e" + ], + "24.13.0-windows_amd64": [ + "node-v24.13.0-win-x64.zip", + "node-v24.13.0-win-x64", + "ca2742695be8de44027d71b3f53a4bdb36009b95575fe1ae6f7f0b5ce091cb88" + ] + }, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "24.13.0", + "include_headers": false, + "platform": "linux_arm64" + } + }, + "nodejs": { + "bzlFile": "@@rules_nodejs~//nodejs/private:nodejs_repo_host_os_alias.bzl", + "ruleClassName": "nodejs_repo_host_os_alias", + "attributes": { + "user_node_repository_name": "nodejs" + } + }, + "nodejs_darwin_arm64": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": { + "24.13.0-darwin_amd64": [ + "node-v24.13.0-darwin-x64.tar.xz", + "node-v24.13.0-darwin-x64", + "4ca0a48233f091a2a69ec28dd58e59f394a1b2d4f052b6c6b10f760377fe266f" + ], + "24.13.0-darwin_arm64": [ + "node-v24.13.0-darwin-arm64.tar.xz", + "node-v24.13.0-darwin-arm64", + "c59a517e9147f25c6167426875a571432f1478c1d7ee7ecc10baa46b0d0e8545" + ], + "24.13.0-linux_amd64": [ + "node-v24.13.0-linux-x64.tar.xz", + "node-v24.13.0-linux-x64", + "e798599612f4bb71333a3397ab0d095fd62214e115aea45aa858a145fc72d67e" + ], + "24.13.0-linux_arm64": [ + "node-v24.13.0-linux-arm64.tar.xz", + "node-v24.13.0-linux-arm64", + "e798599612f4bb71333a3397ab0d095fd62214e115aea45aa858a145fc72d67e" + ], + "24.13.0-windows_amd64": [ + "node-v24.13.0-win-x64.zip", + "node-v24.13.0-win-x64", + "ca2742695be8de44027d71b3f53a4bdb36009b95575fe1ae6f7f0b5ce091cb88" + ] + }, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "24.13.0", + "include_headers": false, + "platform": "darwin_arm64" + } + } + }, + "recordedRepoMappingEntries": [ + [ + "", + "rules_nodejs", + "rules_nodejs~" + ] + ] + } + }, "//tools/gcloud:extensions.bzl%gcloud_sdk_extension": { "general": { "bzlTransitiveDigest": "kvgSakWSAojqjpVE9x4s5Cr2/DcTP4DJDorH/EkVOnU=", @@ -138,6 +472,613 @@ ] } }, + "@@aspect_bazel_lib~//lib:extensions.bzl%toolchains": { + "general": { + "bzlTransitiveDigest": "3KydN9M+cGcn8Huu/umxX7Vk08sXz5lJeUxg/b0Gxjc=", + "usagesDigest": "Cfe43UxnexwXh6eindVSVzskoYyQKVcN0d7Q5GURnP8=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "expand_template_windows_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", + "attributes": { + "platform": "windows_amd64" + } + }, + "copy_to_directory_windows_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", + "attributes": { + "platform": "windows_amd64" + } + }, + "jq_darwin_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_platform_repo", + "attributes": { + "platform": "darwin_amd64", + "version": "1.7" + } + }, + "copy_to_directory_freebsd_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", + "attributes": { + "platform": "freebsd_amd64" + } + }, + "expand_template_linux_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", + "attributes": { + "platform": "linux_amd64" + } + }, + "jq_linux_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_platform_repo", + "attributes": { + "platform": "linux_arm64", + "version": "1.7" + } + }, + "coreutils_darwin_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_platform_repo", + "attributes": { + "platform": "darwin_arm64", + "version": "0.0.26" + } + }, + "copy_to_directory_linux_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", + "attributes": { + "platform": "linux_arm64" + } + }, + "bsd_tar_linux_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:tar_toolchain.bzl", + "ruleClassName": "bsdtar_binary_repo", + "attributes": { + "platform": "linux_arm64" + } + }, + "copy_directory_darwin_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", + "attributes": { + "platform": "darwin_amd64" + } + }, + "coreutils_darwin_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_platform_repo", + "attributes": { + "platform": "darwin_amd64", + "version": "0.0.26" + } + }, + "coreutils_linux_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_platform_repo", + "attributes": { + "platform": "linux_arm64", + "version": "0.0.26" + } + }, + "zstd_linux_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:zstd_toolchain.bzl", + "ruleClassName": "zstd_binary_repo", + "attributes": { + "platform": "linux_arm64" + } + }, + "yq_linux_s390x": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", + "attributes": { + "platform": "linux_s390x", + "version": "4.25.2" + } + }, + "yq": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_host_alias_repo", + "attributes": {} + }, + "expand_template_darwin_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", + "attributes": { + "platform": "darwin_amd64" + } + }, + "copy_directory_linux_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", + "attributes": { + "platform": "linux_amd64" + } + }, + "jq_darwin_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_platform_repo", + "attributes": { + "platform": "darwin_arm64", + "version": "1.7" + } + }, + "yq_darwin_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", + "attributes": { + "platform": "darwin_amd64", + "version": "4.25.2" + } + }, + "copy_directory_linux_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", + "attributes": { + "platform": "linux_arm64" + } + }, + "expand_template_toolchains": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_toolchains_repo", + "attributes": { + "user_repository_name": "expand_template" + } + }, + "bats_assert": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "98ca3b685f8b8993e48ec057565e6e2abcc541034ed5b0e81f191505682037fd", + "urls": [ + "https://github.com/bats-core/bats-assert/archive/v2.1.0.tar.gz" + ], + "strip_prefix": "bats-assert-2.1.0", + "build_file_content": "load(\"@aspect_bazel_lib//lib:copy_to_directory.bzl\", \"copy_to_directory\")\n\ncopy_to_directory(\n name = \"assert\",\n hardlink = \"on\",\n srcs = glob([\n \"src/**\",\n \"load.bash\",\n ]),\n out = \"bats-assert\",\n visibility = [\"//visibility:public\"]\n)\n" + } + }, + "copy_to_directory_darwin_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", + "attributes": { + "platform": "darwin_amd64" + } + }, + "zstd_darwin_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:zstd_toolchain.bzl", + "ruleClassName": "zstd_binary_repo", + "attributes": { + "platform": "darwin_arm64" + } + }, + "bsd_tar_linux_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:tar_toolchain.bzl", + "ruleClassName": "bsdtar_binary_repo", + "attributes": { + "platform": "linux_amd64" + } + }, + "yq_toolchains": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_toolchains_repo", + "attributes": { + "user_repository_name": "yq" + } + }, + "zstd_linux_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:zstd_toolchain.bzl", + "ruleClassName": "zstd_binary_repo", + "attributes": { + "platform": "linux_amd64" + } + }, + "bats_support": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "7815237aafeb42ddcc1b8c698fc5808026d33317d8701d5ec2396e9634e2918f", + "urls": [ + "https://github.com/bats-core/bats-support/archive/v0.3.0.tar.gz" + ], + "strip_prefix": "bats-support-0.3.0", + "build_file_content": "load(\"@aspect_bazel_lib//lib:copy_to_directory.bzl\", \"copy_to_directory\")\n\ncopy_to_directory(\n name = \"support\",\n hardlink = \"on\",\n srcs = glob([\n \"src/**\",\n \"load.bash\",\n ]),\n out = \"bats-support\",\n visibility = [\"//visibility:public\"]\n)\n" + } + }, + "bsd_tar_windows_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:tar_toolchain.bzl", + "ruleClassName": "bsdtar_binary_repo", + "attributes": { + "platform": "windows_amd64" + } + }, + "jq": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_host_alias_repo", + "attributes": {} + }, + "expand_template_darwin_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", + "attributes": { + "platform": "darwin_arm64" + } + }, + "bsd_tar_darwin_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:tar_toolchain.bzl", + "ruleClassName": "bsdtar_binary_repo", + "attributes": { + "platform": "darwin_arm64" + } + }, + "copy_to_directory_linux_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", + "attributes": { + "platform": "linux_amd64" + } + }, + "coreutils_linux_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_platform_repo", + "attributes": { + "platform": "linux_amd64", + "version": "0.0.26" + } + }, + "copy_directory_toolchains": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_toolchains_repo", + "attributes": { + "user_repository_name": "copy_directory" + } + }, + "yq_linux_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", + "attributes": { + "platform": "linux_amd64", + "version": "4.25.2" + } + }, + "copy_to_directory_darwin_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_platform_repo", + "attributes": { + "platform": "darwin_arm64" + } + }, + "coreutils_toolchains": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_toolchains_repo", + "attributes": { + "user_repository_name": "coreutils" + } + }, + "copy_directory_freebsd_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", + "attributes": { + "platform": "freebsd_amd64" + } + }, + "zstd_darwin_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:zstd_toolchain.bzl", + "ruleClassName": "zstd_binary_repo", + "attributes": { + "platform": "darwin_amd64" + } + }, + "zstd_toolchains": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:zstd_toolchain.bzl", + "ruleClassName": "zstd_toolchains_repo", + "attributes": { + "user_repository_name": "zstd" + } + }, + "bats_file": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "9b69043241f3af1c2d251f89b4fcafa5df3f05e97b89db18d7c9bdf5731bb27a", + "urls": [ + "https://github.com/bats-core/bats-file/archive/v0.4.0.tar.gz" + ], + "strip_prefix": "bats-file-0.4.0", + "build_file_content": "load(\"@aspect_bazel_lib//lib:copy_to_directory.bzl\", \"copy_to_directory\")\n\ncopy_to_directory(\n name = \"file\",\n hardlink = \"on\",\n srcs = glob([\n \"src/**\",\n \"load.bash\",\n ]),\n out = \"bats-file\",\n visibility = [\"//visibility:public\"]\n)\n" + } + }, + "expand_template_linux_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", + "attributes": { + "platform": "linux_arm64" + } + }, + "jq_linux_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_platform_repo", + "attributes": { + "platform": "linux_amd64", + "version": "1.7" + } + }, + "bsd_tar_darwin_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:tar_toolchain.bzl", + "ruleClassName": "bsdtar_binary_repo", + "attributes": { + "platform": "darwin_amd64" + } + }, + "bsd_tar_toolchains": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:tar_toolchain.bzl", + "ruleClassName": "tar_toolchains_repo", + "attributes": { + "user_repository_name": "bsd_tar" + } + }, + "bats_toolchains": { + "bzlFile": "@@bazel_tools//tools/build_defs/repo:http.bzl", + "ruleClassName": "http_archive", + "attributes": { + "sha256": "a1a9f7875aa4b6a9480ca384d5865f1ccf1b0b1faead6b47aa47d79709a5c5fd", + "urls": [ + "https://github.com/bats-core/bats-core/archive/v1.10.0.tar.gz" + ], + "strip_prefix": "bats-core-1.10.0", + "build_file_content": "load(\"@local_config_platform//:constraints.bzl\", \"HOST_CONSTRAINTS\")\nload(\"@aspect_bazel_lib//lib/private:bats_toolchain.bzl\", \"bats_toolchain\")\nload(\"@aspect_bazel_lib//lib:copy_to_directory.bzl\", \"copy_to_directory\")\n\ncopy_to_directory(\n name = \"core\",\n hardlink = \"on\",\n srcs = glob([\n \"lib/**\",\n \"libexec/**\"\n ]) + [\"bin/bats\"],\n out = \"bats-core\",\n)\n\nbats_toolchain(\n name = \"toolchain\",\n core = \":core\",\n libraries = [\"@bats_support//:support\", \"@bats_assert//:assert\", \"@bats_file//:file\"]\n)\n\ntoolchain(\n name = \"bats_toolchain\",\n exec_compatible_with = HOST_CONSTRAINTS,\n toolchain = \":toolchain\",\n toolchain_type = \"@aspect_bazel_lib//lib:bats_toolchain_type\",\n)\n" + } + }, + "yq_windows_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", + "attributes": { + "platform": "windows_amd64", + "version": "4.25.2" + } + }, + "jq_windows_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_platform_repo", + "attributes": { + "platform": "windows_amd64", + "version": "1.7" + } + }, + "expand_template_freebsd_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:expand_template_toolchain.bzl", + "ruleClassName": "expand_template_platform_repo", + "attributes": { + "platform": "freebsd_amd64" + } + }, + "yq_linux_ppc64le": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", + "attributes": { + "platform": "linux_ppc64le", + "version": "4.25.2" + } + }, + "copy_to_directory_toolchains": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_to_directory_toolchain.bzl", + "ruleClassName": "copy_to_directory_toolchains_repo", + "attributes": { + "user_repository_name": "copy_to_directory" + } + }, + "jq_toolchains": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:jq_toolchain.bzl", + "ruleClassName": "jq_toolchains_repo", + "attributes": { + "user_repository_name": "jq" + } + }, + "copy_directory_darwin_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", + "attributes": { + "platform": "darwin_arm64" + } + }, + "copy_directory_windows_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:copy_directory_toolchain.bzl", + "ruleClassName": "copy_directory_platform_repo", + "attributes": { + "platform": "windows_amd64" + } + }, + "yq_darwin_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", + "attributes": { + "platform": "darwin_arm64", + "version": "4.25.2" + } + }, + "coreutils_windows_amd64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:coreutils_toolchain.bzl", + "ruleClassName": "coreutils_platform_repo", + "attributes": { + "platform": "windows_amd64", + "version": "0.0.26" + } + }, + "yq_linux_arm64": { + "bzlFile": "@@aspect_bazel_lib~//lib/private:yq_toolchain.bzl", + "ruleClassName": "yq_platform_repo", + "attributes": { + "platform": "linux_arm64", + "version": "4.25.2" + } + } + }, + "recordedRepoMappingEntries": [ + [ + "aspect_bazel_lib~", + "aspect_bazel_lib", + "aspect_bazel_lib~" + ], + [ + "aspect_bazel_lib~", + "bazel_skylib", + "bazel_skylib~" + ], + [ + "aspect_bazel_lib~", + "bazel_tools", + "bazel_tools" + ] + ] + } + }, + "@@aspect_rules_js~//npm:extensions.bzl%pnpm": { + "general": { + "bzlTransitiveDigest": "D9YvWgCfxTlqvth1hogfpMLViNtyt8yQH4MEopFUwck=", + "usagesDigest": "nndrTQgfxu/STubDVVE+EMy+xEEkxEq77unJel7Opw8=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "pnpm__links": { + "bzlFile": "@@aspect_rules_js~//npm/private:npm_import.bzl", + "ruleClassName": "npm_import_links", + "attributes": { + "package": "pnpm", + "version": "8.6.7", + "dev": false, + "root_package": "", + "link_packages": {}, + "deps": {}, + "transitive_closure": {}, + "lifecycle_build_target": false, + "lifecycle_hooks_env": [], + "lifecycle_hooks_execution_requirements": [ + "no-sandbox" + ], + "lifecycle_hooks_use_default_shell_env": false, + "bins": {}, + "package_visibility": [ + "//visibility:public" + ], + "replace_package": "" + } + }, + "pnpm": { + "bzlFile": "@@aspect_rules_js~//npm/private:npm_import.bzl", + "ruleClassName": "npm_import_rule", + "attributes": { + "package": "pnpm", + "version": "8.6.7", + "root_package": "", + "link_workspace": "", + "link_packages": {}, + "integrity": "sha512-vRIWpD/L4phf9Bk2o/O2TDR8fFoJnpYrp2TKqTIZF/qZ2/rgL3qKXzHofHgbXsinwMoSEigz28sqk3pQ+yMEQQ==", + "url": "", + "commit": "", + "patch_args": [ + "-p0" + ], + "patches": [], + "custom_postinstall": "", + "npm_auth": "", + "npm_auth_basic": "", + "npm_auth_username": "", + "npm_auth_password": "", + "lifecycle_hooks": [], + "extra_build_content": "load(\"@aspect_rules_js//js:defs.bzl\", \"js_binary\")\njs_binary(name = \"pnpm\", data = glob([\"package/**\"]), entry_point = \"package/dist/pnpm.cjs\", visibility = [\"//visibility:public\"])", + "generate_bzl_library_targets": false, + "extract_full_archive": true, + "system_tar": "auto" + } + } + }, + "recordedRepoMappingEntries": [ + [ + "aspect_bazel_lib~", + "bazel_skylib", + "bazel_skylib~" + ], + [ + "aspect_bazel_lib~", + "bazel_tools", + "bazel_tools" + ], + [ + "aspect_rules_js~", + "aspect_bazel_lib", + "aspect_bazel_lib~" + ], + [ + "aspect_rules_js~", + "bazel_features", + "bazel_features~" + ], + [ + "aspect_rules_js~", + "bazel_skylib", + "bazel_skylib~" + ], + [ + "aspect_rules_js~", + "bazel_tools", + "bazel_tools" + ], + [ + "bazel_features~", + "bazel_features_globals", + "bazel_features~~version_extension~bazel_features_globals" + ], + [ + "bazel_features~", + "bazel_features_version", + "bazel_features~~version_extension~bazel_features_version" + ] + ] + } + }, + "@@aspect_rules_ts~//ts:extensions.bzl%ext": { + "general": { + "bzlTransitiveDigest": "oKcu5tBbtSfUDhUlzslFb7VqeJo83CbHK95dXgz/1F0=", + "usagesDigest": "bQ2AG52UzRTes7shKeT7lTaTejQW3CTyJX6BcKYl+mw=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "npm_typescript": { + "bzlFile": "@@aspect_rules_ts~//ts/private:npm_repositories.bzl", + "ruleClassName": "http_archive_version", + "attributes": { + "bzlmod": true, + "version": "5.5.4", + "integrity": "", + "build_file": "@@aspect_rules_ts~//ts:BUILD.typescript", + "build_file_substitutions": { + "bazel_worker_version": "5.4.2", + "google_protobuf_version": "3.20.1" + }, + "urls": [ + "https://registry.npmjs.org/typescript/-/typescript-{}.tgz" + ] + } + } + }, + "recordedRepoMappingEntries": [ + [ + "aspect_rules_ts~", + "bazel_tools", + "bazel_tools" + ] + ] + } + }, "@@platforms//host:extension.bzl%host_platform": { "general": { "bzlTransitiveDigest": "xelQcPZH8+tmuOHVjL9vDxMnnQNMlwj0SlvgoqBkm4U=", @@ -154,6 +1095,137 @@ }, "recordedRepoMappingEntries": [] } + }, + "@@rules_nodejs~//nodejs:extensions.bzl%node": { + "general": { + "bzlTransitiveDigest": "0IJr1Jg3Dns9QKY65MtauFLtHjjP3n1DgN0+ZAjFYXo=", + "usagesDigest": "QaaCjO0WbxbalX+3ei3mvAH3DxI2biGkZ5h5rxhaOwk=", + "recordedFileInputs": {}, + "recordedDirentsInputs": {}, + "envVariables": {}, + "generatedRepoSpecs": { + "nodejs_host": { + "bzlFile": "@@rules_nodejs~//nodejs/private:nodejs_repo_host_os_alias.bzl", + "ruleClassName": "nodejs_repo_host_os_alias", + "attributes": { + "user_node_repository_name": "nodejs" + } + }, + "nodejs_linux_s390x": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "18.20.3", + "include_headers": false, + "platform": "linux_s390x" + } + }, + "nodejs_windows_amd64": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "18.20.3", + "include_headers": false, + "platform": "windows_amd64" + } + }, + "nodejs_toolchains": { + "bzlFile": "@@rules_nodejs~//nodejs/private:nodejs_toolchains_repo.bzl", + "ruleClassName": "nodejs_toolchains_repo", + "attributes": { + "user_node_repository_name": "nodejs" + } + }, + "nodejs_linux_amd64": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "18.20.3", + "include_headers": false, + "platform": "linux_amd64" + } + }, + "nodejs_linux_ppc64le": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "18.20.3", + "include_headers": false, + "platform": "linux_ppc64le" + } + }, + "nodejs_darwin_amd64": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "18.20.3", + "include_headers": false, + "platform": "darwin_amd64" + } + }, + "nodejs_linux_arm64": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "18.20.3", + "include_headers": false, + "platform": "linux_arm64" + } + }, + "nodejs": { + "bzlFile": "@@rules_nodejs~//nodejs/private:nodejs_repo_host_os_alias.bzl", + "ruleClassName": "nodejs_repo_host_os_alias", + "attributes": { + "user_node_repository_name": "nodejs" + } + }, + "nodejs_darwin_arm64": { + "bzlFile": "@@rules_nodejs~//nodejs:repositories.bzl", + "ruleClassName": "_nodejs_repositories", + "attributes": { + "node_download_auth": {}, + "node_repositories": {}, + "node_urls": [ + "https://nodejs.org/dist/v{version}/{filename}" + ], + "node_version": "18.20.3", + "include_headers": false, + "platform": "darwin_arm64" + } + } + }, + "recordedRepoMappingEntries": [] + } } } } diff --git a/WORKSPACE b/WORKSPACE deleted file mode 100644 index 9562aef48..000000000 --- a/WORKSPACE +++ /dev/null @@ -1,29 +0,0 @@ -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "build_bazel_rules_nodejs", - sha256 = "e79c08a488cc5ac40981987d862c7320cee8741122a2649e9b08e850b6f20442", - urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/3.8.0/rules_nodejs-3.8.0.tar.gz"], -) - -load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install") - -node_repositories( - node_repositories = { - "24.13.0-darwin_amd64": ("node-v24.13.0-darwin-x64.tar.xz", "node-v24.13.0-darwin-x64", "4ca0a48233f091a2a69ec28dd58e59f394a1b2d4f052b6c6b10f760377fe266f"), - "24.13.0-darwin_arm64": ("node-v24.13.0-darwin-arm64.tar.xz", "node-v24.13.0-darwin-arm64", "c59a517e9147f25c6167426875a571432f1478c1d7ee7ecc10baa46b0d0e8545"), - "24.13.0-linux_amd64": ("node-v24.13.0-linux-x64.tar.xz", "node-v24.13.0-linux-x64", "e798599612f4bb71333a3397ab0d095fd62214e115aea45aa858a145fc72d67e"), - "24.13.0-linux_arm64": ("node-v24.13.0-linux-arm64.tar.xz", "node-v24.13.0-linux-arm64", "e798599612f4bb71333a3397ab0d095fd62214e115aea45aa858a145fc72d67e"), - "24.13.0-windows_amd64": ("node-v24.13.0-win-x64.zip", "node-v24.13.0-win-x64", "ca2742695be8de44027d71b3f53a4bdb36009b95575fe1ae6f7f0b5ce091cb88"), - }, - node_version = "24.13.0", - package_json = ["//:package.json"], - yarn_version = "1.13.0", -) - -yarn_install( - name = "npm", - package_json = "//:package.json", - symlink_node_modules = False, - yarn_lock = "//:yarn.lock", -) diff --git a/cli/BUILD b/cli/BUILD index aa20288d4..82b50a913 100644 --- a/cli/BUILD +++ b/cli/BUILD @@ -1,8 +1,6 @@ load("//tools:ts_library.bzl", "ts_library") load("//tools/common:copy.bzl", "copy_file") -load("//:version.bzl", "DF_VERSION") load("//testing:index.bzl", "ts_test_suite") -load("//tools:node_modules.bzl", "node_modules") package(default_visibility = ["//visibility:public"]) @@ -34,26 +32,20 @@ ts_library( "//core", "//protos:ts", "//sqlx:format", - "@npm//@types/glob", - "@npm//@types/long", - "@npm//@types/node", - "@npm//@types/readline-sync", - "@npm//@types/yargs", - "@npm//chokidar", - "@npm//glob", - "@npm//parse-duration", - "@npm//readline-sync", - "@npm//untildify", - "@npm//yargs", + "//:node_modules/@types/glob", + "//:node_modules/@types/long", + "//:node_modules/@types/node", + "//:node_modules/@types/readline-sync", + "//:node_modules/@types/yargs", + "//:node_modules/chokidar", + "//:node_modules/glob", + "//:node_modules/parse-duration", + "//:node_modules/readline-sync", + "//:node_modules/untildify", + "//:node_modules/yargs", ], ) -node_modules( - name = "node_modules", - deps = [ - "//packages/@dataform/cli:package_tar", - ], -) ts_library( name = "index_test_base", @@ -63,11 +55,11 @@ ts_library( "//core", "//protos:ts", "//testing", - "@npm//@types/fs-extra", - "@npm//@types/js-yaml", - "@npm//@types/node", - "@npm//fs-extra", - "@npm//js-yaml", + "//:node_modules/@types/fs-extra", + "//:node_modules/@types/js-yaml", + "//:node_modules/@types/node", + "//:node_modules/fs-extra", + "//:node_modules/js-yaml", ], ) @@ -83,10 +75,20 @@ ts_test_suite( "tests/jit/jit_run_test.ts", ], data = [ - ":node_modules", + "//packages/@dataform/cli:bundle", + "//packages/@dataform/cli:json", + "//packages/@dataform/cli:worker_bundle", "//packages/@dataform/core:package_tar", "@nodejs//:node", "@nodejs//:npm", + "@nodejs//:node_files", + "@nodejs//:npm_files", + ], + no_copy_to_bin = [ + "@nodejs//:node", + "@nodejs//:npm", + "@nodejs//:node_files", + "@nodejs//:npm_files", ], deps = [ ":index_test_base", @@ -95,15 +97,15 @@ ts_test_suite( "//core", "//protos:ts", "//testing", - "@npm//@types/chai", - "@npm//@types/fs-extra", - "@npm//@types/js-yaml", - "@npm//@types/long", - "@npm//@types/node", - "@npm//chai", - "@npm//fs-extra", - "@npm//js-yaml", - "@npm//ts-mockito", + "//:node_modules/@types/chai", + "//:node_modules/@types/fs-extra", + "//:node_modules/@types/js-yaml", + "//:node_modules/@types/long", + "//:node_modules/@types/node", + "//:node_modules/chai", + "//:node_modules/fs-extra", + "//:node_modules/js-yaml", + "//:node_modules/ts-mockito", ], ) @@ -117,11 +119,21 @@ ts_test_suite( "tests/jit/index_jit_runtime_test.ts" ], data = [ - ":node_modules", + "//packages/@dataform/cli:bundle", + "//packages/@dataform/cli:json", + "//packages/@dataform/cli:worker_bundle", "//packages/@dataform/core:package_tar", - "//test_credentials:bigquery.json", + "//test_credentials:bigquery_credentials", + "@nodejs//:node", + "@nodejs//:npm", + "@nodejs//:node_files", + "@nodejs//:npm_files", + ], + no_copy_to_bin = [ "@nodejs//:node", "@nodejs//:npm", + "@nodejs//:node_files", + "@nodejs//:npm_files", ], tags = ["integration"], deps = [ @@ -131,15 +143,15 @@ ts_test_suite( "//core", "//protos:ts", "//testing", - "@npm//@types/chai", - "@npm//@types/fs-extra", - "@npm//@types/js-yaml", - "@npm//@types/long", - "@npm//@types/node", - "@npm//chai", - "@npm//fs-extra", - "@npm//js-yaml", - "@npm//ts-mockito", + "//:node_modules/@types/chai", + "//:node_modules/@types/fs-extra", + "//:node_modules/@types/js-yaml", + "//:node_modules/@types/long", + "//:node_modules/@types/node", + "//:node_modules/chai", + "//:node_modules/fs-extra", + "//:node_modules/js-yaml", + "//:node_modules/ts-mockito", ], ) diff --git a/cli/api/BUILD b/cli/api/BUILD index 9b817c962..7111f1769 100644 --- a/cli/api/BUILD +++ b/cli/api/BUILD @@ -1,5 +1,4 @@ load("//testing:index.bzl", "ts_test_suite") -load("//tools:node_modules.bzl", "node_modules") load("//tools:ts_library.bzl", "ts_library") package(default_visibility = ["//visibility:public"]) @@ -15,7 +14,28 @@ ts_library( ], ), deps = [ + "//:node_modules/@google-cloud/bigquery", + "//:node_modules/@google-cloud/lineage", + "//:node_modules/@types/fs-extra", + "//:node_modules/@types/glob", + "//:node_modules/@types/js-beautify", + "//:node_modules/@types/js-yaml", + "//:node_modules/@types/long", + "//:node_modules/@types/node", + "//:node_modules/@types/semver", + "//:node_modules/@types/tmp", + "//:node_modules/deepmerge", + "//:node_modules/fs-extra", + "//:node_modules/glob", + "//:node_modules/google-sql-syntax-ts", + "//:node_modules/js-beautify", + "//:node_modules/js-yaml", + "//:node_modules/promise-pool-executor", + "//:node_modules/protobufjs", + "//:node_modules/semver", + "//:node_modules/tmp", "//cli/api/utils", + "//cli/vm", "//common/errors", "//common/flags", "//common/promises", @@ -24,36 +44,7 @@ ts_library( "//core", "//core/compilation_sql", "//protos:ts", - "//cli/vm:compile_loader", "//sqlx:lexer", - "//cli/vm:vm", - "@npm//@google-cloud/bigquery", - "@npm//@google-cloud/lineage", - "@npm//@types/fs-extra", - "@npm//@types/glob", - "@npm//@types/js-beautify", - "@npm//@types/js-yaml", - "@npm//@types/long", - "@npm//@types/node", - "@npm//@types/semver", - "@npm//@types/tmp", - "@npm//deepmerge", - "@npm//fs-extra", - "@npm//glob", - "@npm//google-sql-syntax-ts", - "@npm//js-beautify", - "@npm//js-yaml", - "@npm//promise-pool-executor", - "@npm//protobufjs", - "@npm//semver", - "@npm//tmp", - ], -) - -node_modules( - name = "node_modules", - deps = [ - "//packages/@dataform/core:package_tar", ], ) @@ -67,29 +58,24 @@ ts_test_suite( "dbadapters/bigquery_test.ts", "execution_sql_test.ts", ] + glob(["lineage/*_test.ts"]), - data = [ - ":node_modules", - "//packages/@dataform/core:package_tar", - "@nodejs//:node", - "@nodejs//:npm", - ] + glob(["goldens/**"]), + data = glob(["goldens/**"]), deps = [ ":api", "//cli/api/lineage/testing", "//core", "//protos:ts", "//testing", - "@npm//@google-cloud/bigquery", - "@npm//@google-cloud/lineage", - "@npm//@types/chai", - "@npm//@types/fs-extra", - "@npm//@types/js-yaml", - "@npm//@types/long", - "@npm//@types/node", - "@npm//chai", - "@npm//fs-extra", - "@npm//js-yaml", - "@npm//long", - "@npm//ts-mockito", + "//:node_modules/@google-cloud/bigquery", + "//:node_modules/@google-cloud/lineage", + "//:node_modules/@types/chai", + "//:node_modules/@types/fs-extra", + "//:node_modules/@types/js-yaml", + "//:node_modules/@types/long", + "//:node_modules/@types/node", + "//:node_modules/chai", + "//:node_modules/fs-extra", + "//:node_modules/js-yaml", + "//:node_modules/long", + "//:node_modules/ts-mockito", ], ) diff --git a/cli/api/commands/base_worker.ts b/cli/api/commands/base_worker.ts index 97d54d3c2..e8764ff1f 100644 --- a/cli/api/commands/base_worker.ts +++ b/cli/api/commands/base_worker.ts @@ -1,7 +1,13 @@ import { ChildProcess, fork } from "child_process"; +import * as path from "path"; export abstract class BaseWorker { - protected constructor(private readonly loaderPath: string) {} + // Loader path for tests. Unit tests need a patched loader to correctly load the worker script. + private readonly bazelLoaderRelativePath: string; + + protected constructor(bazelLoaderPath: string) { + this.bazelLoaderRelativePath = path.resolve(__dirname, "../..", bazelLoaderPath); + } protected async runWorker( timeoutMillis: number, @@ -82,7 +88,7 @@ export abstract class BaseWorker { } private resolveScript() { - const pathsToTry = ["./worker_bundle.js", this.loaderPath]; + const pathsToTry = ["./worker_bundle.js", this.bazelLoaderRelativePath]; for (const p of pathsToTry) { try { return require.resolve(p); diff --git a/cli/api/commands/compile.ts b/cli/api/commands/compile.ts index 8ef7c78c8..681c5e88f 100644 --- a/cli/api/commands/compile.ts +++ b/cli/api/commands/compile.ts @@ -104,7 +104,7 @@ export async function compile( export class CompileChildProcess extends BaseWorker { constructor() { - super(path.resolve(__dirname, "../../vm/compile_loader")); + super("vm/bazel_compile_loader"); } public async compile(compileConfig: dataform.ICompileConfig) { diff --git a/cli/api/commands/jit/compiler.ts b/cli/api/commands/jit/compiler.ts index 94b877d65..34a8d2e7e 100644 --- a/cli/api/commands/jit/compiler.ts +++ b/cli/api/commands/jit/compiler.ts @@ -1,5 +1,4 @@ import { ChildProcess } from "child_process"; -import * as path from "path"; import { BaseWorker } from "df/cli/api/commands/base_worker"; import { handleDbRequest } from "df/cli/api/commands/jit/rpc"; @@ -42,7 +41,7 @@ export class JitCompileChildProcess extends BaseWorker< } constructor() { - super(path.resolve(__dirname, "../../../vm/jit_loader")); + super("vm/bazel_jit_worker_loader"); } private async run( diff --git a/cli/api/lineage/testing/BUILD b/cli/api/lineage/testing/BUILD index ebec5c884..fd1260cc4 100644 --- a/cli/api/lineage/testing/BUILD +++ b/cli/api/lineage/testing/BUILD @@ -6,7 +6,7 @@ ts_library( name = "testing", srcs = glob(["**/*.ts"]), deps = [ - "@npm//@google-cloud/lineage", - "@npm//@types/node", + "//:node_modules/@google-cloud/lineage", + "//:node_modules/@types/node", ], ) diff --git a/cli/api/utils/BUILD b/cli/api/utils/BUILD index 42393bcdf..e01c4ae19 100644 --- a/cli/api/utils/BUILD +++ b/cli/api/utils/BUILD @@ -1,16 +1,16 @@ -package(default_visibility = ["//visibility:public"]) - load("//tools:ts_library.bzl", "ts_library") +package(default_visibility = ["//visibility:public"]) + ts_library( name = "utils", srcs = glob(["**/*.ts"]), deps = [ + "//:node_modules/@types/node", + "//:node_modules/object-sizeof", "//common/protos", "//common/strings", "//core", "//protos:ts", - "@npm//@types/node", - "@npm//object-sizeof", ], ) diff --git a/cli/commands/compile_command.ts b/cli/commands/compile_command.ts index f17e07267..8bc6f9c6c 100644 --- a/cli/commands/compile_command.ts +++ b/cli/commands/compile_command.ts @@ -128,7 +128,7 @@ export const compileCommand: ICommand = { process.exit(1); }); while (watching) { - await new Promise((resolve, reject) => setTimeout(() => resolve(), 100)); + await new Promise((resolve, reject) => setTimeout(() => resolve(), 100)); } return 0; }, diff --git a/cli/index_test_base.ts b/cli/index_test_base.ts index 866672735..93a9001c5 100644 --- a/cli/index_test_base.ts +++ b/cli/index_test_base.ts @@ -18,9 +18,9 @@ import { TmpDirFixture } from "df/testing/fixtures"; const DEFAULT_PROJECT = "dataform-open-source"; const DEFAULT_LOCATION = "US"; -const runfilesDir = process.env.RUNFILES; +const runfilesDir = process.env.RUNFILES || ""; let workspaceName = "df"; -if (!fs.existsSync(path.resolve(runfilesDir, "df"))) { +if (runfilesDir && !fs.existsSync(path.resolve(runfilesDir, "df"))) { workspaceName = "_main"; } @@ -66,7 +66,11 @@ export const INTEGRATION_TEST_PROJECT = getCredentialsProjectId(); export const INTEGRATION_TEST_LOCATION = getCredentialsLocation(); export const INTEGRATION_TEST_RESERVATION = `projects/${INTEGRATION_TEST_PROJECT}/locations/${INTEGRATION_TEST_LOCATION.toLowerCase()}/reservations/dataform-test`; -export const cliEntryPointPath = "cli/node_modules/@dataform/cli/bundle.js"; +export const cliEntryPointPath = path.resolve( + runfilesDir, + workspaceName, + "packages/@dataform/cli/bundle.js", +); export async function setupProject( tmpDirFixture: TmpDirFixture, diff --git a/cli/vm/BUILD b/cli/vm/BUILD index 4adc5f391..85cdce65f 100644 --- a/cli/vm/BUILD +++ b/cli/vm/BUILD @@ -1,7 +1,7 @@ -package(default_visibility = ["//visibility:public"]) - load("//tools:ts_library.bzl", "ts_library") +package(default_visibility = ["//visibility:public"]) + ts_library( name = "vm", srcs = [ @@ -9,61 +9,36 @@ ts_library( "jit_worker.ts", ], deps = [ + "//:node_modules/@types/glob", + "//:node_modules/@types/node", + "//:node_modules/@types/semver", + "//:node_modules/glob", + "//:node_modules/semver", + "//:node_modules/vm2", "//common/protos", "//core", "//protos:ts", - "@npm//@types/glob", - "@npm//@types/node", - "@npm//@types/semver", - "@npm//glob", - "@npm//semver", - "@npm//vm2", ], ) -ts_library( - name = "compile_loader", - srcs = [], - data = [ - ":compile_loader.js", - ":jit_loader.js", - ], - deps = [ - ":vm", - "@npm//source-map-support", - ], -) - -load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") - # This is a bit nuts. As we fork a process when compiling projects, we # start a new node instance but within bazel, modules will fail to load in the # forked process as we don't have a loader script available. -# To fix this, we use the binary rules to generate the bazel loader scripts +# To fix this, we generate the bazel loader scripts # and then execute these scripts instead, so module resulution works. -nodejs_binary( - name = "compile", - data = [ - ":vm", - "@npm//source-map-support", - ], - entry_point = ":compile.ts", - templated_args = [ - "--node_options=--require=source-map-support/register", - "--bazel_patch_module_resolver", - ], +genrule( + name = "bazel_compile_loader", + srcs = ["//testing:resolver-patch.js", "compile.js"], + outs = ["bazel_compile_loader.js"], + cmd = "cat $(SRCS) > $@", + testonly = True, ) -nodejs_binary( - name = "jit_worker_bin", - data = [ - ":vm", - "@npm//source-map-support", - ], - entry_point = ":jit_worker.ts", - templated_args = [ - "--node_options=--require=source-map-support/register", - "--bazel_patch_module_resolver", - ], +genrule( + name = "bazel_jit_worker_loader", + srcs = ["//testing:resolver-patch.js", "jit_worker.js"], + outs = ["bazel_jit_worker_loader.js"], + cmd = "cat $(SRCS) > $@", + testonly = True, ) diff --git a/cli/vm/jit_loader.js b/cli/vm/jit_loader.js deleted file mode 100644 index 56dd2906a..000000000 --- a/cli/vm/jit_loader.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -if (require.main === module) { - try { - // jit_loader.js acts as the entrypoint loader for JIT development, loading jit_worker.js - // directly. The static compiler listener (listenForCompileRequest) is omitted here since - // static compilation in development is loaded via its own loader (compile_loader.js). - var jitWorker = require('./jit_worker'); - jitWorker.registerRpcResponseHandler(); - jitWorker.registerJitCompileHandler(); - if (process.send) { - process.send({ type: 'worker_booted' }); - } - } catch (e) { - console.error(e.stack || e); - process.exit(1); - } -} diff --git a/cli/vm/jit_worker.ts b/cli/vm/jit_worker.ts index 58c9f37e5..8c76a4283 100644 --- a/cli/vm/jit_worker.ts +++ b/cli/vm/jit_worker.ts @@ -9,7 +9,13 @@ const pendingRpcCallbacks = new Map< (err: string | null, resBytes: Uint8Array | null) => void >(); +let rpcResponseHandlerRegistered = false; + export function registerRpcResponseHandler() { + if (rpcResponseHandlerRegistered) { + return; + } + rpcResponseHandlerRegistered = true; process.on("message", (res: any) => { if (res.type === "rpc_response") { const callback = pendingRpcCallbacks.get(res.correlationId); @@ -21,7 +27,13 @@ export function registerRpcResponseHandler() { }); } +let jitCompileHandlerRegistered = false; + export function registerJitCompileHandler() { + if (jitCompileHandlerRegistered) { + return; + } + jitCompileHandlerRegistered = true; let hasStartedProcessing = false; process.on("message", async (message: any) => { if (message.type === "jit_compile") { @@ -134,3 +146,11 @@ export async function handleJitRequest(message: { request: any; projectDir: stri process.send({ type: "jit_error", error: e.stack || e.message }); } } + +if (require.main === module) { + registerRpcResponseHandler(); + registerJitCompileHandler(); + if (process.send) { + process.send({ type: "worker_booted" }); + } +} diff --git a/common/errors/BUILD b/common/errors/BUILD index b806837f0..79888d99e 100644 --- a/common/errors/BUILD +++ b/common/errors/BUILD @@ -10,25 +10,17 @@ ts_library( exclude = ["*.spec.ts"], ), deps = [ - "//:modules-fix", ], ) ts_test_suite( name = "tests", srcs = glob(["*.spec.ts"]), - data = [ - "@npm//source-map-support", - ], - templated_args = [ - "--node_options=--require=source-map-support/register", - "--bazel_patch_module_resolver", - ], deps = [ ":errors", + "//:node_modules/@types/chai", + "//:node_modules/@types/node", + "//:node_modules/chai", "@df//testing", - "@npm//@types/chai", - "@npm//@types/node", - "@npm//chai", ], ) diff --git a/common/flags/BUILD b/common/flags/BUILD index 778c0acc3..0508e3dcb 100644 --- a/common/flags/BUILD +++ b/common/flags/BUILD @@ -1,8 +1,9 @@ -package(default_visibility = ["//visibility:public"]) - +load("//testing:build_test.bzl", "build_test") load("//tools:ts_library.bzl", "ts_library") load("@df//testing:index.bzl", "ts_test_suite") +package(default_visibility = ["//visibility:public"]) + ts_library( name = "flags", srcs = glob( @@ -10,34 +11,24 @@ ts_library( exclude = ["*_test.ts", "*.spec.ts"], ), deps = [ - "//:modules-fix", - "@npm//@types/long", - "@npm//@types/node", - "@npm//long", + "//:node_modules/@types/long", + "//:node_modules/@types/node", + "//:node_modules/long", ], ) ts_test_suite( name = "tests", srcs = glob(["*_test.ts"]), - data = [ - "@npm//source-map-support", - ], - templated_args = [ - "--node_options=--require=source-map-support/register", - "--bazel_patch_module_resolver", - ], deps = [ ":flags", + "//:node_modules/@types/chai", + "//:node_modules/@types/node", + "//:node_modules/chai", "@df//testing", - "@npm//@types/chai", - "@npm//@types/node", - "@npm//chai", ], ) -load("//testing:build_test.bzl", "build_test") - build_test( name = "build_test", deps = [":flags"], diff --git a/common/flags/testing/BUILD b/common/flags/testing/BUILD index 32de5ba60..2660535f9 100644 --- a/common/flags/testing/BUILD +++ b/common/flags/testing/BUILD @@ -1,7 +1,7 @@ -package(default_visibility = ["//visibility:public"]) - load("//tools:ts_library.bzl", "ts_library") +package(default_visibility = ["//visibility:public"]) + ts_library( name = "testing", testonly = 1, @@ -9,7 +9,6 @@ ts_library( ["*.ts"], ), deps = [ - "//:modules-fix", "//common/flags", "//testing", ], diff --git a/common/promises/BUILD b/common/promises/BUILD index d34deba15..ef060b934 100644 --- a/common/promises/BUILD +++ b/common/promises/BUILD @@ -1,5 +1,5 @@ -load("@df//tools:ts_library.bzl", "ts_library") load("@df//testing:index.bzl", "ts_test_suite") +load("@df//tools:ts_library.bzl", "ts_library") package(default_visibility = ["//visibility:public"]) @@ -10,26 +10,18 @@ ts_library( exclude = ["*.spec.ts"], ), deps = [ - "//:modules-fix", - "@npm//@types/node", + "//:node_modules/@types/node", ], ) ts_test_suite( name = "tests", srcs = glob(["*.spec.ts"]), - data = [ - "@npm//source-map-support", - ], - templated_args = [ - "--node_options=--require=source-map-support/register", - "--bazel_patch_module_resolver", - ], deps = [ ":promises", + "//:node_modules/@types/chai", + "//:node_modules/@types/node", + "//:node_modules/chai", "@df//testing", - "@npm//@types/chai", - "@npm//@types/node", - "@npm//chai", ], ) diff --git a/common/promises/index.ts b/common/promises/index.ts index 55380d3e8..6f0a01908 100644 --- a/common/promises/index.ts +++ b/common/promises/index.ts @@ -27,7 +27,7 @@ export async function runWithTimeout( } export async function sleep(sleepMillis: number) { - await new Promise((resolve) => setTimeout(() => resolve(), sleepMillis)); + await new Promise((resolve) => setTimeout(() => resolve(), sleepMillis)); } export async function sleepUntil( @@ -40,7 +40,7 @@ export async function sleepUntil( } export async function sleepImmediate() { - await new Promise((resolve) => setImmediate(resolve)); + await new Promise((resolve) => setImmediate(resolve)); } export async function retry( diff --git a/common/protos/BUILD b/common/protos/BUILD index 86ceeab02..06dd47407 100644 --- a/common/protos/BUILD +++ b/common/protos/BUILD @@ -1,45 +1,39 @@ -package(default_visibility = ["//visibility:public"]) - -load("//tools:ts_library.bzl", "ts_library") load("@df//testing:index.bzl", "ts_test_suite") +load("//testing:build_test.bzl", "build_test") +load("//tools:ts_library.bzl", "ts_library") + +package(default_visibility = ["//visibility:public"]) ts_library( name = "protos", srcs = glob( ["*.ts"], - exclude = ["*_test.ts", "*.spec.ts"], + exclude = [ + "*_test.ts", + "*.spec.ts", + ], ), deps = [ - "//:modules-fix", + "//:node_modules/@types/node", + "//:node_modules/protobufjs", "//common/strings", "//protos:ts", - "@npm//@types/node", - "@npm//protobufjs", ], ) ts_test_suite( name = "tests", srcs = glob(["*_test.ts"]), - data = [ - "@npm//source-map-support", - ], - templated_args = [ - "--node_options=--require=source-map-support/register", - "--bazel_patch_module_resolver", - ], deps = [ ":protos", + "//:node_modules/@types/chai", + "//:node_modules/@types/node", + "//:node_modules/chai", "//protos:ts", "@df//testing", - "@npm//@types/chai", - "@npm//@types/node", - "@npm//chai", ], ) -load("//testing:build_test.bzl", "build_test") - build_test( name = "build_test", deps = [":protos"], diff --git a/common/strings/BUILD b/common/strings/BUILD index 6e171d1b0..40318fc49 100644 --- a/common/strings/BUILD +++ b/common/strings/BUILD @@ -10,28 +10,20 @@ ts_library( exclude = ["*.spec.ts"], ), deps = [ - "//:modules-fix", - "@npm//@types/long", - "@npm//long", + "//:node_modules/@types/long", + "//:node_modules/long", ], ) ts_test_suite( name = "tests", srcs = glob(["*.spec.ts"]), - data = [ - "@npm//source-map-support", - ], - templated_args = [ - "--node_options=--require=source-map-support/register", - "--bazel_patch_module_resolver", - ], deps = [ ":strings", + "//:node_modules/@types/chai", + "//:node_modules/@types/long", + "//:node_modules/@types/node", + "//:node_modules/chai", "@df//testing", - "@npm//@types/chai", - "@npm//@types/long", - "@npm//@types/node", - "@npm//chai", ], ) diff --git a/contributing.md b/contributing.md index 96096a514..2f8244316 100644 --- a/contributing.md +++ b/contributing.md @@ -90,8 +90,6 @@ All .ts files are expected to be formatted using prettier. You can format all fi Alternatively, you may want to configure prettier to run on save or as a pre-commit hook. -Note that some files may predate the enforcement of this standard and not be properly formatted yet. If you modify such files, you will have to format the entire file before submitting, even for a small change. - ### Building Building the CLI will build most of the required components. @@ -104,14 +102,14 @@ The projects folder here is not built as it requires an environment file, which ### Add New NPM Dependencies -Global yarn installations will throw errors when installing packages, instead you should use: +Global pnpm installations will throw errors when installing packages, instead you should use: ```bash -$ bazel run @nodejs//:yarn add ... +$ bazel run -- @pnpm --dir "$PWD" add ... ``` Additionally, installed NPM dependencies need to be added to the `deps` of `ts_library` rules by -prefixing them with `@npm//...`. +prefixing them with `//:node_modules/...`. ## The Contribution Process diff --git a/core/BUILD b/core/BUILD index 4a9b78459..10c88a9a1 100644 --- a/core/BUILD +++ b/core/BUILD @@ -45,21 +45,21 @@ ts_library( ":version.ts", ], deps = [ + "//:node_modules/@types/fs-extra", + "//:node_modules/@types/js-yaml", + "//:node_modules/@types/node", + "//:node_modules/@types/semver", + "//:node_modules/fs-extra", + "//:node_modules/js-yaml", + "//:node_modules/protobufjs", + "//:node_modules/semver", + "//:node_modules/tarjan-graph", "//common/errors", "//common/protos", "//common/strings", "//core/compilation_sql", "//protos:ts", "//sqlx:lexer", - "@npm//@types/fs-extra", - "@npm//@types/js-yaml", - "@npm//@types/node", - "@npm//@types/semver", - "@npm//fs-extra", - "@npm//js-yaml", - "@npm//protobufjs", - "@npm//semver", - "@npm//tarjan-graph", ], ) @@ -102,19 +102,19 @@ ts_test_suite( ], deps = [ ":core", + "//:node_modules/@types/chai", + "//:node_modules/@types/fs-extra", + "//:node_modules/@types/js-yaml", + "//:node_modules/@types/long", + "//:node_modules/@types/node", + "//:node_modules/chai", + "//:node_modules/fs-extra", + "//:node_modules/js-yaml", + "//:node_modules/long", "//common/protos", "//protos:ts", "//testing", "//testing:run_core", - "@npm//@types/chai", - "@npm//@types/fs-extra", - "@npm//@types/js-yaml", - "@npm//@types/long", - "@npm//@types/node", - "@npm//chai", - "@npm//fs-extra", - "@npm//js-yaml", - "@npm//long", ], ) diff --git a/core/compilation_sql/BUILD b/core/compilation_sql/BUILD index 8562e708a..8bc796022 100644 --- a/core/compilation_sql/BUILD +++ b/core/compilation_sql/BUILD @@ -9,5 +9,5 @@ ts_library( ], deps = [ "//protos:ts", - ] + ], ) diff --git a/examples/BUILD b/examples/BUILD index 114137428..7d86a7a6d 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -1,9 +1,10 @@ +load("@aspect_rules_js//js:defs.bzl", "js_library") load("//testing:index.bzl", "ts_test_suite") load("//tools:node_modules.bzl", "node_modules") package(default_visibility = ["//visibility:private"]) -filegroup( +js_library( name = "all_projects", srcs = glob( [ @@ -22,28 +23,27 @@ ts_test_suite( data = [ ":all_projects", ":node_modules", - "//packages/@dataform/core:package_tar", - "@nodejs//:node", + "//packages/@dataform/cli:bundle", + "//packages/@dataform/cli:json", + "//packages/@dataform/cli:worker_bundle", ], deps = [ + "//:node_modules/@types/chai", + "//:node_modules/@types/fs-extra", + "//:node_modules/@types/node", + "//:node_modules/chai", + "//:node_modules/fs-extra", + "//cli:index_test_base", "//cli/api", "//common/protos", "//protos:ts", "//testing", - "@npm//@types/chai", - "@npm//@types/fs-extra", - "@npm//@types/node", - "@npm//chai", - "@npm//fs-extra", ], ) node_modules( name = "node_modules", deps = [ - # The CLI bundle remains at this directory level's node_modules, whereas the core package - # is copied into each example project's node_modules during testing. - "//packages/@dataform/cli:package_tar", "//packages/@dataform/core:package_tar", ], ) diff --git a/examples/examples_test.ts b/examples/examples_test.ts index 429146b32..9e16ac1b7 100644 --- a/examples/examples_test.ts +++ b/examples/examples_test.ts @@ -2,13 +2,12 @@ import { expect } from "chai"; import { execFile } from "child_process"; import * as fs from "fs-extra"; +import { cliEntryPointPath } from "df/cli/index_test_base"; import { verifyObjectMatchesProto } from "df/common/protos"; import { dataform } from "df/protos/ts"; import { getProcessResult, nodePath, suite, test } from "df/testing"; suite("examples", { parallel: true }, () => { - const cliEntryPointPath = "examples/node_modules/@dataform/cli/bundle.js"; - ["stackoverflow_reporter", "extreme_weather_programming"].forEach((exampleProject) => { test(`${exampleProject} runs`, async () => { // compile() calls realpath on projectDir, which would jump out of bazel's diff --git a/package.json b/package.json index de16faa75..829021761 100644 --- a/package.json +++ b/package.json @@ -33,11 +33,6 @@ "yargs": "^16.2.0" }, "devDependencies": { - "@bazel/hide-bazel-files": "1.0.0", - "@bazel/ibazel": "^0.9.1", - "@bazel/labs": "^0.42.3", - "@bazel/rollup": "^3.0.0", - "@bazel/typescript": "^3.0.0", "@rollup/plugin-node-resolve": "^7.1.3", "@types/chai": "^4.1.7", "@types/diff": "^4.0.2", @@ -79,31 +74,31 @@ "webpack-cli": "4.10.0" }, "resolutions": { - "**/object-path": "^0.11.5", - "**/http-proxy": "^1.18.1", - "**/serialize-javascript": "^7.1.1", - "**/ssri": "^7.1.1", - "**/glob-parent": "^5.1.2", - "**/node-forge": "^1.0.0", - "**/json-bigint": "^1.0.0", - "**/y18n": "^5.0.5", - "**/underscore": "^1.12.1", - "**/protobufjs": "^7.0.0", - "**/ansi-regex": "^3.0.1", - "**/json-schema": "^0.4.0", - "**/nth-check": "^2.0.1", - "**/node-fetch": "^2.6.7", - "**/markdown-it": "14.3.1", - "**/mdurl": "2.0.0", - "**/wrap-ansi": "7.0.0", - "**/string-width": "4.1.0", - "**/@eslint-community/eslint-utils": "4.9.1", - "**/@ungap/structured-clone": "1.3.1", - "**/brace-expansion": "5.0.9", - "**/linkify-it": "^5.0.2", - "**/braces": "^3.0.3", - "**/@eslint/plugin-kit": "0.7.2", - "@google-cloud/storage/**/uuid": "14.0.2", - "**/fast-uri": "3.1.7" + "object-path": "^0.11.5", + "http-proxy": "^1.18.1", + "serialize-javascript": "^7.1.1", + "ssri": "^7.1.1", + "glob-parent": "^5.1.2", + "node-forge": "^1.0.0", + "json-bigint": "^1.0.0", + "y18n": "^5.0.5", + "underscore": "^1.12.1", + "protobufjs": "^7.6.5", + "ansi-regex": "^3.0.1", + "json-schema": "^0.4.0", + "nth-check": "^2.0.1", + "node-fetch": "^2.6.7", + "markdown-it": "14.3.1", + "mdurl": "2.0.0", + "wrap-ansi": "7.0.0", + "string-width": "4.1.0", + "@eslint-community/eslint-utils": "4.9.1", + "@ungap/structured-clone": "1.3.1", + "brace-expansion": "5.0.9", + "linkify-it": "^5.0.2", + "braces": "^3.0.3", + "@eslint/plugin-kit": "0.7.2", + "uuid": "14.0.2", + "fast-uri": "3.1.7" } } diff --git a/packages/@dataform/BUILD b/packages/@dataform/BUILD index b7dc663a1..19ffc6320 100644 --- a/packages/@dataform/BUILD +++ b/packages/@dataform/BUILD @@ -1 +1,9 @@ +load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin") + +copy_to_bin( + name = "package_layer", + srcs = ["package.layer.json"], + visibility = ["//visibility:public"], +) + exports_files(["package.layer.json"]) diff --git a/packages/@dataform/cli/BUILD b/packages/@dataform/cli/BUILD index 31309c581..198f5275e 100644 --- a/packages/@dataform/cli/BUILD +++ b/packages/@dataform/cli/BUILD @@ -1,10 +1,17 @@ -load("//tools:ts_library.bzl", "ts_library") +load("@aspect_rules_js//js:defs.bzl", "js_binary") load("//:version.bzl", "DF_VERSION") -load("//packages:index.bzl", "LICENSE_HEADER", "add_license_header_to_file", "pkg_bundle", "pkg_json", "pkg_npm_tar") -load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") +load("//packages:index.bzl", "add_license_header_to_file", "pkg_bundle", "pkg_json", "pkg_npm_tar") +load("//tools:ts_library.bzl", "ts_library") package(default_visibility = ["//visibility:public"]) +genrule( + name = "register_loader_gen", + srcs = ["//testing:resolver-patch.js"], + outs = ["register_loader.js"], + cmd = "cat $(SRCS) > $@", +) + ts_library( name = "cli", srcs = glob(["*.ts"]), @@ -12,22 +19,21 @@ ts_library( "//cli", "//cli/api", "//cli/vm", - "//cli/vm:compile_loader", "//protos:ts", ], ) -nodejs_binary( +js_binary( name = "bin", data = [ + "bin_loader.js", + ":register_loader.js", ":cli", - "@npm//source-map-support", - ], - entry_point = ":index.ts", - templated_args = [ - "--node_options=--require=source-map-support/register", - "--bazel_patch_module_resolver", + "//cli/vm:bazel_compile_loader", + "//cli/vm:bazel_jit_worker_loader", ], + entry_point = "bin_loader.js", + testonly = True, ) externals = [ @@ -61,8 +67,8 @@ pkg_json( description = "Dataform command line interface.", external_deps = externals, layers = [ - "//:package.json", - "//packages/@dataform:package.layer.json", + "//:package_json", + "//packages/@dataform:package_layer", "//packages/@dataform/cli:package.layer.json", ], main = "bundle.js", @@ -70,27 +76,39 @@ pkg_json( ) pkg_bundle( - name = "bundle", + name = "bundle_no_license", allow_node_builtins = True, - args = ["--banner='#!/usr/bin/env node\n" + LICENSE_HEADER + "'"], - entry_point = "index.ts", + entry_point = "esm/index.js", externals = externals, deps = [ ":cli", ], ) +add_license_header_to_file( + name = "bundle", + from_file = ":bundle_no_license", + to_file = "bundle.js", + use_shebang = True, +) + pkg_bundle( - name = "worker_bundle", + name = "worker_bundle_no_license", allow_node_builtins = True, - args = ["--banner='#!/usr/bin/env node\n" + LICENSE_HEADER + "'"], - entry_point = "worker.ts", + entry_point = "esm/worker.js", externals = externals, deps = [ ":cli", ], ) +add_license_header_to_file( + name = "worker_bundle", + from_file = ":worker_bundle_no_license", + to_file = "worker_bundle.js", + use_shebang = True, +) + pkg_npm_tar( name = "package", deps = [ diff --git a/packages/@dataform/cli/bin_loader.js b/packages/@dataform/cli/bin_loader.js new file mode 100644 index 000000000..a4cb31b5a --- /dev/null +++ b/packages/@dataform/cli/bin_loader.js @@ -0,0 +1,2 @@ +require('./register_loader.js'); +require('./index.js'); diff --git a/packages/@dataform/core/BUILD b/packages/@dataform/core/BUILD index 15edc71ce..97d5111bc 100644 --- a/packages/@dataform/core/BUILD +++ b/packages/@dataform/core/BUILD @@ -1,9 +1,7 @@ -load("@build_bazel_rules_nodejs//:index.bzl", "npm_package_bin") -load("@npm//webpack:index.bzl", "webpack") +load("@aspect_rules_webpack//webpack:defs.bzl", "webpack_bundle") load("//:version.bzl", "DF_VERSION") -load("//packages:index.bzl", "add_license_header_to_file", "pkg_bundle", "pkg_bundle_dts", "pkg_json", "pkg_npm_tar") +load("//packages:index.bzl", "add_license_header_to_file", "pkg_bundle_dts", "pkg_json", "pkg_npm_tar", "pkg_transitive_types") load("//tools:ts_library.bzl", "ts_library") -load("//tools/common:copy.bzl", "copy_file") package(default_visibility = ["//visibility:public"]) @@ -15,31 +13,28 @@ ts_library( ], ) -webpack( - name = "bundler", - data = [ - ":core", - ":webpack.config.js", - "@npm//webpack-cli", - ], -) - -# RULEDIR explanation: https://bazel.build/reference/be/make-variables#predefined_genrule_variables -npm_package_bin( - name = "bundle", - outs = [ - "bundle_no_license.js", - ], +webpack_bundle( + name = "bundle_no_license", args = [ - "--config=$(location webpack.config.js)", - "--output-path=$(RULEDIR)", - "--output-filename=bundle_no_license.js", "--mode=production", ], data = [ ":webpack.config.js", + "//:node_modules/webpack-cli", + ], + entry_point = "index.js", + node_modules = "//:node_modules", + webpack_config = ":webpack.config.js", + deps = [ + ":core", + "//common/errors", + "//common/protos", + "//common/strings", + "//core", + "//core/compilation_sql", + "//protos:ts", + "//sqlx:lexer", ], - tool = ":bundler", ) pkg_json( @@ -48,8 +43,8 @@ pkg_json( description = "Dataform core API.", external_deps = [], layers = [ - "//:package.json", - "//packages/@dataform:package.layer.json", + "//:package_json", + "//packages/@dataform:package_layer", ], main = "bundle.js", version = DF_VERSION, @@ -87,13 +82,20 @@ add_license_header_to_file( add_license_header_to_file( name = "bundle_with_license", - from_file = "bundle", + from_file = ":bundle_no_license", to_file = "bundle.js", ) +pkg_transitive_types( + name = "core_transitive_types", + deps = [ + ":core", + ], +) + pkg_bundle_dts( name = "bundle.d", - entry_point = "index.ts", + entry_point = "index.d.ts", externals = [ "protobufjs", "tarjan-graph", @@ -103,6 +105,7 @@ pkg_bundle_dts( ], deps = [ ":core", + ":core_transitive_types", ], ) @@ -114,9 +117,8 @@ pkg_npm_tar( ":configs_proto_with_license", ":core_proto_with_license", ":db_adapter_proto_with_license", - ":jit_proto_with_license", ":extension_proto_with_license", + ":jit_proto_with_license", ":package.json", - "//:version.bzl", ], ) diff --git a/packages/@dataform/core/webpack.config.js b/packages/@dataform/core/webpack.config.js index 5c2328c4d..35ffc9983 100644 --- a/packages/@dataform/core/webpack.config.js +++ b/packages/@dataform/core/webpack.config.js @@ -1,38 +1,35 @@ const path = require("path"); const webpack = require("webpack"); -const fs = require("fs"); - module.exports = (env, argv) => { - const runfilesDir = process.env.RUNFILES; - let workspaceName = "df"; - if (!fs.existsSync(path.resolve(runfilesDir, "df"))) { - workspaceName = "_main"; - } + const binDir = process.cwd().endsWith("bin") + ? process.cwd() + : path.resolve(process.cwd(), process.env.BAZEL_BINDIR || "."); const config = { mode: argv.mode || "development", - target: 'node', - entry: [path.resolve(runfilesDir, workspaceName, "packages/@dataform/core/index")], + target: "node", + devtool: false, output: { libraryTarget: "commonjs-module", }, optimization: { - minimize: true + minimize: true, + moduleIds: "deterministic", }, stats: { - warnings: true + warnings: true, }, resolve: { - extensions: [".ts", ".js", ".json"], + extensions: [".js", ".json"], alias: { - df: path.resolve(runfilesDir, workspaceName) - } + df: binDir, + }, }, plugins: [ new webpack.optimize.LimitChunkCountPlugin({ - maxChunks: 1 - }) + maxChunks: 1, + }), ], }; return config; diff --git a/packages/BUILD b/packages/BUILD index 97e326b6f..fd8edb0de 100644 --- a/packages/BUILD +++ b/packages/BUILD @@ -1,8 +1,19 @@ +load("@aspect_bazel_lib//lib:copy_to_bin.bzl", "copy_to_bin") +load("@aspect_rules_js//js:defs.bzl", "js_binary") load("//tools:ts_library.bzl", "ts_library") -load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary") package(default_visibility = ["//visibility:public"]) +copy_to_bin( + name = "rollup_config", + srcs = ["rollup.config.js"], +) + +copy_to_bin( + name = "rollup_dts_config", + srcs = ["rollup_dts.config.js"], +) + exports_files([ "rollup.config.js", "rollup_dts.config.js", @@ -12,21 +23,16 @@ ts_library( name = "gen-package-json", srcs = ["gen_package_json.ts"], deps = [ - "@npm//@types/node", - "@npm//@types/yargs", - "@npm//yargs", + "//:node_modules/@types/node", + "//:node_modules/@types/yargs", + "//:node_modules/yargs", ], ) -nodejs_binary( +js_binary( name = "gen-package-json-bin", - templated_args = [ - "--node_options=--require=source-map-support/register", - "--bazel_patch_module_resolver", - ], data = [ ":gen-package-json", - "@npm//source-map-support", ], - entry_point = ":gen_package_json.ts", + entry_point = "gen_package_json.js", ) diff --git a/packages/index.bzl b/packages/index.bzl index 8e5d5a748..3dc4aaa9b 100644 --- a/packages/index.bzl +++ b/packages/index.bzl @@ -1,6 +1,23 @@ -load("@npm//@bazel/rollup:index.bzl", "rollup_bundle") -load(":rollup_bundle_dts.bzl", "rollup_bundle_dts") -load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm") +load("@aspect_bazel_lib//lib:directory_path.bzl", "directory_path") +load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_run_binary") +load("@aspect_rules_js//js:providers.bzl", "JsInfo") +load("@aspect_rules_js//npm:defs.bzl", "npm_package") +load("@aspect_rules_rollup//rollup:defs.bzl", "rollup") + +LICENSE_HEADER = """// Copyright 2023 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +""" def pkg_json(name, package_name, description, version, external_deps = [], layers = [], main = "", types = ""): native.genrule( @@ -8,7 +25,7 @@ def pkg_json(name, package_name, description, version, external_deps = [], layer srcs = layers, tools = ["//packages:gen-package-json-bin"], outs = ["package.json"], - cmd = """$(location //packages:gen-package-json-bin) \\ + cmd = """BAZEL_BINDIR=. $(location //packages:gen-package-json-bin) \\ --name {name} \\ --description '{description}' \\ --package-version {version} \\ @@ -27,38 +44,79 @@ def pkg_json(name, package_name, description, version, external_deps = [], layer ), ) -def pkg_bundle(deps, externals, allow_node_builtins = False, args = [], **kwargs): +def pkg_bundle(name, deps, externals, entry_point = "index.js", allow_node_builtins = False, args = [], **kwargs): base_args = ["--external={}".format(",".join(externals))] if allow_node_builtins: base_args.append("--environment=ALLOW_NODE_BUILTINS") - rollup_bundle( - config_file = "//packages:rollup.config.js", + + rollup( + name = name, + config_file = "//packages:rollup_config", args = base_args + args, format = "cjs", sourcemap = "false", - deps = [ - "@npm//@rollup/plugin-node-resolve", - ] + deps, + entry_point = entry_point, + node_modules = "//:node_modules", + deps = deps + [ + "//:node_modules/@rollup/plugin-node-resolve", + ], **kwargs ) -def pkg_bundle_dts(deps, externals, args = [], **kwargs): - rollup_bundle_dts( - config_file = "//packages:rollup_dts.config.js", - args = ["--external={}".format(",".join(externals))] + args, - format = "cjs", - sourcemap = "false", - deps = [ - "@npm//rollup-plugin-dts", - ] + deps, +def pkg_bundle_dts(name, deps, externals, entry_point = "index.d.ts", **kwargs): + entry_point_label = entry_point if entry_point.startswith(":") or entry_point.startswith("//") else ":" + entry_point + package = native.package_name() + + rollup_entry_point = "_{}_rollup_entry_point".format(name) + directory_path( + name = rollup_entry_point, + directory = "//:node_modules/rollup/dir", + path = "dist/bin/rollup", + ) + + rollup_bin = "_{}_rollup_binary".format(name) + js_binary( + name = rollup_bin, + data = [ + "//:node_modules/rollup", + "//:node_modules/rollup-plugin-dts", + ], + entry_point = ":" + rollup_entry_point, + ) + + out_filename = name + if not out_filename.endswith(".d.ts"): + if out_filename.endswith(".d"): + out_filename = out_filename + ".ts" + else: + out_filename = out_filename + ".d.ts" + + js_run_binary( + name = name, + tool = ":" + rollup_bin, + srcs = deps + [ + "//packages:rollup_dts_config", + entry_point_label, + ], + outs = [out_filename], + args = [ + "--config", + "packages/rollup_dts.config.js", + "--input", + package + "/" + entry_point, + "--file", + package + "/" + out_filename, + "--external", + ",".join(externals), + ], **kwargs ) def pkg_npm_tar(name, srcs = [], deps = []): - pkg_npm( + npm_package( name = name, - srcs = srcs, - deps = deps, + srcs = srcs + deps, + visibility = ["//visibility:public"], ) native.genrule( name = name + "_tar", @@ -66,35 +124,41 @@ def pkg_npm_tar(name, srcs = [], deps = []): outs = [name + ".tar.gz"], cmd = "tar -cvzf $(location {name}.tar.gz) -C $(location :{name})/.. --dereference {name}" .format(name = name), + visibility = ["//visibility:public"], ) -LICENSE_HEADER = """// Copyright 2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -""" - -def add_license_header_to_file(name, from_file, to_file): - """ - Adds the Apache 2.0 license header to a file. This is not done in-place because Bazel requires - separate output and input files. - """ +def add_license_header_to_file(name, from_file, to_file, use_shebang = False, **kwargs): + header = LICENSE_HEADER + if use_shebang: + header = "#!/usr/bin/env node\\n" + header native.genrule( - name=name, - srcs=[from_file], - outs=[to_file], - cmd=( - ( - "echo '{license_header}' | cat - $(location {from_file}) > $(location {to_file})" - ).format(from_file=from_file, to_file=to_file, license_header=LICENSE_HEADER) - ), + name = name, + srcs = [from_file], + outs = [to_file], + cmd = "echo -e '{header}' | cat - $(location {from_file}) > $(location {to_file})" + .format(from_file = from_file, to_file = to_file, header = header), + **kwargs ) + +def _pkg_transitive_types_impl(ctx): + transitive_types = [] + for dep in ctx.attr.deps: + if JsInfo in dep: + transitive_types.append(dep[JsInfo].transitive_types) + elif DefaultInfo in dep: + transitive_types.append(dep[DefaultInfo].files) + + return [ + DefaultInfo( + files = depset(transitive = transitive_types) + ) + ] + +pkg_transitive_types = rule( + implementation = _pkg_transitive_types_impl, + attrs = { + "deps": attr.label_list( + mandatory = True, + ), + }, +) diff --git a/packages/rollup.config.js b/packages/rollup.config.js index 3ac33cdec..099c0b9d0 100644 --- a/packages/rollup.config.js +++ b/packages/rollup.config.js @@ -1,4 +1,21 @@ import resolve from "@rollup/plugin-node-resolve"; +import * as path from "path"; +import * as fs from "fs"; + +function findBazelBin() { + if (!process.env.BAZEL_BINDIR) { + return undefined; + } + let dir = process.cwd(); + while (dir && !fs.existsSync(path.join(dir, "bazel-out"))) { + const parent = path.dirname(dir); + if (parent === dir) { + break; + } + dir = parent; + } + return path.resolve(dir, process.env.BAZEL_BINDIR); +} function convertToRegex(pattern) { if (pattern instanceof RegExp) { @@ -20,14 +37,13 @@ const knownNodeBuiltins = [ "events", "long", "https", - "net" -].map(moduleName => convertToRegex(moduleName)); + "net", +].map((moduleName) => convertToRegex(moduleName)); const importsToBundle = ["df", /df\/.*$/, /^bazel\-.*$/]; -const checkImports = imports => { - const allowedImports = [...imports].map(pattern => convertToRegex(pattern)); - +const checkImports = (imports) => { + const allowedImports = [...imports].map((pattern) => convertToRegex(pattern)); // We're going to read these from the arguments. let externals = () => false; let allowNodeBuiltins = process.env.ALLOW_NODE_BUILTINS; @@ -37,15 +53,65 @@ const checkImports = imports => { externals = options.external || (() => false); }, resolveId(source) { - // Either this is an internal import, or explicitly listed in externals or we fail. + if (path.isAbsolute(source) || source.startsWith(".")) { + return undefined; + } + + if (source.startsWith("df/") || source.startsWith("packages/")) { + const relPath = source.startsWith("df/") ? source.slice(3) : source; + + const bazelBin = findBazelBin(); + const candidate = bazelBin + ? path.resolve(bazelBin, relPath) + : path.resolve(process.cwd(), relPath); + + const esmCandidates = []; + // Generate ESM variants by walking up the directory tree + let dir = candidate; + let suffix = ""; + while (dir && dir !== "/" && dir !== ".") { + const esmDir = path.join(dir, "esm"); + if (fs.existsSync(esmDir) && fs.statSync(esmDir).isDirectory()) { + const esmPath = suffix ? path.join(esmDir, suffix) : esmDir; + esmCandidates.push(esmPath); + } + + const base = path.basename(dir); + if (base === "bin") { + break; + } + suffix = suffix ? path.join(base, suffix) : base; + dir = path.dirname(dir); + } + + const allCandidates = [...esmCandidates, candidate]; + + for (const candidate of allCandidates) { + if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) { + return candidate; + } + if (fs.existsSync(candidate + ".js") && fs.statSync(candidate + ".js").isFile()) { + return candidate + ".js"; + } + const indexCandidate = path.resolve(candidate, "index.js"); + if (fs.existsSync(indexCandidate) && fs.statSync(indexCandidate).isFile()) { + return indexCandidate; + } + } + } + + if (allowedImports.some((pattern) => pattern.test(source))) { + return null; + } if ( - allowedImports.some(pattern => pattern.test(source)) || externals(source) || externals(source.split("/")[0]) || - (allowNodeBuiltins && knownNodeBuiltins.some(pattern => pattern.test(source))) + externals(source) || + externals(source.split("/")[0]) || + (allowNodeBuiltins && knownNodeBuiltins.some((pattern) => pattern.test(source))) ) { - return null; + return false; } throw new Error("Must explicitly list import as an external: " + source); - } + }, }; }; @@ -53,7 +119,7 @@ export default { plugins: [ checkImports(importsToBundle), resolve({ - resolveOnly: importsToBundle - }) - ] + resolveOnly: importsToBundle, + }), + ], }; diff --git a/packages/rollup_bundle_dts.bzl b/packages/rollup_bundle_dts.bzl deleted file mode 100644 index f1501783c..000000000 --- a/packages/rollup_bundle_dts.bzl +++ /dev/null @@ -1,376 +0,0 @@ -load("@build_bazel_rules_nodejs//:providers.bzl", "DeclarationInfo", "JSEcmaScriptModuleInfo", "NodeContextInfo", "NpmPackageInfo", "node_modules_aspect", "run_node") -load("@build_bazel_rules_nodejs//internal/linker:link_node_modules.bzl", "module_mappings_aspect") - -# This is a fork of https://github.com/bazelbuild/rules_nodejs/blob/master/packages/rollup/src/rollup_bundle.bzl -# with a few small changes to support bundling .d.ts files. Instead of collecting es6 sources, it collects -# typescript declarations. It also changes the logic for resolving js inputs to support resolving .d.ts files instead. -# TODO: Move this upstream into rules_nodejs. - -_DOC = """Runs the Rollup.js CLI under Bazel. -See https://rollupjs.org/guide/en/#command-line-reference -Typical example: -```python -load("@npm_bazel_rollup//:index.bzl", "rollup_bundle") -rollup_bundle( - name = "bundle", - srcs = ["dependency.js"], - entry_point = "input.js", - config_file = "rollup.config.js", -) -``` -Note that the command-line options set by Bazel override what appears in the rollup config file. -This means that typically a single `rollup.config.js` can contain settings for your whole repo, -and multiple `rollup_bundle` rules can share the configuration. -Thus, setting options that Bazel controls will have no effect, e.g. -```javascript -module.exports = { - output: { file: 'this_is_ignored.js' }, -} -``` -You must determine ahead of time whether Rollup needs to produce a directory output. -This is the case if you have dynamic imports which cause code-splitting, or if you -provide multiple entry points. Use the `output_dir` attribute to specify that you want a -directory output. -Rollup's CLI has the same behavior, forcing you to pick `--output.file` or `--output.dir`. -To get multiple output formats, wrap the rule with a macro or list comprehension, e.g. -```python -[ - rollup_bundle( - name = "bundle.%s" % format, - entry_point = "foo.js", - format = format, - ) - for format in [ - "cjs", - "umd", - ] -] -``` -This will produce one output per requested format. -""" - -_ROLLUP_ATTRS = { - "srcs": attr.label_list( - doc = """Non-entry point JavaScript source files from the workspace. -You must not repeat file(s) passed to entry_point/entry_points. -""", - # Don't try to constrain the filenames, could be json, svg, whatever - allow_files = True, - ), - "args": attr.string_list( - doc = """Command line arguments to pass to rollup. Can be used to override config file settings. -These argument passed on the command line before all arguments that are always added by the -rule such as `--output.dir` or `--output.file`, `--format`, `--config` and `--preserveSymlinks` and -also those that are optionally added by the rule such as `--sourcemap`. -See rollup CLI docs https://rollupjs.org/guide/en/#command-line-flags for complete list of supported arguments.""", - default = [], - ), - "config_file": attr.label( - doc = """A rollup.config.js file -Passed to the --config -See https://rollupjs.org/guide/en/#configuration-files -If not set, a default basic Rollup config is used. -""", - allow_single_file = True, - default = "@npm_bazel_rollup//:rollup.config.js", - ), - "entry_point": attr.label( - doc = """The bundle's entry point (e.g. your main.js or app.js or index.js). -This is just a shortcut for the `entry_points` attribute with a single output chunk named the same as the rule. -For example, these are equivalent: -```python -rollup_bundle( - name = "bundle", - entry_point = "index.js", -) -``` -```python -rollup_bundle( - name = "bundle", - entry_points = { - "index.js": "bundle" - } -) -``` -If `rollup_bundle` is used on a `ts_library`, the `rollup_bundle` rule handles selecting the correct outputs from `ts_library`. -In this case, `entry_point` can be specified as the `.ts` file and `rollup_bundle` will handle the mapping to the `.mjs` output file. -For example: -```python -ts_library( - name = "foo", - srcs = [ - "foo.ts", - "index.ts", - ], -) -rollup_bundle( - name = "bundle", - deps = [ "foo" ], - entry_point = "index.ts", -) -``` -""", - allow_single_file = True, - ), - "entry_points": attr.label_keyed_string_dict( - doc = """The bundle's entry points (e.g. your main.js or app.js or index.js). -Passed to the [`--input` option](https://github.com/rollup/rollup/blob/master/docs/999-big-list-of-options.md#input) in Rollup. -Keys in this dictionary are labels pointing to .js entry point files. -Values are the name to be given to the corresponding output chunk. -Either this attribute or `entry_point` must be specified, but not both. -""", - allow_files = True, - ), - "format": attr.string( - doc = """"Specifies the format of the generated bundle. One of the following: -- `amd`: Asynchronous Module Definition, used with module loaders like RequireJS -- `cjs`: CommonJS, suitable for Node and other bundlers -- `esm`: Keep the bundle as an ES module file, suitable for other bundlers and inclusion as a `