Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4830

refactor aws import to import aws on demand

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 4.12.1
    • Affects Version/s: None
    • Component/s: None
    • Labels:
    • 2
    • Not Needed
    • Not Needed

      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.

            Assignee:
            bailey.pearson@mongodb.com Bailey Pearson
            Reporter:
            bailey.pearson@mongodb.com Bailey Pearson
            Daria Pardue
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: