Skip to content
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

enabled GenerateClassFromObject in js_generator #204

Closed
wants to merge 2 commits into from

Conversation

kzolti
Copy link

@kzolti kzolti commented May 12, 2024

The fromObject method works without errors.

@dibenede
Copy link
Contributor

Sorry for the delay. You are correct that fromObject works and is essentially just disconnected. However, this is intentional (our internal codebase essentially has a do-not-export ifdef around it.

We generally don't support toObject/fromObject aside from testing convenience. The produced object format is not stable and should not be used by applications in production. I can't speak for other bundlers, but I know the Closure Compiler in particular will minify the object keys and cause issues between debug/prod builds.

If there particular reason you want this instead of using serialization/deserialization?

@kzolti
Copy link
Author

kzolti commented May 29, 2024

We generally don't support toObject/fromObject aside from testing convenience. The produced object format is not stable and should not be used by applications in production. I can't speak for other bundlers, but I know the Closure Compiler in particular will minify the object keys and cause issues between debug/prod builds.

If there particular reason you want this instead of using serialization/deserialization?

The fromObject method provides a straightforward way to convert JavaScript objects to Protobuf messages, reducing boilerplate code.
I use React. The fromObject works reliably in React applications. The potential issues with the Closure Compiler are not relevant to React, which does not use this tool.

By merging this pull request, the protobuf-javascript library will gain a long-requested feature that improves developer experience and productivity in modern web applications.

@dibenede
Copy link
Contributor

I know there's an FR around this, but as some of the original comments noted, to/fromObject is distinct from standard proto3 JSON (I can't speak off the top of my head to the precise differences). Hypothetically, proto3 JSON is something we would want to support.

We don't support to/fromObject internally. It just exists because of inertia and generally causes us frustration as maintainers. Since it's not presently available in open source, we don't want to start providing it.

@dibenede dibenede closed this May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants