Skip to content

Commit 2bf0c2e

Browse files
authored
fix: specify pbjs root (#323)
If we do not specify a root for pbjs, the default is used which is shared globally, so we can't have a protobuf message called `Message` that exists for both `ipfs-bitswap` and `libp2p-kad-dht`, for example. Specify a root to add a scope to the declaration of protobuf messages.
1 parent 58a8de1 commit 2bf0c2e

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"scripts": {
3434
"prepare": "npm run build",
3535
"build": "npm run build:proto && npm run build:proto-types && npm run build:bundle",
36-
"build:proto": "pbjs -t static-module -w commonjs --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/types/message/message.js src/types/message/message.proto",
36+
"build:proto": "pbjs -t static-module -w commonjs -r ipfs-bitswap --force-number --no-verify --no-delimited --no-create --no-beautify --no-defaults --lint eslint-disable -o src/types/message/message.js src/types/message/message.proto",
3737
"build:proto-types": "pbts -o src/types/message/message.d.ts src/types/message/message.js",
3838
"build:bundle": "aegir build",
3939
"test": "aegir test",

src/types/message/message.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var $protobuf = require("protobufjs/minimal");
77
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;
88

99
// Exported root namespace
10-
var $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});
10+
var $root = $protobuf.roots["ipfs-bitswap"] || ($protobuf.roots["ipfs-bitswap"] = {});
1111

1212
$root.Message = (function() {
1313

0 commit comments

Comments
 (0)