From dda875f16bdc001aa43a4cef607fbc609170646a Mon Sep 17 00:00:00 2001 From: Igor Kholopov Date: Fri, 29 May 2026 16:27:18 +0200 Subject: [PATCH 01/11] js toolchain rewrite attempt to fix --- .bazelrc | 1 + BUILD | 79 +- MODULE.bazel | 54 +- MODULE.bazel.lock | 1074 +++- WORKSPACE | 29 - cli/BUILD | 70 +- cli/api/BUILD | 73 +- cli/api/commands/compile.ts | 2 +- cli/api/commands/jit/compiler.ts | 2 +- cli/api/utils/BUILD | 8 +- cli/index.ts | 2 +- cli/index_test_base.ts | 2 +- cli/vm/BUILD | 60 +- cli/vm/compile_loader.js | 7 + cli/vm/jit_loader.js | 2 + common/errors/BUILD | 9 +- common/flags/BUILD | 12 +- common/flags/testing/BUILD | 5 +- common/promises/BUILD | 13 +- common/promises/index.ts | 4 +- common/protos/BUILD | 25 +- common/strings/BUILD | 15 +- core/BUILD | 90 +- core/compilation_sql/BUILD | 2 +- examples/BUILD | 11 +- package.json | 36 +- packages/@dataform/BUILD | 8 + packages/@dataform/cli/BUILD | 54 +- packages/@dataform/cli/bin_loader.js | 2 + packages/@dataform/core/BUILD | 51 +- packages/@dataform/core/webpack.config.js | 25 +- packages/BUILD | 29 +- packages/index.bzl | 140 +- packages/rollup.config.js | 134 +- packages/rollup_bundle_dts.bzl | 376 -- packages/sample-extension/BUILD | 39 +- packages/sample-extension/webpack.config.js | 20 +- pnpm-lock.yaml | 4867 +++++++++++++++++ scripts/lint | 2 +- scripts/publish | 7 - scripts/run_integration_tests | 3 +- scripts/run_tests | 3 +- scripts/run_tests_on_cloudbuild | 4 - sqlx/BUILD | 26 +- testing/BUILD | 49 +- testing/index.bzl | 62 +- testing/index.ts | 64 +- testing/resolver-patch.js | 52 + tests/api/BUILD | 16 +- tests/api/projects/common_v2/BUILD | 7 +- .../api/projects/invalid_dataform_json/BUILD | 7 +- .../projects/never_finishes_compiling/BUILD | 7 +- tests/integration/BUILD | 8 +- tests/integration/bigquery_project/BUILD | 7 +- tools/BUILD | 18 +- tools/compile_protos.js | 93 + tools/gen-package-json/BUILD | 28 - tools/node_extension.bzl | 19 + tools/registry-tools/BUILD | 6 - tools/registry-tools/switch_registry.js | 38 - tools/ts_library.bzl | 102 +- tools/ts_proto_library.bzl | 183 +- tsconfig.esm.json | 8 + tsconfig.json | 1 + vscode/BUILD | 26 +- yarn.lock | 4687 ---------------- 66 files changed, 7119 insertions(+), 5846 deletions(-) delete mode 100644 WORKSPACE create mode 100644 cli/vm/compile_loader.js create mode 100644 packages/@dataform/cli/bin_loader.js delete mode 100644 packages/rollup_bundle_dts.bzl create mode 100644 pnpm-lock.yaml create mode 100644 testing/resolver-patch.js create mode 100644 tools/compile_protos.js delete mode 100644 tools/gen-package-json/BUILD create mode 100644 tools/node_extension.bzl delete mode 100644 tools/registry-tools/BUILD delete mode 100644 tools/registry-tools/switch_registry.js create mode 100644 tsconfig.esm.json delete mode 100644 yarn.lock 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/BUILD b/BUILD index b427536a2..bf72ec076 100644 --- a/BUILD +++ b/BUILD @@ -1,68 +1,61 @@ +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//:protobufjs-cli/package_json.bzl", "bin") +load("@npm//:tslint/package_json.bzl", tslint_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( +bin.pbjs_binary( name = "pbjs", - data = PROTOBUF_DEPS, - entry_point = "@npm//:node_modules/protobufjs-cli/bin/pbjs", + chdir = ".", + visibility = ["//visibility:public"], ) -nodejs_binary( +bin.pbts_binary( name = "pbts", - data = PROTOBUF_DEPS, - entry_point = "@npm//:node_modules/protobufjs-cli/bin/pbts", + chdir = ".", + visibility = ["//visibility:public"], ) -nodejs_binary( +tslint_bin.tslint_binary( name = "tslint", data = [ - "@npm//tslint", + "//:node_modules/tslint-config-prettier", + "//:node_modules/tslint-config-security", ], - entry_point = "@npm//:node_modules/tslint/bin/tslint", - templated_args = ["--node_options=--preserve-symlinks"], + visibility = ["//visibility:public"], ) -load("@bazel_gazelle//:def.bzl", "gazelle") - # 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 859a852b6..f58d968bf 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -3,17 +3,54 @@ module( version = "1.0.0", ) -# 1. bazel_skylib +# 1. 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") + +# 2. 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", +) + +# 3. 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_repo(npm, "npm") + +pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm") +use_repo(pnpm, "pnpm") + +# 4. bazel_skylib bazel_dep(name = "bazel_skylib", version = "1.7.1") -# 2. com_google_protobuf +# 5. com_google_protobuf bazel_dep(name = "protobuf", version = "27.3", repo_name = "com_google_protobuf") - -# 4. rules_go +# 6. rules_go bazel_dep(name = "rules_go", version = "0.49.0", repo_name = "io_bazel_rules_go") -# 5. bazel_gazelle +# 7. bazel_gazelle bazel_dep(name = "gazelle", version = "0.37.0", repo_name = "bazel_gazelle") # Go dependencies via Gazelle's go_deps extension @@ -40,6 +77,11 @@ use_repo( "org_golang_x_text", ) -# 6. Custom gcloud SDK extension +# 8. Custom gcloud SDK extension gcloud_sdk_ext = use_extension("//tools/gcloud:extensions.bzl", "gcloud_sdk_extension") use_repo(gcloud_sdk_ext, "gcloud_sdk") + +# 9. 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") 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 2eebdabb1..6d409ea48 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"]) @@ -21,26 +19,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", @@ -49,11 +41,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", ], ) @@ -68,11 +60,21 @@ ts_test_suite( "util_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", "@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", @@ -81,15 +83,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 111ff2a89..d24e5cf38 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"]) @@ -14,7 +13,28 @@ ts_library( ], ), deps = [ + "//:node_modules/@google-cloud/bigquery", + "//: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", + "//cli/vm:compile_loader", "//common/errors", "//common/flags", "//common/promises", @@ -23,35 +43,7 @@ ts_library( "//core", "//core/compilation_sql", "//protos:ts", - "//cli/vm:compile_loader", "//sqlx:lexer", - "//cli/vm:vm", - "@npm//@google-cloud/bigquery", - "@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", ], ) @@ -64,26 +56,23 @@ ts_test_suite( "utils_test.ts", ], data = [ - ":node_modules", "//packages/@dataform/core:package_tar", "//test_credentials:bigquery.json", - "@nodejs//:node", - "@nodejs//:npm", ] + glob(["goldens/**"]), deps = [ ":api", + "//:node_modules/@google-cloud/bigquery", + "//: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", "//core", "//protos:ts", "//testing", - "@npm//@google-cloud/bigquery", - "@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", ], ) diff --git a/cli/api/commands/compile.ts b/cli/api/commands/compile.ts index 38d32592a..ccdf26369 100644 --- a/cli/api/commands/compile.ts +++ b/cli/api/commands/compile.ts @@ -102,7 +102,7 @@ export async function compile( export class CompileChildProcess extends BaseWorker { constructor() { - super(path.resolve(__dirname, "../../vm/compile_loader")); + super(path.resolve(__dirname, "../../vm/compile")); } public async compile(compileConfig: dataform.ICompileConfig) { diff --git a/cli/api/commands/jit/compiler.ts b/cli/api/commands/jit/compiler.ts index 651da96f8..1c7bb5d14 100644 --- a/cli/api/commands/jit/compiler.ts +++ b/cli/api/commands/jit/compiler.ts @@ -40,7 +40,7 @@ export class JitCompileChildProcess extends BaseWorker< } constructor() { - super(path.resolve(__dirname, "../../../vm/jit_loader")); + super(path.resolve(__dirname, "../../../vm/jit_worker")); } private async run( 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/index.ts b/cli/index.ts index 452d71f5f..47bda6d7f 100644 --- a/cli/index.ts +++ b/cli/index.ts @@ -495,7 +495,7 @@ export function runCli() { process.exit(1); }); while (watching) { - await new Promise((resolve, reject) => setTimeout(() => resolve(), 100)); + await new Promise((resolve, reject) => setTimeout(() => resolve(), 100)); } } }, diff --git a/cli/index_test_base.ts b/cli/index_test_base.ts index 564d7f435..5b3720336 100644 --- a/cli/index_test_base.ts +++ b/cli/index_test_base.ts @@ -14,4 +14,4 @@ if (!fs.existsSync(path.resolve(runfilesDir, "df"))) { export const CREDENTIALS_PATH = path.resolve(runfilesDir, workspaceName, "test_credentials/bigquery.json"); -export const cliEntryPointPath = "cli/node_modules/@dataform/cli/bundle.js"; +export const cliEntryPointPath = path.resolve(runfilesDir, workspaceName, "packages/@dataform/cli/bundle.js"); diff --git a/cli/vm/BUILD b/cli/vm/BUILD index 4adc5f391..4ecb25141 100644 --- a/cli/vm/BUILD +++ b/cli/vm/BUILD @@ -1,7 +1,8 @@ -package(default_visibility = ["//visibility:public"]) - +load("@aspect_rules_js//js:defs.bzl", "js_binary") load("//tools:ts_library.bzl", "ts_library") +package(default_visibility = ["//visibility:public"]) + ts_library( name = "vm", srcs = [ @@ -9,61 +10,34 @@ 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( +js_binary( 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 -# and then execute these scripts instead, so module resulution works. - -nodejs_binary( - name = "compile", + chdir = "../..", data = [ ":vm", - "@npm//source-map-support", - ], - entry_point = ":compile.ts", - templated_args = [ - "--node_options=--require=source-map-support/register", - "--bazel_patch_module_resolver", + "//:node_modules/source-map-support", ], + entry_point = "compile.js", ) -nodejs_binary( +js_binary( name = "jit_worker_bin", + chdir = "../..", data = [ ":vm", - "@npm//source-map-support", - ], - entry_point = ":jit_worker.ts", - templated_args = [ - "--node_options=--require=source-map-support/register", - "--bazel_patch_module_resolver", + "//:node_modules/source-map-support", ], + entry_point = "jit_worker.js", ) diff --git a/cli/vm/compile_loader.js b/cli/vm/compile_loader.js new file mode 100644 index 000000000..d08fbecfa --- /dev/null +++ b/cli/vm/compile_loader.js @@ -0,0 +1,7 @@ +require('../../testing/resolver-patch.js'); + +const compileModule = require('./compile.js'); +if (process.send) { + process.send({ type: "worker_booted" }); +} +compileModule.listenForCompileRequest(); diff --git a/cli/vm/jit_loader.js b/cli/vm/jit_loader.js index cb325cee9..876a0b20f 100644 --- a/cli/vm/jit_loader.js +++ b/cli/vm/jit_loader.js @@ -1,5 +1,7 @@ 'use strict'; +require('../../testing/resolver-patch.js'); + if (require.main === module) { var entryPointPath = 'df/cli/vm/jit_worker.js'; var mainScript = process.argv[1] = entryPointPath; diff --git a/common/errors/BUILD b/common/errors/BUILD index b806837f0..bef537262 100644 --- a/common/errors/BUILD +++ b/common/errors/BUILD @@ -10,7 +10,6 @@ ts_library( exclude = ["*.spec.ts"], ), deps = [ - "//:modules-fix", ], ) @@ -18,7 +17,7 @@ ts_test_suite( name = "tests", srcs = glob(["*.spec.ts"]), data = [ - "@npm//source-map-support", + "//:node_modules/source-map-support", ], templated_args = [ "--node_options=--require=source-map-support/register", @@ -26,9 +25,9 @@ ts_test_suite( ], 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 3d6514c38..94d718a3a 100644 --- a/common/flags/BUILD +++ b/common/flags/BUILD @@ -1,21 +1,19 @@ -package(default_visibility = ["//visibility:public"]) - +load("//testing:build_test.bzl", "build_test") load("//tools:ts_library.bzl", "ts_library") +package(default_visibility = ["//visibility:public"]) + ts_library( name = "flags", srcs = glob( ["*.ts"], ), deps = [ - "//:modules-fix", - "@npm//@types/long", - "@npm//@types/node", + "//:node_modules/@types/long", + "//:node_modules/@types/node", ], ) -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..98ad07d0d 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,8 +10,7 @@ ts_library( exclude = ["*.spec.ts"], ), deps = [ - "//:modules-fix", - "@npm//@types/node", + "//:node_modules/@types/node", ], ) @@ -19,7 +18,7 @@ ts_test_suite( name = "tests", srcs = glob(["*.spec.ts"]), data = [ - "@npm//source-map-support", + "//:node_modules/source-map-support", ], templated_args = [ "--node_options=--require=source-map-support/register", @@ -27,9 +26,9 @@ ts_test_suite( ], 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 7ba7bed27..120e743ee 100644 --- a/common/promises/index.ts +++ b/common/promises/index.ts @@ -28,7 +28,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( @@ -41,7 +41,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 ffb46ca4d..5327c1bf4 100644 --- a/common/protos/BUILD +++ b/common/protos/BUILD @@ -1,19 +1,22 @@ -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/protobufjs", "//common/strings", "//protos:ts", - "@npm//protobufjs", ], ) @@ -21,7 +24,7 @@ ts_test_suite( name = "tests", srcs = glob(["*_test.ts"]), data = [ - "@npm//source-map-support", + "//:node_modules/source-map-support", ], templated_args = [ "--node_options=--require=source-map-support/register", @@ -29,16 +32,14 @@ ts_test_suite( ], 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..f5d5b8617 100644 --- a/common/strings/BUILD +++ b/common/strings/BUILD @@ -10,9 +10,8 @@ ts_library( exclude = ["*.spec.ts"], ), deps = [ - "//:modules-fix", - "@npm//@types/long", - "@npm//long", + "//:node_modules/@types/long", + "//:node_modules/long", ], ) @@ -20,7 +19,7 @@ ts_test_suite( name = "tests", srcs = glob(["*.spec.ts"]), data = [ - "@npm//source-map-support", + "//:node_modules/source-map-support", ], templated_args = [ "--node_options=--require=source-map-support/register", @@ -28,10 +27,10 @@ ts_test_suite( ], 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/core/BUILD b/core/BUILD index db9219e8b..2f133a184 100644 --- a/core/BUILD +++ b/core/BUILD @@ -15,50 +15,52 @@ expand_template( template = "version.ts.tmpl", ) +CORE_SRCS = [ + "actions/assertion.ts", + "actions/data_preparation.ts", + "actions/declaration.ts", + "actions/incremental_table.ts", + "actions/index.ts", + "actions/notebook.ts", + "actions/operation.ts", + "actions/table.ts", + "actions/test.ts", + "actions/view.ts", + "column_descriptors.ts", + "compilers.ts", + "contextables.ts", + "extension.ts", + "index.ts", + "jit_compiler.ts", + "jit_context.ts", + "main.ts", + "path.ts", + "session.ts", + "targets.ts", + "utils.ts", + "workflow_settings.ts", + "version.ts", +] + ts_library( name = "core", - srcs = [ - "actions/assertion.ts", - "actions/data_preparation.ts", - "actions/declaration.ts", - "actions/incremental_table.ts", - "actions/index.ts", - "actions/notebook.ts", - "actions/operation.ts", - "actions/table.ts", - "actions/test.ts", - "actions/view.ts", - "column_descriptors.ts", - "compilers.ts", - "contextables.ts", - "extension.ts", - "index.ts", - "jit_compiler.ts", - "jit_context.ts", - "main.ts", - "path.ts", - "session.ts", - "targets.ts", - "utils.ts", - "workflow_settings.ts", - ":version.ts", - ], + srcs = [f if f != "version.ts" else ":version.ts" for f in CORE_SRCS], 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", ], ) @@ -87,19 +89,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 95e336821..f69a500d2 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -24,18 +24,17 @@ ts_test_suite( ":node_modules", "//packages/@dataform/core:package_tar", "//test_credentials:bigquery.json", - "@nodejs//:node", ], deps = [ + "//:node_modules/@types/chai", + "//:node_modules/@types/fs-extra", + "//:node_modules/@types/node", + "//:node_modules/chai", + "//:node_modules/fs-extra", "//cli/api", "//common/protos", "//protos:ts", "//testing", - "@npm//@types/chai", - "@npm//@types/fs-extra", - "@npm//@types/node", - "@npm//chai", - "@npm//fs-extra", ], ) diff --git a/package.json b/package.json index f102c21c4..b91f2e2d7 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,8 @@ "@google-cloud/storage": "^7.19.0", "@google-cloud/bigquery": "~8.3.0", "@rollup/plugin-node-resolve": "^7.1.3", + "@rollup/plugin-commonjs": "^17.1.0", + "@rollup/plugin-json": "^5.0.0", "@types/chai": "^4.1.7", "@types/diff": "^4.0.2", "@types/es6-shim": "^0.31.37", @@ -85,22 +87,22 @@ "yargs": "^16.2.0" }, "resolutions": { - "**/object-path": "^0.11.5", - "**/http-proxy": "^1.18.1", - "**/serialize-javascript": "^3.1.0", - "**/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": "^12.3.2", - "**/wrap-ansi": "7.0.0", - "**/string-width": "4.1.0" + "object-path": "^0.11.5", + "http-proxy": "^1.18.1", + "serialize-javascript": "^3.1.0", + "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": "^12.3.2", + "wrap-ansi": "7.0.0", + "string-width": "4.1.0" } } 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 7a1d7085c..e61a92c9c 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"]), @@ -14,17 +21,16 @@ ts_library( ], ) -nodejs_binary( +js_binary( name = "bin", + chdir = "../../..", 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", + "//:node_modules/source-map-support", ], + entry_point = "bin_loader.js", ) externals = [ @@ -57,8 +63,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", @@ -66,27 +72,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..dd1f8adf4 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") 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,13 @@ 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_bundle_dts( name = "bundle.d", - entry_point = "index.ts", + entry_point = "index.d.ts", externals = [ "protobufjs", "tarjan-graph", @@ -114,8 +109,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..35903ca98 100644 --- a/packages/@dataform/core/webpack.config.js +++ b/packages/@dataform/core/webpack.config.js @@ -4,36 +4,35 @@ 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")], + mode: argv.mode || "production", + target: "node", + devtool: false, output: { - libraryTarget: "commonjs-module", + libraryTarget: "commonjs-module" }, optimization: { - minimize: true + minimize: true, + moduleIds: "deterministic" }, stats: { warnings: true }, resolve: { - extensions: [".ts", ".js", ".json"], + extensions: [".js", ".ts", ".json"], alias: { - df: path.resolve(runfilesDir, workspaceName) + df: binDir } }, plugins: [ new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }) - ], + ] }; return config; }; diff --git a/packages/BUILD b/packages/BUILD index 97e326b6f..8287b4c19 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,17 @@ 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", + "//:node_modules/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..c976688c8 100644 --- a/packages/index.bzl +++ b/packages/index.bzl @@ -1,6 +1,22 @@ -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//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 +24,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 +43,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 +123,18 @@ 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 ) diff --git a/packages/rollup.config.js b/packages/rollup.config.js index 3ac33cdec..6b3b1eb41 100644 --- a/packages/rollup.config.js +++ b/packages/rollup.config.js @@ -1,15 +1,15 @@ import resolve from "@rollup/plugin-node-resolve"; +import * as path from "path"; +import * as fs from "fs"; function convertToRegex(pattern) { if (pattern instanceof RegExp) { return pattern; } - // If it's a string, turn it into a regex, by escaping any regex characters in the string. const normalized = pattern.replace(/[\\^$*+?.()|[\]{}]/g, "\\$&"); return new RegExp(`^${normalized}$`); } -// Add new node built ins here if they are used. const knownNodeBuiltins = [ "path", "fs", @@ -27,8 +27,6 @@ const importsToBundle = ["df", /df\/.*$/, /^bazel\-.*$/]; 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,9 +35,71 @@ const checkImports = imports => { externals = options.external || (() => false); }, resolveId(source) { - // Either this is an internal import, or explicitly listed in externals or we fail. + if (source.startsWith("\u0000") || source.includes("\u0000")) { + return undefined; + } + + if (path.isAbsolute(source) || source.startsWith("/")) { + return undefined; + } + + if (source.startsWith("df/") || source.startsWith("packages/")) { + const relPath = source.startsWith("df/") ? source.slice(3) : source; + + // Compute three possible candidates: + const candidates = [ + path.resolve(process.cwd(), relPath), + path.resolve(process.cwd(), "../../..", "bazel-out", "k8-fastbuild-py2", "bin", relPath), + path.resolve(process.cwd(), "bazel-out", "k8-fastbuild-py2", "bin", relPath) + ]; + + const esmCandidates = []; + const normalCandidates = []; + for (const candidate of candidates) { + normalCandidates.push(candidate); + // 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" || base === "migration" || base === "dataform_migrated") { + break; + } + suffix = suffix ? path.join(base, suffix) : base; + dir = path.dirname(dir); + } + } + + const allCandidates = [...esmCandidates, ...normalCandidates]; + + 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 (source.startsWith(".") || source.startsWith("bazel-out/")) { + return undefined; + } + if ( - allowedImports.some(pattern => pattern.test(source)) || externals(source) || externals(source.split("/")[0]) || + allowedImports.some(pattern => pattern.test(source)) || + externals(source) || + externals(source.split("/")[0]) || (allowNodeBuiltins && knownNodeBuiltins.some(pattern => pattern.test(source))) ) { return null; @@ -49,11 +109,71 @@ const checkImports = imports => { }; }; +const resolverPatch = `(function() { +const Module = require('module'); +const path = require('path'); + +let runfilesDir = process.env.RUNFILES; +if (!runfilesDir) { + const mainFilename = require.main ? require.main.filename : __filename; + const runfilesIndex = mainFilename.indexOf('.runfiles'); + if (runfilesIndex !== -1) { + runfilesDir = mainFilename.substring(0, runfilesIndex + 9); + } +} +if (runfilesDir) { + runfilesDir = path.resolve(runfilesDir); + const originalResolveFilename = Module._resolveFilename; + Module._resolveFilename = function (request, parent, isMain, options) { + if (request === 'df' || request.startsWith('df/')) { + const relativePath = request === 'df' ? '' : request.substring(3); + const resolvedPath = path.join(runfilesDir, '_main', relativePath); + try { + return originalResolveFilename(resolvedPath, parent, isMain, options); + } catch (e) { + try { + return originalResolveFilename(path.join(runfilesDir, relativePath), parent, isMain, options); + } catch (e2) { + // ignore + } + throw e; + } + } + try { + return originalResolveFilename(request, parent, isMain, options); + } catch (err) { + if (!request.startsWith('.') && !path.isAbsolute(request)) { + try { + return originalResolveFilename(path.join(runfilesDir, '_main', 'node_modules', request), parent, isMain, options); + } catch (err2) { + try { + return originalResolveFilename(path.join(runfilesDir, 'node_modules', request), parent, isMain, options); + } catch (err3) { + // ignore + } + } + } + throw err; + } + }; +} +})();`; + export default { + external: id => { + if (id.startsWith("df/") || id === "df") return false; + if (id.startsWith("bazel-")) return false; + if (id.startsWith(".") || id.startsWith("/") || require("path").isAbsolute(id)) return false; + if (id.includes("commonjsHelpers")) return false; + return true; + }, plugins: [ checkImports(importsToBundle), resolve({ resolveOnly: importsToBundle }) - ] + ], + output: { + banner: resolverPatch, + } }; 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 `