Skip to content

Commit 6988982

Browse files
authored
Merge pull request #1 from disintegrator/cjs-support
chore: support esm + cjs
2 parents 2c45b9e + 5557d88 commit 6988982

File tree

4 files changed

+38
-11
lines changed

4 files changed

+38
-11
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,29 @@
1919
"dist"
2020
],
2121
"type": "module",
22-
"types": "./dist/index.d.ts",
23-
"module": "./dist/index.js",
22+
"types": "./dist/esm/index.d.ts",
23+
"module": "./dist/esm/index.js",
2424
"exports": {
2525
".": {
26-
"types": "./dist/index.d.ts",
27-
"import": "./dist/index.js"
26+
"import": {
27+
"types": "./dist/esm/index.d.ts",
28+
"default": "./dist/esm/index.js"
29+
},
30+
"require": {
31+
"types": "./dist/commonjs/index.d.ts",
32+
"default": "./dist/commonjs/index.js"
33+
}
2834
},
35+
"./package.json": "./package.json",
2936
"./parser": {
30-
"types": "./dist/parser/index.d.ts",
31-
"import": "./dist/parser/index.js"
37+
"import": {
38+
"types": "./dist/esm/parser/index.d.ts",
39+
"default": "./dist/esm/parser/index.js"
40+
},
41+
"require": {
42+
"types": "./dist/commonjs/parser/index.d.ts",
43+
"default": "./dist/commonjs/parser/index.js"
44+
}
3245
}
3346
},
3447
"sideEffects": false,
@@ -39,7 +52,9 @@
3952
"url": "https://github.com/P0lip/jsonpath-rfc9535"
4053
},
4154
"scripts": {
42-
"build": "tsc --outDir dist",
55+
"build:esm": "tsc --outDir dist/esm && echo '{\"type\":\"module\"}' > dist/esm/package.json",
56+
"build:cjs": "tsc --project tsconfig.cjs.json --outDir dist/commonjs && echo '{\"type\":\"commonjs\"}' > dist/commonjs/package.json",
57+
"build": "npm run build:esm && npm run build:cjs",
4358
"build.parser": "peggy src/parser/grammars/grammar.peggy --output src/parser/parser.js --format es --dts",
4459
"lint": "npx @biomejs/biome check",
4560
"type-check": "tsc --noEmit",
@@ -53,4 +68,4 @@
5368
"typescript": "^5.7.2"
5469
},
5570
"packageManager": "[email protected]+sha512.8ab88f10f224a0c614cb717a7f7c30499014f77134120e9c1f0211ea3cf3397592cbe483feb38e0c4b3be1c54e347292c76a1b5edb94a3289d5448484ab8ac81"
56-
}
71+
}

tsconfig.cjs.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "CommonJS",
5+
"moduleResolution": "node",
6+
"outDir": "./dist/commonjs",
7+
"verbatimModuleSyntax": false,
8+
"noEmitHelpers": false,
9+
"resolvePackageJsonExports": false,
10+
"resolvePackageJsonImports": false
11+
}
12+
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"allowJs": true,
1818
"declaration": true,
1919
"sourceMap": true,
20-
"outDir": "./dist",
20+
"outDir": "./dist/esm",
2121
"importHelpers": false,
2222
"noEmitHelpers": true,
2323
"noEmitOnError": true,

0 commit comments

Comments
 (0)