-
Notifications
You must be signed in to change notification settings - Fork 1.4k
protobufjs library itself doesn't provide module support #1230
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
Comments
This would be particularly useful to support deno. I would love to help with this, but since protobuf.js uses CommonJS, a design decision needs to be made on how to approach this. |
Any more updates/info on this one? Using ES6 modules in Node via
|
Trying to import as ESM module to vite project also fails. I am adding protobuf globally to the page to make it work, but ESM support could be nice. |
Switches the codebase to ESM and exports ESM and CJS code. The main goal is to enable ipfs-unixfs to be built on next generation bundlers like skypack: codepen.io/vascosantos/pen/NWjaYqP?editors=0011 This is a problem that has not been fixed in skypack yet. More details: skypackjs/skypack-cdn#171 Given we will need to export ESM and we will, let's get this to circumvent the issue. We also need to manually change the generated protobuf code due to protobufjs/protobuf.js#1230 BREAKING CHANGE: ./src/dir-sharded is not in the exports map so cannot be imported Co-authored-by: Alex Potsides <[email protected]>
Seems to have been resolved, no longer getting the error ⭐ 🚀 |
I have my HTML like this <script src="//cdn.jsdelivr.net/npm/[email protected]/dist/protobuf.min.js"></script>
<script src="./proto/proto.js" type="module"></script> I have compiled my proto syntax="proto3";
// message = type of object
// ClientMessage = name of object
message ClientMessage {
string message =1;
}
message ServerMessage {
string username =1;
string message =2;
bool history=3;
} into js using this command pbjs -t static-module -w es6 -o proto.js chat.proto Im not use node or anything. Just want my compiled file to be able to use the proto protobuf.min.js from the cdn. No matter what i do i get this error
All due to this line in proto.js [ the compiled js ] import * as $protobuf from "protobufjs/minimal"; Now im out of options. Can anyone please help ? As if the compiled code is unable to see the min.js pulled by the CDN |
Uh oh!
There was an error while loading. Please reload this page.
protobuf.js version: 6.8.8
example: https://github.com/gertcuykens/protobuf
Generated modules looks ok using
But it seems the protobufjs library itself doesn't provide module support?
Suggest to make a seperate
protobufjs/minimal.mjs
andprotobufjs/index.mjs
maybe to have full module support out of the box?The text was updated successfully, but these errors were encountered: