Skip to content

Commit 9d5aeaf

Browse files
committed
wip
1 parent 555fef2 commit 9d5aeaf

File tree

4 files changed

+33
-8
lines changed

4 files changed

+33
-8
lines changed

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@
3030
"types": "./build/types/index.d.ts",
3131
"exports": {
3232
".": {
33-
"require": "./build/cjs/index.js",
34-
"import": "./build/esm/index.mjs"
33+
"types": "./build/types/nodeJavaBridge.d.ts",
34+
"require": "./build/cjs/nodeJavaBridge.js",
35+
"import": "./build/esm/nodeJavaBridge.js",
36+
"default": "./build/esm/nodeJavaBridge.js"
3537
}
3638
},
3739
"files": [
@@ -56,9 +58,8 @@
5658
"when": "3.7.8"
5759
},
5860
"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",
61+
"compile": "tsc -b ./tsconfig.cjs.json ./tsconfig.esm.json ./tsconfig.types.json",
62+
"build": "npm run compile && node ./scripts/fix-tsc-build.js",
6263
"install": "node-gyp rebuild",
6364
"clean": "rm -rf build",
6465
"test": "node ./scripts/testRunner.js",

scripts/fix-tsc-build.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const fs = require("node:fs");
2+
const path = require("node:path");
3+
4+
const buildDir = path.join(__dirname, "..", "build", "esm");
5+
function createEsmModulePackageJson() {
6+
const packageJsonFile = path.join(buildDir, "/package.json");
7+
fs.writeFileSync(
8+
packageJsonFile,
9+
new Uint8Array(Buffer.from('{"type": "module"}')),
10+
function (err) {
11+
if (err) {
12+
throw err;
13+
}
14+
}
15+
);
16+
}
17+
18+
createEsmModulePackageJson();

tsconfig.base.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
"lib": [
44
"esnext"
55
],
6-
"declaration": true,
7-
"declarationDir": "./build/types",
86
"strict": true,
97
"esModuleInterop": false,
108
"skipLibCheck": true,
119
"forceConsistentCasingInFileNames": true,
1210
"moduleResolution": "node",
1311
"baseUrl": ".",
14-
"rootDir": "./src"
12+
"rootDir": "./src-node"
1513
},
1614
"include": [
1715
"src-node"

tsconfig.types.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+
"outDir": "./build/types",
5+
"declaration": true,
6+
"emitDeclarationOnly": true
7+
}
8+
}

0 commit comments

Comments
 (0)