Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
remove dynamic import statements
Browse files Browse the repository at this point in the history
Importing from paths generated at runtime breaks
parcel, see (parcel-bundler/parcel#4031), or
esbuild, see (evanw/esbuild#480)
By removing the calls to the deprecated global MONGOOSE_DRIVER_PATH this
issue can be resolved.
  • Loading branch information
raphaelschwinger authored Feb 15, 2021
1 parent aef25e0 commit f7baa33
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,7 @@
* Module dependencies.
*/

if (global.MONGOOSE_DRIVER_PATH) {
const deprecationWarning = 'The `MONGOOSE_DRIVER_PATH` global property is ' +
'deprecated. Use `mongoose.driver.set()` instead.';
const setDriver = require('util').deprecate(function() {
require('./driver').set(require(global.MONGOOSE_DRIVER_PATH));
}, deprecationWarning);
setDriver();
} else {
require('./driver').set(require('./drivers/node-mongodb-native'));
}
require('./driver').set(require('./drivers/node-mongodb-native'));

const Document = require('./document');
const Schema = require('./schema');
Expand Down Expand Up @@ -732,19 +723,17 @@ Mongoose.prototype.connections;
* Driver dependent APIs
*/

const driver = global.MONGOOSE_DRIVER_PATH || './drivers/node-mongodb-native';

/*!
* Connection
*/

const Connection = require(driver + '/connection');
const Connection = require('./drivers/node-mongodb-native/connection');

/*!
* Collection
*/

const Collection = require(driver + '/collection');
const Collection = require('./drivers/node-mongodb-native/collection');

/**
* The Mongoose Aggregate constructor
Expand Down

0 comments on commit f7baa33

Please sign in to comment.