Skip to content

Commit d372eeb

Browse files
committed
feat: dual-publish ESM and CJS
1 parent c613630 commit d372eeb

File tree

3 files changed

+892
-66
lines changed

3 files changed

+892
-66
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/lib/
1+
/dist/
22
node_modules
33
prebuilds
44
test/postgres_regress/**/*.test.ts

package.json

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
{
22
"name": "@pg-nano/pg-parser",
3-
"type": "module",
43
"version": "16.1.4",
54
"sideEffects": false,
65
"description": "Node.js addon for PostgreSQL query parsing",
76
"license": "MIT",
8-
"main": "lib/index.js",
7+
"main": "./dist/index.js",
8+
"module": "./dist/index.mjs",
99
"exports": {
1010
".": {
11-
"types": "./lib/index.d.ts",
12-
"default": "./lib/index.js"
11+
"types": "./dist/index.d.ts",
12+
"require": "./dist/index.js",
13+
"import": "./dist/index.mjs"
1314
},
1415
"./ast": {
15-
"types": "./lib/ast.d.ts",
16-
"default": "./lib/ast.js"
16+
"types": "./dist/ast.d.ts",
17+
"require": "./dist/ast.js",
18+
"import": "./dist/ast.mjs"
1719
}
1820
},
1921
"repository": {
@@ -22,10 +24,10 @@
2224
},
2325
"scripts": {
2426
"dev": "tinyrun --names js,gyp 'pnpm -s dev:js' 'pnpm -s dev:gyp'",
25-
"dev:js": "rimraf lib && tsc -p . --watch --preserveWatchOutput",
27+
"dev:js": "npm run build -- --watch src/lib",
2628
"dev:gyp": "watchlist src --eager --no-clear -- pnpm -s build:gyp",
2729
"build": "tinyrun --names js,gyp 'pnpm -s build:js' 'pnpm -s build:gyp'",
28-
"build:js": "rimraf lib && tsc -p .",
30+
"build:js": "tsup src/lib --format cjs,esm --dts --clean --no-splitting",
2931
"build:gyp": "node-gyp rebuild && pnpm --no-bail prepare:clangd",
3032
"prepare:clangd": "cd build && compiledb make -f binding.Makefile -n || true",
3133
"prepare:types": "pnpm -s dlx tsx scripts/inferFieldMetadata.ts && pnpm -s dlx tsx scripts/generateTypes.ts && pnpm -s format",
@@ -56,13 +58,13 @@
5658
"node-gyp": "^10.0.1",
5759
"prebuild": "^13.0.1",
5860
"prettier": "^3.3.3",
59-
"rimraf": "^6.0.1",
6061
"tinyrun": "^1.0.1",
62+
"tsup": "^8.3.0",
6163
"typescript": "^5.5.4",
6264
"watchlist": "npm:@aleclarson/watchlist@^0.3.3"
6365
},
6466
"files": [
65-
"lib"
67+
"dist"
6668
],
6769
"engines": {
6870
"node": ">=16"

0 commit comments

Comments
 (0)