You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to put example1.proto and example2.proto into a common namespace throws the following:
> var builder = ProtoBuf.protoFromFile("./example1.proto");
undefined
> ProtoBuf.protoFromFile("./example2.proto", builder)
Error: Duplicate name in namespace Namespace : Test3
at ProtoBuf.Reflect.Namespace.addChild (E:\Downloads\node_modules\protobufjs\ProtoBuf.js:1192:27)
at ProtoBuf.Builder.Builder.create (E:\Downloads\node_modules\protobufjs\ProtoBuf.js:2530:42)
at ProtoBuf.Builder.Builder.import (E:\Downloads\node_modules\protobufjs\ProtoBuf.js:2590:26)
at ProtoBuf.Builder.Builder.import (E:\Downloads\node_modules\protobufjs\ProtoBuf.js:2622:43)
at Object.ProtoBuf.protoFromString (E:\Downloads\node_modules\protobufjs\ProtoBuf.js:2757:34)
at Object.ProtoBuf.protoFromFile (E:\Downloads\node_modules\protobufjs\ProtoBuf.js:2790:53)
at repl:1:11
at REPLServer.self.eval (repl.js:110:21)
at Interface.<anonymous> (repl.js:239:12)
at Interface.EventEmitter.emit (events.js:95:17)
The text was updated successfully, but these errors were encountered:
The recommended way of doing this is to use two builders through ProtoBuf.protoFromFile(...) or to create a compound .proto file for your application.
Of course file names could be remembered and excluded from the next include. However, ProtoBuf.js does not know of possible file changes, working directory changes and so on, which might lead to unexpected behaviour. Hmm..
Instead of remembering file names, you could remember the absolute paths - in node.js you can use path.resolve. It's not an issue in the browser, correct?
As for file changes, I think it would be best to follow the approach of node.js's require. If the file has been loaded before, it returns the cached module and doesn't care if the file has been modified.
Consider the following three files:
Trying to put example1.proto and example2.proto into a common namespace throws the following:
The text was updated successfully, but these errors were encountered: