-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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(core): add missing optional dependencies #5477
Conversation
Pull Request Test Coverage Report for Build b6459367-ea49-40fc-b5bb-8ffd4337ae59
💛 - Coveralls |
We should probably add |
@kamilmysliwiec shall I add them as part of this same PR? |
@andreialecu sounds good! |
Added. |
It seems that nest/packages/common/pipes/validation.pipe.ts Lines 63 to 68 in 85c6be1
Originally reported at: nestjs/nest-cli#555 (comment) Probably everything else that comes up in other calls to |
It might worth it to explore whether this eslint rule can be implemented: |
Would you like to do it in this PR? |
07358a6
to
3382890
Compare
@kamilmysliwiec done. I used There are still a bunch of warnings left, but they're internal to the project (dev dependencies, etc) so I didn't mess with those (since they won't affect end users of packages). They can be fixed as part of a subsequent PR. |
3382890
to
cc9a912
Compare
@kamilmysliwiec just some further info: All recent package managers support optional peer dependencies using the npm as of: npm/cli#224 |
@@ -22,6 +22,7 @@ | |||
"peerDependencies": { | |||
"@nestjs/common": "^7.0.0", | |||
"@nestjs/core": "^7.0.0", | |||
"rxjs": "^6.0.0" | |||
"rxjs": "^6.0.0", | |||
"reflect-metadata": "^0.1.12" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is actually not optional, see:
nest/packages/websockets/index.ts
Line 7 in 8e216b2
import 'reflect-metadata'; |
@@ -26,8 +26,47 @@ | |||
"@nestjs/core": "7.4.4" | |||
}, | |||
"peerDependencies": { | |||
"reflect-metadata": "^0.1.12", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not optional, see:
nest/packages/microservices/index.ts
Line 7 in 8e216b2
import 'reflect-metadata'; |
Also relevant: moleculerjs/moleculer#623 (comment) |
@kamilmysliwiec is there anything holding this from being merged? There have been a bunch of support requests in the Yarn discord related to NestJS not working properly out of the box and this is among the last things needed. |
We use yarn berry with workspaces, but without the monorepo flag set in nest-cli. If using typescript compiler, it works even without that huge of a list of peer dependency overrides, but it becomes a massive problem with webpack flag set. Some peer dependencies that might be missing from this PR: "@nestjs/mapped-types@*":
peerDependenciesMeta:
"class-transformer":
optional: true
"class-validator":
optional: true
"@nestjs/serve-static@*":
peerDependenciesMeta:
"express":
optional: true
"@nestjs/swagger@*":
peerDependenciesMeta:
"swagger-ui-express":
optional: true |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
@nestjs/platform-express
is hardcoded as the default platform, and isrequire
d in various places in the code base. However, it is not an explicit dependency and thus package installers (yarn/npm/pnpm) need a hint on how to properly link them in order to be resolved.See:
nest/packages/core/nest-factory.ts
Lines 211 to 218 in 09fbc83
Without this change, Nest has problems running on stricter package managers (yarn with pnp, or pnpm)
What is the new behavior?
@nestjs/platform-express
is added as an optional dependency.peerDependenciesMeta
is supported by all major package managers: npm, yarn and pnpm.Does this PR introduce a breaking change?
Other information
See: https://yarnpkg.com/advanced/rulebook#packages-should-only-ever-require-what-they-formally-list-in-their-dependencies