-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.6.6
-
Component/s: None
-
Empty show more show less
-
Not Needed
Release of `mongodb@3.6.6` in NPM included a change from `require_optional` to `optional-require`. These two packages take different approaches to optional `require`s: `require_optional` checks for explicit `peerOptionalDependencies`, while `optional-require` tries to `require` and ignores certain error messages. With Yarn v2 PnP, the "Module Not Found" error message is atypical, so `optional-require` does not ignore it; as a result, `requireOptional('mongodb-extjson')` (for example) throws an error when it is not installed in the application. This is a breaking change from `mongodb@3.6.5`.
I have opened a pull request for `optional-require` to add support for Yarn v2 PnP. Once that PR is accepted, there should be no action required for `mongodb`, besides optionally upgrading the dependency on `optional-require`. Alternatively, `mongodb` could re-introduce the `try-catch` blocks around `requireOptional` that were removed in `mongodb@3.6.6`.