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 CommonJS in protoc-gen-connect-query #297

Closed
timostamm opened this issue Dec 13, 2023 · 0 comments · Fixed by #303
Closed

Support CommonJS in protoc-gen-connect-query #297

timostamm opened this issue Dec 13, 2023 · 0 comments · Fixed by #303

Comments

@timostamm
Copy link
Member

@bufbuild/protoplugin added support for CommonJS in v1.6.0.

It would be nice if protoc-gen-connect-query supported the this feature as well. It needs to generate export statements with the new method GeneratedFile.exportDecl to do so.

See connectrpc/connect-es#956 for the same update to protoc-gen-connect-es.

paul-sachs added a commit that referenced this issue Dec 14, 2023
Fixes #297 

Add support for CommonJS with the new plugin option:

### `js_import_style`

By default,
[protoc-gen-connect-query](https://www.npmjs.com/package/@connectrpc/protoc-gen-connect-query)(and
all other plugins based on
[@bufbuild/protoplugin](https://www.npmjs.com/package/@bufbuild/protoplugin))
generate ECMAScript `import` and `export` statements. For use cases
where CommonJS is difficult to avoid, this option can be used to
generate CommonJS`require()` calls.

#### Example buf.gen.yaml

```
version: v1
plugins:
  - plugin: es
    out: src/gen
    opt: js_import_style=legacy_commonjs
  - plugin: connect-query
    out: src/gen
    opt: js_import_style=legacy_commonjs
 ```
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 a pull request may close this issue.

1 participant