-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 ```
- Loading branch information
1 parent
036bab5
commit 7ee2820
Showing
16 changed files
with
855 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,32 @@ | ||
# buf.gen.yaml defines a local generation template. | ||
# For details, see https://docs.buf.build/configuration/v1/buf-gen-yaml | ||
version: v1 | ||
plugins: | ||
# js | ||
- plugin: es | ||
out: gen | ||
out: gen_js | ||
- plugin: connect-query | ||
path: ../bin/protoc-gen-connect-query | ||
out: gen_js | ||
|
||
# cjs | ||
- plugin: es | ||
out: gen_cjs | ||
opt: | ||
- target=ts | ||
- js_import_style=legacy_commonjs | ||
- plugin: connect-query | ||
path: ../bin/protoc-gen-connect-query | ||
out: gen_cjs | ||
opt: | ||
- js_import_style=legacy_commonjs | ||
- ts_nocheck=false # we only set this for our tests | ||
|
||
# ts | ||
- plugin: es | ||
out: gen_ts | ||
opt: | ||
- target=ts | ||
- plugin: connect-query | ||
path: ../bin/protoc-gen-connect-query | ||
out: gen | ||
out: gen_ts | ||
opt: | ||
- target=ts+dts+js | ||
- import_extension=none | ||
- ts_nocheck=false | ||
- target=ts | ||
- ts_nocheck=false # we only set this for our tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...en-connect-query/snapshots/gen_cjs/connectrpc/eliza/v1/eliza-ElizaService_connectquery.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2021-2023 The Connect Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// @generated by protoc-gen-connect-query v1.0.0 with parameter "js_import_style=legacy_commonjs,ts_nocheck=false" | ||
// @generated from file connectrpc/eliza/v1/eliza.proto (package connectrpc.eliza.v1, syntax proto3) | ||
/* eslint-disable */ | ||
|
||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
|
||
const { MethodKind } = require("@bufbuild/protobuf"); | ||
const { SayRequest, SayResponse } = require("./eliza_pb.js"); | ||
|
||
/** | ||
* Say is a unary RPC. Eliza responds to the prompt with a single sentence. | ||
* | ||
* @generated from rpc connectrpc.eliza.v1.ElizaService.Say | ||
*/ | ||
const say = { | ||
localName: "say", | ||
name: "Say", | ||
kind: MethodKind.Unary, | ||
I: SayRequest, | ||
O: SayResponse, | ||
service: { | ||
typeName: "connectrpc.eliza.v1.ElizaService", | ||
}, | ||
}; | ||
|
||
exports.say = say; |
258 changes: 258 additions & 0 deletions
258
packages/protoc-gen-connect-query/snapshots/gen_cjs/connectrpc/eliza/v1/eliza_pb.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,258 @@ | ||
// Copyright 2021-2023 The Connect Authors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
// @generated by protoc-gen-es v1.6.0 with parameter "js_import_style=legacy_commonjs" | ||
// @generated from file connectrpc/eliza/v1/eliza.proto (package connectrpc.eliza.v1, syntax proto3) | ||
/* eslint-disable */ | ||
// @ts-nocheck | ||
|
||
import type { | ||
BinaryReadOptions, | ||
FieldList, | ||
JsonReadOptions, | ||
JsonValue, | ||
PartialMessage, | ||
PlainMessage, | ||
} from "@bufbuild/protobuf"; | ||
import { Message, proto3 } from "@bufbuild/protobuf"; | ||
|
||
/** | ||
* SayRequest is a single-sentence request. | ||
* | ||
* @generated from message connectrpc.eliza.v1.SayRequest | ||
*/ | ||
export declare class SayRequest extends Message<SayRequest> { | ||
/** | ||
* @generated from field: string sentence = 1; | ||
*/ | ||
sentence: string; | ||
|
||
constructor(data?: PartialMessage<SayRequest>); | ||
|
||
static readonly runtime: typeof proto3; | ||
static readonly typeName = "connectrpc.eliza.v1.SayRequest"; | ||
static readonly fields: FieldList; | ||
|
||
static fromBinary( | ||
bytes: Uint8Array, | ||
options?: Partial<BinaryReadOptions>, | ||
): SayRequest; | ||
|
||
static fromJson( | ||
jsonValue: JsonValue, | ||
options?: Partial<JsonReadOptions>, | ||
): SayRequest; | ||
|
||
static fromJsonString( | ||
jsonString: string, | ||
options?: Partial<JsonReadOptions>, | ||
): SayRequest; | ||
|
||
static equals( | ||
a: SayRequest | PlainMessage<SayRequest> | undefined, | ||
b: SayRequest | PlainMessage<SayRequest> | undefined, | ||
): boolean; | ||
} | ||
|
||
/** | ||
* SayResponse is a single-sentence response. | ||
* | ||
* @generated from message connectrpc.eliza.v1.SayResponse | ||
*/ | ||
export declare class SayResponse extends Message<SayResponse> { | ||
/** | ||
* @generated from field: string sentence = 1; | ||
*/ | ||
sentence: string; | ||
|
||
constructor(data?: PartialMessage<SayResponse>); | ||
|
||
static readonly runtime: typeof proto3; | ||
static readonly typeName = "connectrpc.eliza.v1.SayResponse"; | ||
static readonly fields: FieldList; | ||
|
||
static fromBinary( | ||
bytes: Uint8Array, | ||
options?: Partial<BinaryReadOptions>, | ||
): SayResponse; | ||
|
||
static fromJson( | ||
jsonValue: JsonValue, | ||
options?: Partial<JsonReadOptions>, | ||
): SayResponse; | ||
|
||
static fromJsonString( | ||
jsonString: string, | ||
options?: Partial<JsonReadOptions>, | ||
): SayResponse; | ||
|
||
static equals( | ||
a: SayResponse | PlainMessage<SayResponse> | undefined, | ||
b: SayResponse | PlainMessage<SayResponse> | undefined, | ||
): boolean; | ||
} | ||
|
||
/** | ||
* ConverseRequest is a single sentence request sent as part of a | ||
* back-and-forth conversation. | ||
* | ||
* @generated from message connectrpc.eliza.v1.ConverseRequest | ||
*/ | ||
export declare class ConverseRequest extends Message<ConverseRequest> { | ||
/** | ||
* @generated from field: string sentence = 1; | ||
*/ | ||
sentence: string; | ||
|
||
constructor(data?: PartialMessage<ConverseRequest>); | ||
|
||
static readonly runtime: typeof proto3; | ||
static readonly typeName = "connectrpc.eliza.v1.ConverseRequest"; | ||
static readonly fields: FieldList; | ||
|
||
static fromBinary( | ||
bytes: Uint8Array, | ||
options?: Partial<BinaryReadOptions>, | ||
): ConverseRequest; | ||
|
||
static fromJson( | ||
jsonValue: JsonValue, | ||
options?: Partial<JsonReadOptions>, | ||
): ConverseRequest; | ||
|
||
static fromJsonString( | ||
jsonString: string, | ||
options?: Partial<JsonReadOptions>, | ||
): ConverseRequest; | ||
|
||
static equals( | ||
a: ConverseRequest | PlainMessage<ConverseRequest> | undefined, | ||
b: ConverseRequest | PlainMessage<ConverseRequest> | undefined, | ||
): boolean; | ||
} | ||
|
||
/** | ||
* ConverseResponse is a single sentence response sent in answer to a | ||
* ConverseRequest. | ||
* | ||
* @generated from message connectrpc.eliza.v1.ConverseResponse | ||
*/ | ||
export declare class ConverseResponse extends Message<ConverseResponse> { | ||
/** | ||
* @generated from field: string sentence = 1; | ||
*/ | ||
sentence: string; | ||
|
||
constructor(data?: PartialMessage<ConverseResponse>); | ||
|
||
static readonly runtime: typeof proto3; | ||
static readonly typeName = "connectrpc.eliza.v1.ConverseResponse"; | ||
static readonly fields: FieldList; | ||
|
||
static fromBinary( | ||
bytes: Uint8Array, | ||
options?: Partial<BinaryReadOptions>, | ||
): ConverseResponse; | ||
|
||
static fromJson( | ||
jsonValue: JsonValue, | ||
options?: Partial<JsonReadOptions>, | ||
): ConverseResponse; | ||
|
||
static fromJsonString( | ||
jsonString: string, | ||
options?: Partial<JsonReadOptions>, | ||
): ConverseResponse; | ||
|
||
static equals( | ||
a: ConverseResponse | PlainMessage<ConverseResponse> | undefined, | ||
b: ConverseResponse | PlainMessage<ConverseResponse> | undefined, | ||
): boolean; | ||
} | ||
|
||
/** | ||
* IntroduceRequest asks Eliza to introduce itself to the named user. | ||
* | ||
* @generated from message connectrpc.eliza.v1.IntroduceRequest | ||
*/ | ||
export declare class IntroduceRequest extends Message<IntroduceRequest> { | ||
/** | ||
* @generated from field: string name = 1; | ||
*/ | ||
name: string; | ||
|
||
constructor(data?: PartialMessage<IntroduceRequest>); | ||
|
||
static readonly runtime: typeof proto3; | ||
static readonly typeName = "connectrpc.eliza.v1.IntroduceRequest"; | ||
static readonly fields: FieldList; | ||
|
||
static fromBinary( | ||
bytes: Uint8Array, | ||
options?: Partial<BinaryReadOptions>, | ||
): IntroduceRequest; | ||
|
||
static fromJson( | ||
jsonValue: JsonValue, | ||
options?: Partial<JsonReadOptions>, | ||
): IntroduceRequest; | ||
|
||
static fromJsonString( | ||
jsonString: string, | ||
options?: Partial<JsonReadOptions>, | ||
): IntroduceRequest; | ||
|
||
static equals( | ||
a: IntroduceRequest | PlainMessage<IntroduceRequest> | undefined, | ||
b: IntroduceRequest | PlainMessage<IntroduceRequest> | undefined, | ||
): boolean; | ||
} | ||
|
||
/** | ||
* IntroduceResponse is one sentence of Eliza's introductory monologue. | ||
* | ||
* @generated from message connectrpc.eliza.v1.IntroduceResponse | ||
*/ | ||
export declare class IntroduceResponse extends Message<IntroduceResponse> { | ||
/** | ||
* @generated from field: string sentence = 1; | ||
*/ | ||
sentence: string; | ||
|
||
constructor(data?: PartialMessage<IntroduceResponse>); | ||
|
||
static readonly runtime: typeof proto3; | ||
static readonly typeName = "connectrpc.eliza.v1.IntroduceResponse"; | ||
static readonly fields: FieldList; | ||
|
||
static fromBinary( | ||
bytes: Uint8Array, | ||
options?: Partial<BinaryReadOptions>, | ||
): IntroduceResponse; | ||
|
||
static fromJson( | ||
jsonValue: JsonValue, | ||
options?: Partial<JsonReadOptions>, | ||
): IntroduceResponse; | ||
|
||
static fromJsonString( | ||
jsonString: string, | ||
options?: Partial<JsonReadOptions>, | ||
): IntroduceResponse; | ||
|
||
static equals( | ||
a: IntroduceResponse | PlainMessage<IntroduceResponse> | undefined, | ||
b: IntroduceResponse | PlainMessage<IntroduceResponse> | undefined, | ||
): boolean; | ||
} |
Oops, something went wrong.