diff options
author | James Kuszmaul <jkuszmaul@users.noreply.github.com> | 2022-03-10 10:08:13 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-10 10:08:13 -0800 |
commit | e5f331db998a808f78cf5a4880e6f5d0a321c4d0 (patch) | |
tree | 71b2ba71b1ca02320db75e931ec99cc83e7b50a5 /ts | |
parent | 2f84c60385602a1052fb5713aa623541d8a895b5 (diff) | |
download | flatbuffers-e5f331db998a808f78cf5a4880e6f5d0a321c4d0.tar.gz flatbuffers-e5f331db998a808f78cf5a4880e6f5d0a321c4d0.tar.bz2 flatbuffers-e5f331db998a808f78cf5a4880e6f5d0a321c4d0.zip |
[TS] Add single-file ts codegen & bazel rule for typescript (#7161)
The headline here is adding a flatbuffer_ts_library rule for generating
typescript code in bazel. This entails some non-trivial other changes,
but ideally none are user-visible.
In particular:
* Added a --ts-flat-file flag that generates a single *_generated.ts
file instead of separate files for each typescript type. This makes
bazel much happier.
* Import the bazel rules_nodejs stuff needed to support building
typescript in bazel
* Move flatbuffers.ts to index.ts because I wasn't sure how to make
bazel comprehend the "main" attribute of the package.json. Happy
to take another stab at figuring that out if really needed.
* Fix another couple keyword escaping spots in typescript...
Diffstat (limited to 'ts')
-rw-r--r-- | ts/BUILD.bazel | 39 | ||||
-rw-r--r-- | ts/index.ts (renamed from ts/flatbuffers.ts) | 0 |
2 files changed, 39 insertions, 0 deletions
diff --git a/ts/BUILD.bazel b/ts/BUILD.bazel new file mode 100644 index 00000000..605329ed --- /dev/null +++ b/ts/BUILD.bazel @@ -0,0 +1,39 @@ +load("@npm//@bazel/typescript:index.bzl", "ts_project") +load("@build_bazel_rules_nodejs//:index.bzl", "js_library") + +ts_project( + name = "flatbuffers_ts", + srcs = [ + "builder.ts", + "byte-buffer.ts", + "constants.ts", + "encoding.ts", + "index.ts", + "types.ts", + "utils.ts", + ], + declaration = True, + tsconfig = { + "compilerOptions": { + "module": "commonjs", + "declaration": True, + "moduleResolution": "node", + "lib": [ + "ES2015", + "ES2020.BigInt", + "DOM", + ], + "types": ["node"], + "strict": True, + }, + }, + visibility = ["//visibility:public"], + deps = ["@npm//@types/node"], +) + +js_library( + name = "flatbuffers", + package_name = "flatbuffers", + visibility = ["//visibility:public"], + deps = [":flatbuffers_ts"], +) diff --git a/ts/flatbuffers.ts b/ts/index.ts index 19f44e6f..19f44e6f 100644 --- a/ts/flatbuffers.ts +++ b/ts/index.ts |