Skip to content

Commit 6720773

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

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

packages/pg/lib/index.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ 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+
var PG = function (exports, clientConstructor) {
18+
exports.defaults = defaults
19+
exports.Client = clientConstructor
20+
exports.Query = exports.Client.Query
21+
exports.Pool = poolFactory(exports.Client)
22+
exports._pools = []
23+
exports.Connection = Connection
24+
exports.types = require('pg-types')
25+
exports.DatabaseError = DatabaseError
2626
}
2727

2828
if (typeof process.env.NODE_PG_FORCE_NATIVE !== 'undefined') {
29-
module.exports = new PG(require('./native'))
29+
PG(module.exports, require('./native'))
3030
} else {
31-
module.exports = new PG(Client)
31+
PG(module.exports, Client)
3232

3333
// lazy require native module...the native module may not have installed
3434
Object.defineProperty(module.exports, 'native', {
3535
configurable: true,
3636
enumerable: false,
3737
get() {
38-
var native = null
38+
var native = {}
3939
try {
40-
native = new PG(require('./native'))
40+
PG(native, require('./native'))
4141
} catch (err) {
4242
if (err.code !== 'MODULE_NOT_FOUND') {
4343
throw err

0 commit comments

Comments
 (0)