Skip to content

Commit

Permalink
fix: fixing exportCommonSymbols in nestjs (#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
eladhaim authored Sep 3, 2023
1 parent be5c22e commit daf41f7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions NESTJS.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,5 @@ export class AppService implements OnModuleInit {
(Requires `nestJs=true`.)

- With `--ts_proto_opt=nestJs=true`, the defaults will change to generate [NestJS protobuf](https://docs.nestjs.com/microservices/grpc) friendly types & service interfaces that can be used in both the client-side and server-side of NestJS protobuf implementations.

- With `--ts_proto_opt=exportCommonSymbols=false`, the plugin will not generate the export with the specified package name.
7 changes: 4 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,10 @@ export function generateFile(ctx: Context, fileDesc: FileDescriptorProto): [stri

// If nestJs=true export [package]_PACKAGE_NAME and [service]_SERVICE_NAME const
if (options.nestJs) {
const prefix = camelToSnake(fileDesc.package.replace(/\./g, "_"));
chunks.push(code`export const ${prefix}_PACKAGE_NAME = '${fileDesc.package}';`);

if (options.exportCommonSymbols) {
const prefix = camelToSnake(fileDesc.package.replace(/\./g, "_"));
chunks.push(code`export const ${prefix}_PACKAGE_NAME = '${fileDesc.package}';`);
}
if (
options.useDate === DateOption.DATE &&
fileDesc.messageType.find((message) =>
Expand Down

0 comments on commit daf41f7

Please sign in to comment.