Commit Graph

5 Commits

Author SHA1 Message Date
James Kuszmaul 28e858c855
[TS/Bazel] Minor improvements to typescript.bzl (#7300)
* Move reflection_ts_fbs into a separate directory (#7342)

Right now, reflection_ts_fbs target is in reflection/BUILD.bazel.

This is not ideal because reflection:reflection_fbs_schema is referenced
from :flatc in the root. Thus, for any Bazel projects that want to
include flatbuffers, they need to include npm / yarn_install and nodejs
support all because reflection/BUILD.bazel loads typescript.bzl and that
requires all TypeScript things.

This PR separated that target into a different subdirectory, freeing
root BUILD.bazel from that dependency.

* Minor improvements to typescript.bzl

* Uses @...// dependencies so that flatbuffers can actually
  be used as an external repo (had forgotten to upstream this earlier).
* Allows using flatbuffer_ts_library to generate reflection schemas
  in the same way that flatbuffer_cc_library does (but default it
  to off to avoid behavioral changes).
* Pass through a package_name attribute to flatbuffer_ts_library to
  allow non-relative imports of generated typescript code.

Co-authored-by: Liu Liu <i@liuliu.me>
2022-08-05 22:04:05 -07:00
Derek Bailey b4647beb8f
Revert "Move reflection_ts_fbs into a separate directory (#7342)" (#7349)
This reverts commit 090caa2809.
2022-06-14 20:58:00 -07:00
Liu Liu 090caa2809
Move reflection_ts_fbs into a separate directory (#7342)
Right now, reflection_ts_fbs target is in reflection/BUILD.bazel.

This is not ideal because reflection:reflection_fbs_schema is referenced
from :flatc in the root. Thus, for any Bazel projects that want to
include flatbuffers, they need to include npm / yarn_install and nodejs
support all because reflection/BUILD.bazel loads typescript.bzl and that
requires all TypeScript things.

This PR separated that target into a different subdirectory, freeing
root BUILD.bazel from that dependency.
2022-06-13 09:36:52 -04:00
James Kuszmaul eeb49c2757
Move flatbuffer_ts_library to typescript.bzl (#7183)
This makes it so that users of flatbuffer_cc_library don't need to have
rules_nodejs available in their WORKSPACE, addressing #7179.
2022-03-22 21:41:39 -07:00
James Kuszmaul e5f331db99
[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...
2022-03-10 10:08:13 -08:00