github.com/stackb/rules_proto@v0.0.0-20240221195024-5428336c51f1/docs/closurejs.md (about)

     1  ---
     2  layout: default
     3  title: closurejs
     4  permalink: examples/closurejs
     5  parent: Examples
     6  ---
     7  
     8  
     9  # closurejs example
    10  
    11  `bazel test //example/golden:closurejs_test`
    12  
    13  
    14  ## `BUILD.bazel` (after gazelle)
    15  
    16  ~~~python
    17  load("@rules_proto//proto:defs.bzl", "proto_library")
    18  load("@build_stack_rules_proto//rules:proto_compile.bzl", "proto_compile")
    19  
    20  # "proto_rule" instantiates the proto_compile rule
    21  # gazelle:proto_rule proto_compile implementation stackb:rules_proto:proto_compile
    22  
    23  # "proto_plugin" instantiates the builtin closurejs plugin
    24  # gazelle:proto_plugin closurejs implementation builtin:js:closure
    25  
    26  # "proto_language" binds the rule(s) and plugin(s) together
    27  # gazelle:proto_language closurejs rule proto_compile
    28  # gazelle:proto_language closurejs plugin closurejs
    29  
    30  proto_library(
    31      name = "example_proto",
    32      srcs = ["example.proto"],
    33      visibility = ["//visibility:public"],
    34  )
    35  
    36  proto_compile(
    37      name = "example_closurejs_compile",
    38      options = {"@build_stack_rules_proto//plugin/builtin:closurejs": [
    39          "import_style=closure",
    40          "library=example",
    41      ]},
    42      outputs = ["example.js"],
    43      plugins = ["@build_stack_rules_proto//plugin/builtin:closurejs"],
    44      proto = "example_proto",
    45  )
    46  ~~~
    47  
    48  
    49  ## `BUILD.bazel` (before gazelle)
    50  
    51  ~~~python
    52  # "proto_rule" instantiates the proto_compile rule
    53  # gazelle:proto_rule proto_compile implementation stackb:rules_proto:proto_compile
    54  
    55  # "proto_plugin" instantiates the builtin closurejs plugin
    56  # gazelle:proto_plugin closurejs implementation builtin:js:closure
    57  
    58  # "proto_language" binds the rule(s) and plugin(s) together
    59  # gazelle:proto_language closurejs rule proto_compile
    60  # gazelle:proto_language closurejs plugin closurejs
    61  ~~~
    62  
    63  
    64  ## `WORKSPACE`
    65  
    66  ~~~python
    67  ~~~
    68