Skip to content

Commit

Permalink
fix: specify pbjs root (#323)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
achingbrain authored Apr 20, 2021
1 parent 58a8de1 commit 2bf0c2e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"scripts": {
"prepare": "npm run build",
"build": "npm run build:proto && npm run build:proto-types && npm run build:bundle",
"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",
"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",
"build:proto-types": "pbts -o src/types/message/message.d.ts src/types/message/message.js",
"build:bundle": "aegir build",
"test": "aegir test",
Expand Down
2 changes: 1 addition & 1 deletion src/types/message/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var $protobuf = require("protobufjs/minimal");
var $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;

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

$root.Message = (function() {

Expand Down

0 comments on commit 2bf0c2e

Please sign in to comment.