Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change ts_proto_library to default es5 wrapping #1593

Merged
merged 3 commits into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,8 @@ load("@build_bazel_integration_testing//tools:repositories.bzl", "bazel_binaries

# Depend on the Bazel binaries
bazel_binaries(versions = [BAZEL_VERSION])

# Install labs dependencies
load("@npm_bazel_labs//:package.bzl", "npm_bazel_labs_dependencies")

npm_bazel_labs_dependencies()
2 changes: 1 addition & 1 deletion packages/labs/src/protobufjs/ts_proto_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

load("@build_bazel_rules_nodejs//:providers.bzl", "DeclarationInfo", "JSEcmaScriptModuleInfo", "JSNamedModuleInfo")

def _run_pbjs(actions, executable, var, output_name, proto_files, suffix = ".js", wrap = "amd", amd_name = ""):
def _run_pbjs(actions, executable, var, output_name, proto_files, suffix = ".js", wrap = "default", amd_name = ""):
js_file = actions.declare_file(output_name + suffix)

# Create an intermediate file so that we can do some manipulation of the
Expand Down
31 changes: 31 additions & 0 deletions packages/labs/test/protobufjs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
load("@npm_bazel_jasmine//:index.from_src.bzl", "jasmine_node_test")
load("@npm_bazel_labs//:index.bzl", "ts_proto_library")
load("@npm_bazel_typescript//:index.from_src.bzl", "ts_library")
load("@rules_proto//proto:defs.bzl", "proto_library")

ts_library(
name = "test",
srcs = ["test.ts"],
deps = [
":test_ts_proto",
"@npm//@types/jasmine",
],
)

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

ts_proto_library(
name = "test_ts_proto",
deps = [":test_proto"],
)

jasmine_node_test(
name = "protobuf_test",
srcs = [":test"],
deps = [
"@npm//protobufjs",
],
)
5 changes: 5 additions & 0 deletions packages/labs/test/protobufjs/test.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
syntax = "proto3";

message TestMessage {
string test_field = 1;
}
11 changes: 11 additions & 0 deletions packages/labs/test/protobufjs/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {TestMessage} from 'build_bazel_rules_nodejs/packages/labs/test/protobufjs/test_ts_proto';

// const TestMessage = build_bazel_rules_nodejs.packages.labs.test.protobufjs.TestMessage;
CooperBills marked this conversation as resolved.
Show resolved Hide resolved

describe('protobufjs', () => {
it('should work in node', () => {
expect(TestMessage.verify({
testField: 'Hello',
})).toBeFalsy(); // verify returns an error if failed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be a success case too? or is it enough to assert that it doesn't throw an error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test case is really just to run some code - I could change it to expect(TestMessage).toBeTruthy(); and get the verification needed for this PR, would you prefer the simpler test case?

});
});