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

support for generating es6 imports and .d.ts files #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lukfugl
Copy link
Member

@lukfugl lukfugl commented Dec 9, 2024

Builds on protocolbuffers#150, adding:

  • support for library option with ES6
  • .d.ts generation when requested (generate_dts flag) and compatible (library option set and import_style set to es6)

Tested compilation of Derivita's omaha/base/ast.proto and inspecting the generated omaha/base/ast_proto.js and omaha/base/ast_proto.d.ts files.

@lukfugl lukfugl requested a review from ribrdb December 9, 2024 18:26
Copy link

@ribrdb ribrdb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you temporarily add the output of running this on test.proto so I can see the output?

for (int i = 0; i < file->dependency_count(); i++) {
const std::string& name = file->dependency(i)->name();
printer->Print("import * as $alias$ from '$file$';\n"
"goog.object.extend(proto, $alias$);\n",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goog.object.extend is deprecated, we should just use Object.assign.
Although I'm a little curios what's getting extended here. If this is building up a goog.module style namespace containing all protobufs, that's probably not something we want.

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.

3 participants