Skip to content

Commit f8c9305

Browse files
committed
Making package compatible with ESM.
1 parent 8f0db30 commit f8c9305

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

packages/pg/lib/index.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,23 @@ const poolFactory = (Client) => {
1414
}
1515
}
1616

17-
var PG = function (clientConstructor) {
18-
this.defaults = defaults
19-
this.Client = clientConstructor
20-
this.Query = this.Client.Query
21-
this.Pool = poolFactory(this.Client)
22-
this._pools = []
23-
this.Connection = Connection
24-
this.types = require('pg-types')
25-
this.DatabaseError = DatabaseError
17+
module.exports = {
18+
defaults: defaults,
19+
_pools: [],
20+
Connection: Connection,
21+
types: require('pg-types'),
22+
DatabaseError: DatabaseError,
2623
}
2724

2825
if (typeof process.env.NODE_PG_FORCE_NATIVE !== 'undefined') {
29-
module.exports = new PG(require('./native'))
26+
var nativeClient = require('./native')
27+
module.exports.Client = nativeClient
28+
module.exports.Query = nativeClient.Query
29+
module.exports.Pool = poolFactory(nativeClient)
3030
} else {
31-
module.exports = new PG(Client)
31+
module.exports.Client = Client
32+
module.exports.Query = Client.Query
33+
module.exports.Pool = poolFactory(Client)
3234

3335
// lazy require native module...the native module may not have installed
3436
Object.defineProperty(module.exports, 'native', {

0 commit comments

Comments
 (0)