Giter Club home page Giter Club logo

rules_typescript_proto's Introduction

rules_typescript_proto

Bazel rules for generating TypeScript declarations for JavaScript protocol buffers using the ts-protoc-gen protoc plugin. These rules can also generate service definitions for use by grpc-web.

Getting Started

If you're migrating from the ts-protoc-gen rules, see here for a migration guide

Before you can use rules_typescript_proto, you must first setup:

Once those are setup, add the following to your workspace:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# TODO: Setup rules_proto
# TODO: Setup rules_nodejs

http_archive(
    name = "rules_typescript_proto",
    # TODO: Update these values to the latest version
    sha256 = "3ef93812b7c8589a5e7fbc7e9a8c1b2f9a982320f3e96443f8bcdd76b3ef6bc0",
    strip_prefix = "rules_typescript_proto-88de411e84ca05133f584633871f1f417a52095e",
    urls = [
        "https://github.com/Dig-Doug/rules_typescript_proto/archive/88de411e84ca05133f584633871f1f417a52095e.tar.gz",
    ],
)

load("@rules_typescript_proto//:index.bzl", "rules_typescript_proto_dependencies")

rules_typescript_proto_dependencies()

Then, in your BUILD file:

load("@rules_typescript_proto//:index.bzl", "typescript_proto_library")

proto_library(
  name = "test_proto",
  srcs = [
    "test.proto",
  ],
)

typescript_proto_library(
  name = "test_ts_proto",
  proto = ":test_proto",
)

You can now use the test_ts_proto target as a dep in other ts_library targets. However, you will need to include the following dependencies at runtime yourself:

  • google-protobuf
  • @improbable-eng/grpc-web
  • browser-headers

See //test:pizza_service_proto_test_suite for an example.

IDE Code Completion

To get code completion working for the generated protos in your IDE, add the following to your tsconfig.json:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      // Replace <workspace-name> with the name of your workspace
      "<workspace-name>/*": [
        "*", // Enables absolute paths for src files in your project
        "bazel-bin/*" // Enables referencing generate protos with absolute paths
      ]
    }
  }
}

NOTE: This has only been tested in IntelliJ with the bazel plugin

Contributing

Contributions are welcome!

rules_typescript_proto's People

Contributors

dig-doug avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.