Skip to content

Commit 6b52ba9

Browse files
committed
sdk dist: Create index.d.ts files that are colocated with bundle index.js
1 parent 051119b commit 6b52ba9

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

sdk/build.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,27 @@ async function build() {
7373
console.log('📂 Copying WASM files for tree-sitter...')
7474
await copyWasmFiles()
7575

76+
console.log('📝 Creating colocated declaration files...')
77+
await createColocatedDeclarations()
78+
7679
console.log('✅ Build complete!')
7780
}
7881

82+
/**
83+
* Create colocated declaration files for better TypeScript compatibility
84+
*/
85+
async function createColocatedDeclarations() {
86+
// Create colocated ESM declaration file
87+
const esmDeclaration = 'export * from "./sdk/src/index";\n'
88+
await Bun.write('dist/esm/index.d.ts', esmDeclaration)
89+
console.log(' ✓ Created dist/esm/index.d.ts')
90+
91+
// Create colocated CJS declaration file for extra compatibility
92+
const cjsDeclaration = 'export * from "../esm/index";\n'
93+
await Bun.write('dist/cjs/index.d.ts', cjsDeclaration)
94+
console.log(' ✓ Created dist/cjs/index.d.ts')
95+
}
96+
7997
/**
8098
* Copy WASM files from @vscode/tree-sitter-wasm to shared dist/wasm directory
8199
*/

sdk/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
"type": "module",
99
"main": "./dist/cjs/index.js",
1010
"module": "./dist/esm/index.js",
11-
"types": "./dist/esm/sdk/src/index.d.ts",
11+
"types": "./dist/esm/index.d.ts",
12+
"typings": "./dist/esm/index.d.ts",
1213
"exports": {
1314
".": {
14-
"types": "./dist/esm/sdk/src/index.d.ts",
15+
"types": "./dist/esm/index.d.ts",
1516
"import": "./dist/esm/index.js",
1617
"require": "./dist/cjs/index.js",
1718
"default": "./dist/esm/index.js"

0 commit comments

Comments
 (0)