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

fix: fixing exportCommonSymbols in nestjs #916

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -156,9 +156,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
Loading