-
Type: Improvement
-
Resolution: Fixed
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
The Node driver's current optional dependency import pattern attempts to import all optional dependencies when the dependency module (`deps.ts`) is initialized. This patterns is based on the assumption that only optional dependencies that the user wants are installed because the user manually installed the optional dependency.
Version 4.11.0 of the driver introduced the aws sdk as an npm optional dependency. npm optional dependencies are installed by default. As a result, by default the driver will install and import the aws sdk even if the user is not using aws authentication.
The optional dependency import should be lazy and we should only actually import the module when aws authentication is used.
A POC is available here - https://github.com/mongodb/node-mongodb-native/tree/test-optional-dependency. But we may want to consider formalizing our optional dependency approach (perhaps something similar to the PromiseProvider - DependencyProvider perhaps?) since we plan to add more optional dependencies.
An alternate approach is to remove the aws sdk from the "optionalDependencies" in the package.json but that approach would depend on the outcome of NODE-4829.
Acceptance Criteria
- The AWS sdk is only imported into the Node runtime when configured by the user.