* 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>
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.
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...