Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to rulesjs and pnpm #1815

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update to bazel 7, swap to proto_ts
  • Loading branch information
Ekrekr committed Aug 21, 2024
commit 5f11487f5f1f2d14acc8d1f4425e57004a6ada17
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.4.0
7.2.0
39 changes: 0 additions & 39 deletions BUILD
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
load("@aspect_rules_js//js:defs.bzl", "js_binary", "js_library")
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@npm//:defs.bzl", "npm_link_all_packages")
load("@aspect_rules_ts//ts:defs.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")

package(default_visibility = ["//visibility:public"])

Expand All @@ -15,38 +13,6 @@ exports_files([
"jsconfig.json"
])

PROTOBUF_DEPS = [
"//:node_modules/protobufjs",
"//:node_modules/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
"//:node_modules/semver",
"//:node_modules/chalk",
"//:node_modules/glob",
"//:node_modules/jsdoc",
"//:node_modules/minimist",
"//:node_modules/tmp",
"//:node_modules/uglify-js",
"//:node_modules/uglify-es",
"//:node_modules/espree",
"//:node_modules/escodegen",
"//:node_modules/estraverse",
]

nodejs_binary(
name = "pbjs",
data = PROTOBUF_DEPS,
entry_point = "//:node_modules/protobufjs-cli/bin/pbjs",
)

nodejs_binary(
name = "pbts",
data = PROTOBUF_DEPS,
entry_point = "//:node_modules/protobufjs-cli/bin/pbts",
)

js_library(
name = "package_json",
srcs = ["package.json"],
Expand All @@ -64,8 +30,3 @@ js_binary(
node_options = ["--preserve-symlinks"],
# install_source_map_support = False,
)

# gazelle:prefix github.com/dataform-co/dataform
# gazelle:proto package
# gazelle:proto_group go_package
gazelle(name = "gazelle")
38 changes: 38 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module(
name = "df",
version = "3.0.2", # TODO: update automatically.
repo_name = "dataform",
)

####### rules_js #########

bazel_dep(name = "aspect_rules_js", version = "2.0.0")

npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True)

npm.npm_translate_lock(
name = "npm",
pnpm_lock = "//:pnpm-lock.yaml",
verify_node_modules_ignored = "//:.bazelignore",
npmrc = "@@//:.npmrc",
)

use_repo(npm, "npm")

pnpm = use_extension("@aspect_rules_js//npm:extensions.bzl", "pnpm")

use_repo(pnpm, "pnpm")

############## rules_ts ###############

bazel_dep(name = "aspect_rules_ts", version = "3.0.0")

rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext", dev_dependency = True)

rules_ts_ext.deps(
ts_version_from = "//:package.json",
)

use_repo(rules_ts_ext, "npm_typescript")

##################################
866 changes: 866 additions & 0 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

175 changes: 0 additions & 175 deletions WORKSPACE

This file was deleted.

5 changes: 2 additions & 3 deletions cli/vm/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package(default_visibility = ["//visibility:public"])

load("//tools:ts_library.bzl", "ts_library")
load("@aspect_rules_js//js:defs.bzl", "js_binary")

ts_library(
name = "vm",
Expand Down Expand Up @@ -30,15 +31,13 @@ ts_library(
],
)

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(
js_binary(
name = "compile",
data = [
":vm",
Expand Down
2 changes: 1 addition & 1 deletion common/errors/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ ts_test_suite(
"//:node_modules/@types/chai",
"//:node_modules/@types/node",
"//:node_modules/chai",
"@df//testing",
"//testing",
],
)
2 changes: 1 addition & 1 deletion common/promises/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ts_test_suite(
],
deps = [
":promises",
"@df//testing",
"//testing",
"//:node_modules/@types/chai",
"//:node_modules/@types/node",
"//:node_modules/chai",
Expand Down
16 changes: 6 additions & 10 deletions common/strings/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,24 @@ package(default_visibility = ["//visibility:public"])

ts_library(
name = "strings",
srcs = glob(
["*.ts"],
exclude = ["*.spec.ts"],
),
srcs = [
"index.ts",
"stringifier.ts",
],
deps = [
"//:node_modules/@types/long",
"//:node_modules/long",
],
)

ts_test_suite(
srcs = glob(["*.spec.ts"]),
srcs = ["stringifier_test.ts"],
data = [
"//:node_modules/source-map-support",
],
templated_args = [
"--node_options=--require=source-map-support/register",
"--bazel_patch_module_resolver",
],
deps = [
":strings",
"@df//testing",
"//testing",
"//:node_modules/@types/chai",
"//:node_modules/@types/long",
"//:node_modules/@types/node",
Expand Down
6 changes: 3 additions & 3 deletions core/compilation_sql/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { dataform } from "#df/protos/ts";
import * as dataform from "#df/protos/core_pb";

export class CompilationSql {
constructor(
private readonly project: dataform.IProjectConfig,
private readonly project: dataform.ProjectConfig,
private readonly dataformCoreVersion: string
) {}

public resolveTarget(target: dataform.ITarget) {
public resolveTarget(target: dataform.Target) {
const database = target.database || this.project.defaultDatabase;
if (!database) {
return `\`${target.schema || this.project.defaultSchema}.${target.name}\``;
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"@blueprintjs/core": "^3.22.3",
"@blueprintjs/icons": "^3.13.0",
"@blueprintjs/select": "^3.8.0",
"@bufbuild/protobuf": "^2.0.0",
"@bufbuild/protoc-gen-es": "^2.0.0",
"@connectrpc/protoc-gen-connect-es": "^1.4.0",
"@google-cloud/bigquery": "^5.6.0",
"@google-cloud/storage": "^5.8.2",
"@mapbox/rehype-prism": "^0.6.0",
Expand All @@ -25,6 +28,7 @@
"@types/glob": "^7.1.1",
"@types/google-protobuf": "^3.2.7",
"@types/js-beautify": "^1.8.1",
"@types/js-yaml": "^4.0.9",
"@types/json-stable-stringify": "^1.0.32",
"@types/lodash": "^4.14.149",
"@types/long": "^4.0.0",
Expand Down
Loading