diff --git a/docs/guide/installation-guide.txt b/docs/guide/installation-guide.txt index 4f2ce77df1..2629ae5963 100644 --- a/docs/guide/installation-guide.txt +++ b/docs/guide/installation-guide.txt @@ -21,7 +21,6 @@ Troubleshooting The MongoDB driver depends on several other packages, including: * `bson `_ -* `require_optional `_ * `safe-buffer `_ * `saslprep `_ diff --git a/lib/core/connection/utils.js b/lib/core/connection/utils.js index 2f3d889f43..d6e2d9da2a 100644 --- a/lib/core/connection/utils.js +++ b/lib/core/connection/utils.js @@ -1,7 +1,5 @@ 'use strict'; -const require_optional = require('require_optional'); - function debugOptions(debugFields, options) { var finaloptions = {}; debugFields.forEach(function(n) { @@ -16,7 +14,7 @@ function retrieveBSON() { BSON.native = false; try { - var optionalBSON = require_optional('bson-ext'); + var optionalBSON = require('bson-ext'); if (optionalBSON) { optionalBSON.native = true; return optionalBSON; @@ -37,7 +35,7 @@ function noSnappyWarning() { function retrieveSnappy() { var snappy = null; try { - snappy = require_optional('snappy'); + snappy = require('snappy'); } catch (error) {} // eslint-disable-line if (!snappy) { snappy = { diff --git a/lib/core/index.js b/lib/core/index.js index 28aca32e9c..a462b3d202 100644 --- a/lib/core/index.js +++ b/lib/core/index.js @@ -1,12 +1,11 @@ 'use strict'; let BSON = require('bson'); -const require_optional = require('require_optional'); const EJSON = require('./utils').retrieveEJSON(); try { // Attempt to grab the native BSON parser - const BSONNative = require_optional('bson-ext'); + const BSONNative = require('bson-ext'); // If we got the native parser, use it instead of the // Javascript one if (BSONNative) { diff --git a/lib/core/utils.js b/lib/core/utils.js index 6043a51297..bbf04dbd30 100644 --- a/lib/core/utils.js +++ b/lib/core/utils.js @@ -1,7 +1,6 @@ 'use strict'; const os = require('os'); const crypto = require('crypto'); -const requireOptional = require('require_optional'); /** * Generate a UUIDv4 @@ -27,7 +26,7 @@ function retrieveKerberos() { let kerberos; try { - kerberos = requireOptional('kerberos'); + kerberos = require('kerberos'); } catch (err) { if (err.code === 'MODULE_NOT_FOUND') { throw new Error('The `kerberos` module was not found. Please install it and try again.'); @@ -48,7 +47,7 @@ const noEJSONError = function() { function retrieveEJSON() { let EJSON = null; try { - EJSON = requireOptional('mongodb-extjson'); + EJSON = require('mongodb-extjson'); } catch (error) {} // eslint-disable-line if (!EJSON) { EJSON = { diff --git a/package-lock.json b/package-lock.json index 716cf883e3..b4ac3d4899 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3062,27 +3062,6 @@ "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", "dev": true }, - "require_optional": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/require_optional/-/require_optional-1.0.1.tgz", - "integrity": "sha512-qhM/y57enGWHAe3v/NcwML6a3/vfESLe/sGM2dII+gEO0BpKRUkWZow/tyloNqJyN6kXSl3RyyM8Ll5D/sJP8g==", - "requires": { - "resolve-from": "^2.0.0", - "semver": "^5.1.0" - }, - "dependencies": { - "resolve-from": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-2.0.0.tgz", - "integrity": "sha1-lICrIOlP+h2egKgEx+oUdhGWa1c=" - }, - "semver": { - "version": "5.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", - "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" - } - } - }, "safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", diff --git a/package.json b/package.json index 52dde7b5a1..ee0236e406 100644 --- a/package.json +++ b/package.json @@ -16,18 +16,38 @@ "driver", "official" ], - "peerOptionalDependencies": { + "peerDependencies": { "kerberos": "^1.1.0", "mongodb-client-encryption": "^1.0.0", "mongodb-extjson": "^2.1.2", "snappy": "^6.3.4", - "bson-ext": "^2.0.0" + "bson-ext": "^2.0.0", + "aws4": "^1.10.1" + }, + "peerDependenciesMeta": { + "kerberos": { + "optional": true + }, + "mongodb-client-encryption": { + "optional": true + }, + "mongodb-extjson": { + "optional": true + }, + "snappy": { + "optional": true + }, + "bson-ext": { + "optional": true + }, + "aws4": { + "optional": true + } }, "dependencies": { "bl": "^2.2.1", "bson": "^1.1.4", "denque": "^1.4.1", - "require_optional": "^1.0.1", "safe-buffer": "^5.1.2" }, "devDependencies": {