flatbuffers/ts
Philipp Schrader 7106d86685
Remove npm/rules_js dependency for C++ only use cases (#7990)
When flatbuffers is being used from a project that has no use for
JavaScript, users encounter an error similar to the following:

    ERROR: Skipping '@com_github_google_flatbuffers//:flatbuffers': error loading package '@com_github_google_flatbuffers//': Unable to find package for @npm//:defs.bzl: The repository '@npm' could not be resolved: Repository '@npm' is not defined.
    WARNING: Target pattern parsing failed.
    ERROR: error loading package '@com_github_google_flatbuffers//': Unable to find package for @npm//:defs.bzl: The repository '@npm' could not be resolved: Repository '@npm' is not defined.
    INFO: Elapsed time: 0.023s
    INFO: 0 processes.
    FAILED: Build did NOT complete successfully (0 packages loaded)
        currently loading: @com_github_google_flatbuffers//

That's not ideal. Users that only care about C++ for example
shouldn't be forced to deal with rules_js and friends.

This patch attempts to fix that by moving the rules_js-specific things
into the `ts` and `tests/ts` directories. This should allow
non-JavaScript projects to ignore rules_js and friends completely.

Here I basically followed the `rules_foo` example from rules_js:
https://github.com/aspect-build/rules_js/tree/main/e2e/rules_foo

The idea is that flatbuffers has its own npm dependencies regardless
of what other projects may have. This means we should not force the
user to import flatbuffers's npm dependencies. The new
`ts/repositories.bzl` file is used by dependents to import
flatbuffers's dependencies. They can still import their own
dependencies. This cleanup allowed me to move all
JavaScript-specific stuff from the top-level directory into
subdirectories.

There should be no changes in this patch in terms of functionality.
It's just a refactor of the rules_js call sites. Users will have to
add a call to the function in `ts/repositories.bzl` in their own
`WORKSPACE` file. They can use
`tests/ts/bazel_repository_test/WORKSPACE` as an example.

Co-authored-by: Derek Bailey <derekbailey@google.com>
2024-04-18 05:06:06 +00:00
..
flexbuffers Fix FlexBuffers JS/TS bug https://github.com/google/flatbuffers/issues/6934 (#7434) 2022-08-13 18:29:28 -07:00
BUILD.bazel Remove npm/rules_js dependency for C++ only use cases (#7990) 2024-04-18 05:06:06 +00:00
builder.ts [TS/JS] Create byte vectors (#8185) 2023-12-19 06:42:21 +00:00
byte-buffer.ts [TS] Make strict compliant and improve typings (#7549) 2022-09-29 15:03:35 -07:00
compile_flat_file.sh Migrate from rules_nodejs to rules_js/rules_ts (take 2) (#7928) 2023-05-03 11:48:15 -07:00
constants.ts [JS/TS] Modernize TypeScript / JavaScript flatbuffers support (#6095) 2020-09-17 12:21:14 -07:00
encoding.ts [JS/TS] Modernize TypeScript / JavaScript flatbuffers support (#6095) 2020-09-17 12:21:14 -07:00
flatbuffers.ts [TS/JS] Entry point per namespace and reworked 1.x compatible single file build (#7510) 2023-01-21 12:22:22 -08:00
flexbuffers.ts [JS] Add ".js" suffix to all import statements to generate a browser compatible mjs version. (#7086) 2022-02-08 12:21:20 -08:00
repositories.bzl Remove npm/rules_js dependency for C++ only use cases (#7990) 2024-04-18 05:06:06 +00:00
types.ts [TS] Make strict compliant and improve typings (#7549) 2022-09-29 15:03:35 -07:00
utils.ts [JS/TS] Modernize TypeScript / JavaScript flatbuffers support (#6095) 2020-09-17 12:21:14 -07:00