From daf41f7c2654e801994c0791fb3f9f178b5d8ad8 Mon Sep 17 00:00:00 2001 From: eladhaim <91606452+eladhaim@users.noreply.github.com> Date: Sun, 3 Sep 2023 07:21:23 +0300 Subject: [PATCH] fix: fixing exportCommonSymbols in nestjs (#916) --- NESTJS.markdown | 2 ++ src/main.ts | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/NESTJS.markdown b/NESTJS.markdown index 1f3a1ba8b..7dc0ef01e 100644 --- a/NESTJS.markdown +++ b/NESTJS.markdown @@ -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. diff --git a/src/main.ts b/src/main.ts index 9f143fe53..23fe63000 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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) =>