-
Notifications
You must be signed in to change notification settings - Fork 71
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
JavaScript: es6 module generation #75
Comments
Yes it isn't specified anywhere what would be the correct syntax. My guess is this: but the code generated isn't showing any imports or exports so it must not be working. Can someone confirm what the correct syntax is? |
My version is
It doesn't even complain if any random import_stype provide: protoc --js_out=import_style=random,binary:${DEST} -I ${SRC} ${PROTO_FILE} |
es6 module isn't supported yet. |
Any chance of ES6 imports happening soon? Currently blocking grpc/grpc-web#237 |
Are there any news about ES6 support? I am trying to use grpc-web with commonjs in Vue.js, but get an error. |
You should consider using https://github.com/thesayyn/protoc-gen-ts. It generates classes ES6 compatible. |
Would you accept ES6 support in a pull request? |
Why is it considered to be in any way acceptable to still be relying on ES5 code 5 years after its deprecation? |
Please enhance protoc compiler to generate es6 modules. |
I made a patch for an older commit of protobuf for creating ES6 compatible code. It works fine for me, although it is far from being good enough for a pull request: |
This is a reasonable request, but not planned. |
This is very disappointing. Some libraries already reject to support non-module projects and you don't plan to support modules 👍 Such a good idea of protobuf / grpc(-web) and such a poor implementation and maintenance that people who just want to use it need to use third party libs. Non-tree-shakable, builder pattern in javascript (what???), no typescript / Promises / rxjs support, no alignment to the modern technologies and the outside world (actually this issue prevents any project with The following is maybe not that kind, but that's what I feel. The current state of JS support just looks like a stub that's done for only one reason: to write "we support all the languages" or "here is the implementation, if you don't want to use it it's your problem". If you want your technology to stay alive you should probably reconsider what you are doing and at the very first target all the issues above and finally get away of the stone age. Every project has problems, every framework has issues, but at least they should be targeted and there should be a clear future. |
I can highly recommend https://github.com/timostamm/protobuf-ts as an alternative code generator. Works great in my 100% Typescript codebase. It even still uses protoc.exe under the hood. |
What would be the expected output for ES6 module-style imports? It doesn't seem too hard to modify the generator C++ to support this once the desired behavior is fully specified. Perhaps the following is a bit of an aside - I'm not too familiar with Typescript imports: What makes sense to me is that a generated |
Actually all imports should be done with native JS imports and to support "type": "module" it should also include the file extension, for both typescript and JavaScript it should be '.js'. This should also be adapted in well-known-types which actually made it impossible for me to proceed with patching the protoc's original output, cause changing the well-known-types in the lib was already too much (and if I remember it right they are provided by direct file reference, that's why they aren't processed properly by node.js that would normally see that the library's type is not module and gracefully treat it as it does with legacy libs). Offtopic: Wouldn't it be better to make a separate generator for JavaScript like the guys already did with Golang? Extending C++ compiler is not something one expects while generating JS. This would give a chance to generate a modern tree-shakeable code with direct typescript support |
All imports should be done with native ES6 "import" statements. Code should not require a loader to load. That's just poor form. |
what about this super tiny patch? https://github.com/protocolbuffers/protobuf-javascript/pull/150/files , what do you think? |
https://github.com/protocolbuffers/protobuf-javascript/pull/156/files is pretty close to completing this but needs testing and support for the built-in well-known-types. |
With Angular updating their application-builder to use
will prevent the It is unclear to me how long the old builder support will be maintained by the Angular team. |
@codedread I followed up with the Angular folks about this and you should be able to continue to use commonjs require()'s with esbuild. They noted that additional configuration may be needed for the Vite dev server: "The development server has an option (prebundle) which can be used to fully disable the feature or exclude specific packages. In the case of google-protobuf generated files with require, one of these options would be needed with the tradeoff being longer rebuilds during development. An example subset of the configuration would be similar to the folllowing:"
If you've encountered a specific issue during a migration/prototype, I'm happy to try to dig into it. |
Why is this not yet implemented? Is protobuf-javascript abandoned project and we should use other projects instead? |
Asking because I couldn't find anything about generating es6 modules instead of closure or common via protoc (https://developers.google.com/protocol-buffers/docs/reference/javascript-generated#package).
Is it possible or on the roadmap?
The text was updated successfully, but these errors were encountered: