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

feat(microservices): support ncc when using grpc #8615

Merged

Conversation

zanminkian
Copy link
Contributor

A well-performed nestjs standard project, which transport is Transport.GRPC and protoLoader is @grpc/proto-loader, is not compatible with npm package @vercel/ncc. The reason is - ncc compiling js file use static analysation. Therefore, require(someVar) is not supported by ncc, but require("some-string") works well.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

  • Step1: run nest build in a standard nestjs project that its transport is Transport.GRPC and its protoLoader is @grpc/proto-loader
  • Step2: run npm i -g @vercel/ncc && ncc build dist/main.js -m -o out
  • Step3: run node out/index.js to bootstrap, but fail

What is the new behavior?

  • Step1: run nest build in a standard nestjs project that its transport is Transport.GRPC and its protoLoader is @grpc/proto-loader
  • Step2: run npm i -g @vercel/ncc && ncc build dist/main.js -m -o out
  • Step3: run node out/index.js to bootstrap, success.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@kamilmysliwiec
Copy link
Member

Left 2 minor comments, otherwise it looks great

@coveralls
Copy link

coveralls commented Nov 17, 2021

Pull Request Test Coverage Report for Build bcea77f5-5d40-44f5-b790-7c93618f653d

  • 4 of 4 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.002%) to 94.082%

Totals Coverage Status
Change from base Build 8b22cdab-da56-48e2-8ec8-1138233399c3: 0.002%
Covered Lines: 5660
Relevant Lines: 6016

💛 - Coveralls

@zanminkian zanminkian force-pushed the feat/support-ncc-when-using-grpc branch from 99616ef to 3d95392 Compare November 17, 2021 08:19
@kamilmysliwiec kamilmysliwiec merged commit beebe16 into nestjs:master Nov 17, 2021
@kamilmysliwiec
Copy link
Member

LGTM

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 this pull request may close these issues.

None yet

3 participants