Closed carrolp closed 2 years ago
@carrolp Thanks for reporting this issue.
I'll mark v2.1.1
as deprecated because it introduces this unexpected breaking change.
I'll double check if there is some way to keep the same logic without relying on mongoose.Schema.Types.Subdocument
.
v2.1.2
with that implemented, and introduce automated tests with mongoose@5
.v3.0.0
with the current code and bump mongoose
peer dependency.Any help is appreciated, if you want to contribute with a pull request.
Describe the bug
This change introduces a dependency on
mongoose.Schema.Types.Subdocument
, butSubdocument
is not added tomongoose.Schema.Types
until Mongoose v6. Butmongoose-lean-defaults
still states that its peerDependency is mongoose >=5.As a result, when used with mongoose v5, an error like this will occur:
Mongoose 5.13.14: https://github.com/Automattic/mongoose/blob/5.13.14/lib/schema/index.js (no Subdocument) Mongoose 6.0.0: https://github.com/Automattic/mongoose/blob/6.0.0/lib/schema/index.js#L16 (has Subdocument)
If the dependency on
Subdocument
being defined is necessary, then I would think the peerDependency needs to be updated tomongoose >=6
. As that would be a breaking change (no longer compatible with v5), themongoose-leand-defaults
version should be bumped to 3.0.0 instead of 2.1.x.We are updating our project to explicitly depend on
mongoose-lean-defaults
at version2.1.0
(not^2.1.0
) to avoid this breakage for now.To Reproduce
Steps to reproduce the behavior:
mongoose-lean-defaults
with a project using Mongoose v5Expected behavior
mongoose-lean-defaults
2.x should continue to support Mongoose v5Additional context
Mongoose version: 5.13.14 Node version: 14, 16