-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change ts_proto_library to default es5 wrapping (#1593)
* change ts_proto_library to default es5 wrapping This change wraps es5 sources generated with `ts_proto_library` to be wrapped in "default" mode. The "default" mode behaves like UMD, supporting both AMD and CommonJS. This change is necessary to support Node, as Node does not use AMD. See #562
- Loading branch information
1 parent
30d0f37
commit dbb2a90
Showing
5 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
syntax = "proto3"; | ||
|
||
message TestMessage { | ||
string test_field = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {TestMessage} from 'build_bazel_rules_nodejs/packages/labs/test/protobufjs/test_ts_proto'; | ||
|
||
describe('protobufjs', () => { | ||
it('should work in node', () => { | ||
expect(TestMessage.verify({ | ||
testField: 'Hello', | ||
})).toBeFalsy(); // verify returns an error if failed | ||
}); | ||
}); |