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

Not works well with Webpack (AMD package name wrong ?) #554

Closed
k8w opened this Issue Dec 13, 2016 · 4 comments

Comments

Projects
None yet
2 participants
@k8w

k8w commented Dec 13, 2016

When using with webpack (generate static code), it always compiled error:

ERROR in ../realtimeServer/src/proto/RealtimeServerProto.js
Module not found: Error: Cannot resolve module 'protobuf' in E:\Codes\ChartMaker\realtimeServer\src\proto
@ ../realtimeServer/src/proto/RealtimeServerProto.js 4:8-37

This problem can be resolved by modify the line 4 in generated .js file:

define(["protobuf"], factory);

modify to

define(["protobufjs"], factory);
@dcodeIO

This comment has been minimized.

Owner

dcodeIO commented Dec 13, 2016

The AMD module name is protobuf. If you do not require AMD, try with the current master version and use --wrap commonjs with pbjs. If you require AMD only, consider using --wrap amd and a require config to point protobuf accordingly.

@dcodeIO dcodeIO added the question label Dec 13, 2016

@k8w

This comment has been minimized.

k8w commented Dec 14, 2016

with --wrap commonjs
But occur error at runtime.

TypeError: Cannot set property 'default' of undefined

At last of the js file:
$protobuf.roots["default"] = $root;
Seems $protobuf.roots is undefined.
It works well if remove this line.

@k8w

This comment has been minimized.

k8w commented Dec 14, 2016

AMD package name is different with npm package name.
Not sure if it is unfriendly to other package tools except Webpack

@dcodeIO

This comment has been minimized.

Owner

dcodeIO commented Dec 14, 2016

The protobuf.roots feature has just been added. Are you using 6.1.1?

Wait, it's not in the minimal runtime yet... need to add it there, too.

AMD package name is different with npm package name.
Not sure if it is unfriendly to other package tools except Webpack

Well, the "protobuf" name wasn't available anymore on npm at that time, and that's the only reason it is using something else on npm. I believe this is a general issue that tools should always consider, because this will become more and more standard in the future / as npm grows.

dcodeIO added a commit that referenced this issue Dec 14, 2016

@dcodeIO dcodeIO closed this Dec 15, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment