Merge branch 'master' into master

This commit is contained in:
Derek Bailey
2023-04-28 11:22:26 -07:00
committed by GitHub
108 changed files with 3059 additions and 2240 deletions

View File

@@ -1,5 +1,23 @@
load("@npm//@bazel/typescript:index.bzl", "ts_project")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
load("@aspect_rules_js//npm:defs.bzl", "npm_package")
filegroup(
name = "distribution",
srcs = [
"BUILD.bazel",
"compile_flat_file.sh",
] + glob([
"*.ts",
]),
visibility = ["//visibility:public"],
)
# Add an index to emulate the top-level package.json's "main" entry.
genrule(
name = "generate_index.ts",
outs = ["index.ts"],
cmd = """echo "export * from './flatbuffers.js'" > $(OUTS)""",
)
ts_project(
name = "flatbuffers_ts",
@@ -11,6 +29,7 @@ ts_project(
"flatbuffers.ts",
"types.ts",
"utils.ts",
":index.ts",
],
declaration = True,
tsconfig = {
@@ -28,14 +47,19 @@ ts_project(
},
},
visibility = ["//visibility:public"],
deps = ["@npm//@types/node"],
deps = [
# Because the main repository instantiates the @npm repository, we need
# to depend on the main repository's node import.
"@//:node_modules/@types/node",
],
)
js_library(
npm_package(
name = "flatbuffers",
package_name = "flatbuffers",
srcs = [":flatbuffers_ts"],
include_external_repositories = ["*"],
package = "flatbuffers",
visibility = ["//visibility:public"],
deps = [":flatbuffers_ts"],
)
sh_binary(
@@ -44,7 +68,6 @@ sh_binary(
data = [
"@com_github_google_flatbuffers//:flatc",
"@nodejs_linux_amd64//:node_bin",
"@npm//esbuild/bin:esbuild",
],
# We just depend directly on the linux amd64 nodejs binary, so only support
# running this script on amd64 for now.

View File

@@ -14,10 +14,9 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v2 ---
set -e
set -eu
runfiles_export_envvars
FLATC=$(rlocation com_github_google_flatbuffers/flatc)
ESBUILD=$(rlocation npm/node_modules/esbuild/bin/esbuild)
TS_FILE=$(${FLATC} $@ | grep "Entry point.*generated" | grep -o "bazel-out.*ts")
export PATH=$(rlocation nodejs_linux_amd64/bin/nodejs/bin)
${ESBUILD} ${TS_FILE} --format=cjs --bundle --outfile="${OUTPUT_FILE}" --external:flatbuffers --log-level=warning
export PATH="$(rlocation nodejs_linux_amd64/bin/nodejs/bin):${PATH}"
${ESBUILD_BIN} ${TS_FILE} --format=cjs --bundle --outfile="${OUTPUT_FILE}" --external:flatbuffers --log-level=warning