Skip to content

Commit 555fef2

Browse files
committed
switch to typescript
1 parent 9b68dc6 commit 555fef2

File tree

7 files changed

+91
-4
lines changed

7 files changed

+91
-4
lines changed

index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

package-lock.json

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

package.json

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@
2525
"type": "git",
2626
"url": "https://github.com/joeferner/node-java.git"
2727
},
28+
"main": "./build/cjs/index.js",
29+
"module": "./build/esm/index.mjs",
30+
"types": "./build/types/index.d.ts",
31+
"exports": {
32+
".": {
33+
"require": "./build/cjs/index.js",
34+
"import": "./build/esm/index.mjs"
35+
}
36+
},
37+
"files": [
38+
"build"
39+
],
2840
"dependencies": {
2941
"async": "^3.2.6",
3042
"find-java-home": "^2.0.0",
@@ -34,14 +46,19 @@
3446
},
3547
"devDependencies": {
3648
"@eslint/js": "^9.27.0",
49+
"@types/node": "^22.15.21",
3750
"chalk": "2.4.2",
3851
"eslint": "^9.27.0",
3952
"globals": "^16.1.0",
4053
"prettier": "^3.5.3",
54+
"typescript": "^5.8.3",
4155
"vitest": "^3.1.3",
4256
"when": "3.7.8"
4357
},
4458
"scripts": {
59+
"build:cjs": "tsc -p tsconfig.cjs.json",
60+
"build:esm": "tsc -p tsconfig.esm.json",
61+
"build": "npm run build:cjs && npm run build:esm",
4562
"install": "node-gyp rebuild",
4663
"clean": "rm -rf build",
4764
"test": "node ./scripts/testRunner.js",
@@ -50,6 +67,5 @@
5067
"format": "prettier --write .",
5168
"format-cpp": "clang-format --version; find src-cpp/ -iname '*.h' -o -iname '*.cpp' | xargs clang-format -i",
5269
"precommit": "npm run format-cpp && npm run format && npm run lint && npm test"
53-
},
54-
"main": "./index.js"
55-
}
70+
}
71+
}

tsconfig.base.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"lib": [
4+
"esnext"
5+
],
6+
"declaration": true,
7+
"declarationDir": "./build/types",
8+
"strict": true,
9+
"esModuleInterop": false,
10+
"skipLibCheck": true,
11+
"forceConsistentCasingInFileNames": true,
12+
"moduleResolution": "node",
13+
"baseUrl": ".",
14+
"rootDir": "./src"
15+
},
16+
"include": [
17+
"src-node"
18+
],
19+
"exclude": [
20+
"build",
21+
"node_modules"
22+
]
23+
}

tsconfig.cjs.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "commonjs",
5+
"outDir": "./build/cjs",
6+
"target": "ES2015"
7+
}
8+
}

tsconfig.esm.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.base.json",
3+
"compilerOptions": {
4+
"module": "esnext",
5+
"outDir": "./build/esm",
6+
"target": "esnext"
7+
}
8+
}

0 commit comments

Comments
 (0)