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

pbjs: generate json-module target #621

Closed
halex2005 opened this issue Jan 5, 2017 · 0 comments
Closed

pbjs: generate json-module target #621

halex2005 opened this issue Jan 5, 2017 · 0 comments

Comments

@halex2005
Copy link
Contributor

protobuf.js version: v6.4.1

I use

node_modules/protobufjs/bin/pbjs -p ./proto -o protoclasses-module.js -t json-module --no-delimited ./proto/**/*.proto

to generate javascript module.
Generated code has bootstrapper:

module.exports = factory(require("protobufjs/runtime"));

where the factory is

function($protobuf) {
    "use strict";
    var $root = protobuf.Root.fromJSON({

but protobufjs/runtime has no Root property exported and I get runtime error

/home/hal/git/diadocsdk-proto/protoclasses-module.js:8
        module.exports = factory(require("protobufjs/runtime"));
                         ^
TypeError: Cannot read property 'fromJSON' of undefined
    at /home/hal/git/diadocsdk-proto/protoclasses-module.js:13:30

So, I can fix this by require('protobufjs'), not require('protobufjs/runtime').
Or I can make PR with Root exported from runtime.
Which is correct usage scenario for protobuf/runtime here?

@dcodeIO dcodeIO closed this as completed in c9a61e5 Jan 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant