Skip to content

Commit ce22030

Browse files
committed
fix: emit TypeScript declarations alongside bundled JS
Add tsconfig.build.json that emits only declaration files into dist/, so TypeScript consumers retain type information after the switch from source to bundled JS entry points. - Add tsconfig.build.json with emitDeclarationOnly + rootDir: ./src - Update build script to run tsc -p tsconfig.build.json after bundling - Add types field to package.json exports and top-level - Include .d.ts condition in export map for both . and ./server Addresses CodeRabbit review comment on PR #36
1 parent 37a86e8 commit ce22030

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,14 @@
2929
"eslint-plugin-jsdoc": "^50.6.11"
3030
},
3131
"exports": {
32-
".": "./dist/index.js",
33-
"./server": "./dist/index.js"
32+
".": {
33+
"types": "./dist/index.d.ts",
34+
"default": "./dist/index.js"
35+
},
36+
"./server": {
37+
"types": "./dist/index.d.ts",
38+
"default": "./dist/index.js"
39+
}
3440
},
3541
"files": [
3642
"dist/"
@@ -47,6 +53,7 @@
4753
"license": "MPL-2.0",
4854
"main": "dist/index.js",
4955
"module": "dist/index.js",
56+
"types": "dist/index.d.ts",
5057
"name": "@devtheops/opencode-plugin-otel",
5158
"oc-plugin": [
5259
"server"
@@ -59,7 +66,7 @@
5966
"url": "https://github.com/DEVtheOPS/opencode-plugin-otel.git"
6067
},
6168
"scripts": {
62-
"build": "bun build src/index.ts --outdir=./dist --target=node",
69+
"build": "bun build src/index.ts --outdir=./dist --target=node && tsc -p tsconfig.build.json",
6370
"check:jsdoc-coverage": "bun scripts/check-jsdoc-coverage.mjs",
6471
"lint": "bun --bun eslint .",
6572
"typecheck": "tsc --noEmit",

tsconfig.build.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+
"noEmit": false,
5+
"declaration": true,
6+
"emitDeclarationOnly": true,
7+
"outDir": "./dist",
8+
"rootDir": "./src"
9+
},
10+
"include": ["src"],
11+
"exclude": ["eslint.config.mjs", "dist", "scripts", "tests"]
12+
}

0 commit comments

Comments
 (0)