Skip to content

Commit 98bc876

Browse files
committed
build: add esm exports
1 parent 477f812 commit 98bc876

17 files changed

Lines changed: 147 additions & 9 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// ESM wrapper for pg-cloudflare
2+
import module from '../dist/empty.js';
3+
4+
// Re-export any named exports and the default
5+
export const CloudflareSocket = module.CloudflareSocket;
6+
export default module;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// ESM wrapper for pg-cloudflare in Cloudflare Workers
2+
import module from '../dist/index.js';
3+
4+
// Re-export CloudflareSocket and the default
5+
export const CloudflareSocket = module.CloudflareSocket;
6+
export default module;

packages/pg-cloudflare/package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@
1010
"typescript": "^4.0.3"
1111
},
1212
"exports": {
13-
"workerd": "./dist/index.js",
14-
"default": "./dist/empty.js"
13+
".": {
14+
"import": "./esm/index.js",
15+
"require": "./dist/empty.js",
16+
"types": "./dist/index.d.ts"
17+
},
18+
"./worker": {
19+
"import": "./esm/worker.js",
20+
"require": "./dist/index.js"
21+
}
1522
},
1623
"scripts": {
1724
"build": "tsc",
@@ -26,6 +33,7 @@
2633
},
2734
"files": [
2835
"/dist/*{js,ts,map}",
29-
"/src"
36+
"/src",
37+
"/esm"
3038
]
3139
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// ESM wrapper for pg-connection-string
2+
import connectionString from '../index.js';
3+
4+
// Re-export the parse function
5+
export const parse = connectionString.parse;
6+
7+
// Re-export the default
8+
export default connectionString;

packages/pg-connection-string/package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
"description": "Functions for dealing with a PostgresSQL connection string",
55
"main": "./index.js",
66
"types": "./index.d.ts",
7+
"exports": {
8+
".": {
9+
"import": "./esm/index.js",
10+
"require": "./index.js",
11+
"types": "./index.d.ts"
12+
}
13+
},
714
"scripts": {
815
"test": "istanbul cover _mocha && npm run check-coverage",
916
"check-coverage": "istanbul check-coverage --statements 100 --branches 100 --lines 100 --functions 100",
@@ -34,6 +41,7 @@
3441
},
3542
"files": [
3643
"index.js",
37-
"index.d.ts"
44+
"index.d.ts",
45+
"esm"
3846
]
3947
}

packages/pg-cursor/esm/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// ESM wrapper for pg-cursor
2+
import Cursor from '../index.js';
3+
4+
// Export as default only to match CJS module
5+
export default Cursor;

packages/pg-cursor/package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
"version": "2.13.1",
44
"description": "Query cursor extension for node-postgres",
55
"main": "index.js",
6+
"exports": {
7+
".": {
8+
"import": "./esm/index.js",
9+
"require": "./index.js"
10+
}
11+
},
612
"directories": {
713
"test": "test"
814
},
@@ -22,5 +28,9 @@
2228
},
2329
"peerDependencies": {
2430
"pg": "^8"
25-
}
31+
},
32+
"files": [
33+
"index.js",
34+
"esm"
35+
]
2636
}

packages/pg-native/esm/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// ESM wrapper for pg-native
2+
import Client from '../index.js';
3+
4+
// Export as default only to match CJS module
5+
export default Client;

packages/pg-native/package.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
"version": "3.3.0",
44
"description": "A slightly nicer interface to Postgres over node-libpq",
55
"main": "index.js",
6+
"exports": {
7+
".": {
8+
"import": "./esm/index.js",
9+
"require": "./index.js"
10+
}
11+
},
612
"scripts": {
713
"test": "mocha"
814
},
@@ -34,5 +40,9 @@
3440
"node-gyp": ">=10.x",
3541
"okay": "^0.3.0",
3642
"semver": "^4.1.0"
37-
}
43+
},
44+
"files": [
45+
"index.js",
46+
"esm"
47+
]
3848
}

packages/pg-pool/esm/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// ESM wrapper for pg-pool
2+
import Pool from '../index.js';
3+
4+
// Export as default only to match CJS module
5+
export default Pool;

0 commit comments

Comments
 (0)