-
Notifications
You must be signed in to change notification settings - Fork 522
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
[ts_proto_library] - Does not support Nodejs #562
Comments
There is a simple fix to this issue. You just need to tweak the following line in def _run_pbjs(actions, executable, output_name, proto_files, suffix = '.js',
wrap = 'amd', amd_name = ''): Change I am thinking of upstreaming my changes here. Just have not got enough priorities yet. If it works for you and there is a strong interest, please feel free to bring up a PR. |
FYI, our team has been using this trick for a few months and it served us well. |
Just to update, the New path to ts_proto_library.bzl. Cheers! |
* change ts_proto_library to default es5 wrapping This change wraps es5 sources generated with `ts_proto_library` to be wrapped in "default" mode. The "default" mode behaves like UMD, supporting both AMD and CommonJS. This change is necessary to support Node, as Node does not use AMD. See #562
🐞 bug report
Affected Rule
ts_proto_library
Is this a regression?
Nope
Description
The module format of the code generated is not usable in a Nodejs environment due to it being AMD module format, where as Nodejs expects CommonJS.
From looking at the docs: https://github.com/dcodeIO/ProtoBuf.js/#pbts-for-typescript
They don't appear to support different modules so either a preprocessing step to change the module format is required to changing the protobufjs lib itself to support other module code generation.
🔬 Minimal Reproduction
angular/universal#1003
🔥 Exception or Error
Error:
ReferenceError: define is not defined
This is the generated code:
🌍 Your Environment
Operating System:
Output of
bazel version
:Rules version (SHA):
Anything else relevant?
The text was updated successfully, but these errors were encountered: