protobuf-javascript icon indicating copy to clipboard operation
protobuf-javascript copied to clipboard

js/{closure,commonjs}: create a new js_module option

Open glerchundi opened this issue 7 years ago • 18 comments

What language does this apply to?

If it's a proto syntax change, is it for proto2 or proto3? proto3 If it's about generated code change, what programming language? javascript/commonjs but it can be applied to es6 or closure as well.

Describe the problem you are trying to solve.

We are generating code of multiple packages that we want to publish independently but with references between them. Currently the generator creates a tightly coupled relative paths between folders.

Describe the solution you'd like

An option like Go's go_package or C#'s csharp_namespace where I can put the import path, in this case the JS module.

I think a js_module called option would do the trick.

Describe alternatives you've considered

Overriding the generated code.

glerchundi avatar Sep 07 '18 10:09 glerchundi

@xfxyjwf friendly ping!

glerchundi avatar Sep 21 '18 10:09 glerchundi

Any update on this ?

aberasarte avatar Mar 27 '19 16:03 aberasarte

Another friendly ping to @anandolee @TeBoring @BSBandme!

glerchundi avatar Mar 28 '19 11:03 glerchundi

This is related to protocolbuffers/protobuf#2198, is it possible any maintainer give us a status update or how they think this can be solved/workaround?

We want to start collaborating with envoyproxy/lyft and its protoc-gen-validate and this would open up the possibility to make it happen.

glerchundi avatar May 07 '19 09:05 glerchundi

In fact internally we have some options to tweak the namespace. But we still don't have a way for commonjs. There're some legacy reasons that we didn't open source this (we have several different js protobuf implementations internally).

Will discuss about this in next team meeting.

BSBandme avatar Jun 11 '19 01:06 BSBandme

In fact internally we have some options to tweak the namespace. But we still don't have a way for commonjs. There're some legacy reasons that we didn't open source this (we have several different js protobuf implementations internally).

Thanks for the update and the details.

Will discuss about this in next team meeting.

Did that meeting already occurred, and it case it did do you have a path forward for this issue?

Thanks.

glerchundi avatar Jul 08 '19 07:07 glerchundi

Believe me that I feel really really bad for pinging you all again but we're really interested in working on this and would love to see at least a status update and/or roadmap for a possible publishing or reimplementation on upstream. 🙏

glerchundi avatar Aug 21 '19 10:08 glerchundi

@BSBandme, can you tell us if there are any plans to implement this or suggest a workaround, I'd greatly appreciate it!

This is blocking for me, I'm planning to work around this by patching the generated code to remove relative imports with corresponding npm packages. That is, replace require("../sibling/sibling.proto") with require("npmlib/sibling.proto").

I'm trying to decouple proto packages into separate npm modules, and have them depend on each other.

4nte avatar Mar 12 '20 13:03 4nte

That is, replace require("../sibling/sibling.proto") with require("npmlib/sibling.proto").

This is exactly what we are doing. We have a shell script that replaces the relative imports with package imports. It's ugly and error prone but is the only workaround we have at the moment.

It's been a while since the last update, I would love to hear if there are any plans to add this feature in the near future.

aberasarte avatar Mar 12 '20 16:03 aberasarte

@BSBandme could you shed some light on this matter please?

Our building script is now a little monster that is really hard to maintain and is breaking every time we add new dependencies.

This feature would make things much easier for us.

Thanks in advance

aberasarte avatar Nov 26 '20 09:11 aberasarte

Watching this one closly We also work with protos and node and would love to have validations with lyft's PGV project. (We work with it already in golang, clojure & python).

buzzdan avatar Dec 02 '20 18:12 buzzdan

friendly ping to @anandolee @TeBoring @BSBandme 🙏

buzzdan avatar Jan 13 '21 14:01 buzzdan

Also another friendly reminder for @perezd as he seems to be the one driving javascript related issues. 🙏

glerchundi avatar Jan 13 '21 14:01 glerchundi

Howdy, thanks for reaching out. Addressing this is currently not on our roadmap at this time. We're in the process of revamping our comprehensive Protobuf support for JavaScript/TypeScript and would ask that you remain patient with us as we attempt to address the larger needs of the project both internally and externally. I hope you understand the position we're in with our resources and responsibilities.

perezd avatar Jan 13 '21 18:01 perezd

@perezd to be honest this is taking more time than I thought, even for triaging! 😭

Without being too dramatic and trying to set real expectations, do you think this will be addressed in the next, for instance, 6 months? I really wanna go through the standard path but if there is no an expected timeline for this I will try to think & implement alternative ways.

Thanks!

glerchundi avatar Aug 24 '21 05:08 glerchundi

heya, our roadmap/objectives have shifted and I do not believe you'll see this in that timeframe. sorry :(

perezd avatar Aug 24 '21 17:08 perezd

While we don't have this sorted, I am handling this issue with a simple bash function https://github.com/apssouza22/modern-api-management/blob/master/bin/js-gen.sh#L105

apssouza22 avatar Apr 11 '22 18:04 apssouza22

We understand this is a problem, but are unclear what the best solution would be.

dibenede avatar Sep 23 '22 23:09 dibenede