| load( |
| "@build_bazel_rules_typescript//:defs.bzl", |
| "ts_library", |
| "ts_proto_library", |
| "ts_web_test_suite", |
| "ts_devserver", |
| ) |
| |
| 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"], |
| deps = [":car"], |
| ) |
| |
| 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 = [":app"], |
| ) |
| |
| # Test for production mode |
| load("@build_bazel_rules_nodejs//:defs.bzl", "rollup_bundle", "nodejs_binary") |
| |
| 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", |
| ) |
| |
| nodejs_binary( |
| name = "prodserver", |
| args = ["./examples/protocol_buffers"], |
| data = [ |
| "index.html", |
| ":bundle", |
| ":protobufjs", |
| ], |
| entry_point = "http-server/bin/http-server", |
| ) |
| |
| ts_library( |
| name = "e2e", |
| testonly = 1, |
| srcs = ["app_e2e_test.ts"], |
| ) |