| load("@build_bazel_rules_karma//:defaults.bzl", "ts_web_test_suite") |
| load("@build_bazel_rules_nodejs//:defs.bzl", "http_server", "rollup_bundle") |
| load("@io_bazel_rules_go//go:def.bzl", "go_library") |
| load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") |
| load( |
| "//:defs.bzl", |
| "ts_devserver", |
| "ts_proto_library", |
| ) |
| load("//internal:defaults.bzl", "ts_library") |
| |
| proto_library( |
| name = "tire_proto", |
| srcs = ["tire.proto"], |
| ) |
| |
| proto_library( |
| name = "car_proto", |
| srcs = ["car.proto"], |
| deps = [":tire_proto"], |
| ) |
| |
| ts_proto_library( |
| # The result will be "car.d.ts" named after this target. |
| # We could use the output_name attribute if we want the output named |
| # differently than the target. |
| name = "car", |
| deps = [":car_proto"], |
| ) |
| |
| ts_library( |
| name = "test_lib", |
| testonly = True, |
| srcs = ["car.spec.ts"], |
| tsconfig = "//examples:tsconfig-test", |
| deps = [ |
| ":car", |
| "@npm//@types/jasmine", |
| "@npm//@types/long", |
| "@npm//@types/node", |
| "@npm//long", |
| ], |
| ) |
| |
| ts_web_test_suite( |
| name = "test", |
| bootstrap = ["@build_bazel_rules_typescript//:protobufjs_bootstrap_scripts"], |
| browsers = [ |
| "@io_bazel_rules_webtesting//browsers:chromium-local", |
| "@io_bazel_rules_webtesting//browsers:firefox-local", |
| ], |
| deps = ["test_lib"], |
| ) |
| |
| ts_library( |
| name = "app", |
| srcs = ["app.ts"], |
| deps = [":car"], |
| ) |
| |
| ts_devserver( |
| name = "devserver", |
| bootstrap = ["@build_bazel_rules_typescript//:protobufjs_bootstrap_scripts"], |
| entry_module = "build_bazel_rules_typescript/examples/protocol_buffers/app", |
| port = 8080, |
| deps = [":bundle"], |
| ) |
| |
| # Test for production mode |
| rollup_bundle( |
| name = "bundle", |
| entry_point = "examples/protocol_buffers/app", |
| # TODO(alexeagle): we should be able to get this from //:protobufjs_bootstrap_scripts |
| # and automatically plumb it through to Rollup. |
| globals = { |
| "long": "Long", |
| "protobufjs/minimal": "protobuf", |
| }, |
| deps = [":app"], |
| ) |
| |
| # Needed because the prodserver only loads static files that appear under this |
| # package. |
| genrule( |
| name = "protobufjs", |
| srcs = [ |
| "@build_bazel_rules_typescript_protobufs_compiletime_deps//node_modules/protobufjs:dist/minimal/protobuf.min.js", |
| "@build_bazel_rules_typescript_protobufs_compiletime_deps//node_modules/long:dist/long.js", |
| ], |
| outs = [ |
| "protobuf.min.js", |
| "long.js", |
| ], |
| cmd = "outs=($(OUTS)); d=$$(dirname $${outs[0]}); for s in $(SRCS); do cp $$s $$d; done", |
| ) |
| |
| http_server( |
| name = "prodserver", |
| data = [ |
| "index.html", |
| ":bundle", |
| ":protobufjs", |
| ], |
| ) |
| |
| ts_library( |
| name = "e2e", |
| testonly = 1, |
| srcs = ["app_e2e_test.ts"], |
| tsconfig = "//examples:tsconfig-test", |
| deps = [ |
| "@npm//@types/jasmine", |
| "@npm//@types/node", |
| "@npm//protractor", |
| ], |
| ) |
| |
| proto_library( |
| name = "rules_typescript_proto", |
| srcs = [ |
| "car.proto", |
| "tire.proto", |
| ], |
| visibility = ["//visibility:public"], |
| ) |
| |
| go_proto_library( |
| name = "rules_typescript_go_proto", |
| importpath = "github.com/bazelbuild/rules_typescript/examples/protocol_buffers", |
| proto = ":rules_typescript_proto", |
| visibility = ["//visibility:public"], |
| ) |
| |
| go_library( |
| name = "go_default_library", |
| embed = [":rules_typescript_go_proto"], |
| importpath = "github.com/bazelbuild/rules_typescript/examples/protocol_buffers", |
| visibility = ["//visibility:public"], |
| ) |