fix: compile @gsd/native to JS before publish

@gsd/native shipped raw .ts files in node_modules, which Node.js
refuses to import (ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING on
Node 22/24, ERR_UNKNOWN_FILE_EXTENSION on Node 20). Add tsc build
step, point exports at dist/, and add to bundleDependencies.

Closes #248

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lex Christopherson 2026-03-13 14:05:41 -06:00
parent d5b7ecb58c
commit e6be5ac03f
2 changed files with 27 additions and 24 deletions

View file

@ -40,7 +40,8 @@
"build:pi-ai": "npm run build -w @gsd/pi-ai",
"build:pi-agent-core": "npm run build -w @gsd/pi-agent-core",
"build:pi-coding-agent": "npm run build -w @gsd/pi-coding-agent",
"build:pi": "npm run build:pi-tui && npm run build:pi-ai && npm run build:pi-agent-core && npm run build:pi-coding-agent",
"build:native-pkg": "npm run build -w @gsd/native",
"build:pi": "npm run build:native-pkg && npm run build:pi-tui && npm run build:pi-ai && npm run build:pi-agent-core && npm run build:pi-coding-agent",
"build": "npm run build:pi && tsc && npm run copy-themes",
"copy-themes": "node -e \"const{mkdirSync,cpSync}=require('fs');const{resolve}=require('path');const src=resolve(__dirname,'packages/pi-coding-agent/dist/modes/interactive/theme');mkdirSync('pkg/dist/modes/interactive/theme',{recursive:true});cpSync(src,'pkg/dist/modes/interactive/theme',{recursive:true})\"",
"test": "node --import ./src/resources/extensions/gsd/tests/resolve-ts.mjs --experimental-strip-types --test src/resources/extensions/gsd/tests/*.test.ts src/resources/extensions/gsd/tests/*.test.mjs src/tests/*.test.ts",
@ -67,6 +68,7 @@
"sharp": "^0.34.5"
},
"bundleDependencies": [
"@gsd/native",
"@gsd/pi-agent-core",
"@gsd/pi-ai",
"@gsd/pi-coding-agent",

View file

@ -3,57 +3,58 @@
"version": "0.1.0",
"description": "Native Rust bindings for GSD \u2014 high-performance native modules via N-API",
"type": "module",
"main": "./src/index.ts",
"types": "./src/index.ts",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "tsc -p tsconfig.json",
"build:native": "node ../../native/scripts/build.js",
"build:native:dev": "node ../../native/scripts/build.js --dev",
"test": "node --test src/__tests__/grep.test.mjs src/__tests__/ps.test.mjs src/__tests__/glob.test.mjs src/__tests__/clipboard.test.mjs src/__tests__/highlight.test.mjs src/__tests__/html.test.mjs src/__tests__/text.test.mjs src/__tests__/fd.test.mjs src/__tests__/image.test.mjs"
},
"exports": {
".": {
"types": "./src/index.ts",
"import": "./src/index.ts"
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./grep": {
"types": "./src/grep/index.ts",
"import": "./src/grep/index.ts"
"types": "./dist/grep/index.d.ts",
"import": "./dist/grep/index.js"
},
"./ps": {
"types": "./src/ps/index.ts",
"import": "./src/ps/index.ts"
"types": "./dist/ps/index.d.ts",
"import": "./dist/ps/index.js"
},
"./glob": {
"types": "./src/glob/index.ts",
"import": "./src/glob/index.ts"
"types": "./dist/glob/index.d.ts",
"import": "./dist/glob/index.js"
},
"./clipboard": {
"types": "./src/clipboard/index.ts",
"import": "./src/clipboard/index.ts"
"types": "./dist/clipboard/index.d.ts",
"import": "./dist/clipboard/index.js"
},
"./ast": {
"types": "./src/ast/index.ts",
"import": "./src/ast/index.ts"
"types": "./dist/ast/index.d.ts",
"import": "./dist/ast/index.js"
},
"./html": {
"types": "./src/html/index.ts",
"import": "./src/html/index.ts"
"types": "./dist/html/index.d.ts",
"import": "./dist/html/index.js"
},
"./text": {
"types": "./src/text/index.ts",
"import": "./src/text/index.ts"
"types": "./dist/text/index.d.ts",
"import": "./dist/text/index.js"
},
"./fd": {
"types": "./src/fd/index.ts",
"import": "./src/fd/index.ts"
"types": "./dist/fd/index.d.ts",
"import": "./dist/fd/index.js"
},
"./image": {
"types": "./src/image/index.ts",
"import": "./src/image/index.ts"
"types": "./dist/image/index.d.ts",
"import": "./dist/image/index.js"
}
},
"files": [
"src"
"dist"
],
"license": "MIT"
}