Skip to content

Commit 5a2b486

Browse files
author
JosXa
committed
Ship pre-compiled JS to avoid Bun transpilation cost on install
1 parent 3720bcb commit 5a2b486

3 files changed

Lines changed: 39 additions & 14 deletions

File tree

package.json

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"name": "opencode-pty",
3-
"module": "index.ts",
3+
"main": "dist/index.js",
4+
"types": "dist/index.d.ts",
5+
"module": "dist/index.js",
46
"version": "0.2.3",
57
"description": "OpenCode plugin for interactive PTY management - run background processes, send input, read output with regex filtering",
68
"author": "shekohex",
@@ -26,27 +28,33 @@
2628
},
2729
"homepage": "https://github.com/shekohex/opencode-pty#readme",
2830
"files": [
29-
"index.ts",
30-
"src",
3131
"dist"
3232
],
3333
"license": "MIT",
3434
"type": "module",
3535
"exports": {
36-
"./*": "./src/*.ts",
37-
"./*/*": "./src/*/*.ts",
38-
"./*/*/*": "./src/*/*/*.ts",
39-
"./*/*/*/*": "./src/*/*/*/*.ts",
40-
"./*/*/*/*/*": "./src/*/*/*/*/*.ts"
36+
".": {
37+
"types": "./dist/index.d.ts",
38+
"default": "./dist/index.js"
39+
},
40+
"./*": {
41+
"types": "./dist/src/*.d.ts",
42+
"default": "./dist/src/*.js"
43+
},
44+
"./*/*": {
45+
"types": "./dist/src/*/*.d.ts",
46+
"default": "./dist/src/*/*.js"
47+
}
4148
},
4249
"scripts": {
4350
"typecheck": "tsc --noEmit",
4451
"unittest": "bun test",
4552
"test:e2e": "PW_DISABLE_TS_ESM=1 NODE_ENV=test bun --bun playwright test",
4653
"test:all": "bun unittest && bun test:e2e",
47-
"build:dev": "bun clean && vite build --mode development",
48-
"build:prod": "bun clean && vite build --mode production",
49-
"prepack": "bun build:prod",
54+
"build:plugin": "tsc -p tsconfig.build.json && bun x copyfiles -u 0 \"src/**/*.txt\" dist",
55+
"build:dev": "bun clean && bun build:plugin && vite build --mode development",
56+
"build:prod": "bun clean && bun build:plugin && vite build --mode production",
57+
"prepublishOnly": "bun build:prod",
5058
"clean": "rm -rf dist playwright-report test-results",
5159
"lint": "biome lint .",
5260
"lint:fix": "biome lint --write .",

src/web/server/handlers/static.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { resolve } from 'node:path'
21
import { readdirSync, statSync } from 'node:fs'
3-
import { join, extname } from 'node:path'
2+
import { extname, join, resolve } from 'node:path'
43
import { ASSET_CONTENT_TYPES } from '../../shared/constants.ts'
54

65
// ----- MODULE-SCOPE CONSTANTS -----
7-
const PROJECT_ROOT = resolve(import.meta.dir, '../../../..')
6+
// Resolve project root regardless of whether we're running from source or dist/
7+
const MODULE_DIR = resolve(import.meta.dir, '../../../..')
8+
const PROJECT_ROOT = MODULE_DIR.replace(/[\\/]dist$/, '')
89
const SECURITY_HEADERS = {
910
'X-Content-Type-Options': 'nosniff',
1011
'X-Frame-Options': 'DENY',

tsconfig.build.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "https://json.schemastore.org/tsconfig",
3+
"extends": "./tsconfig.json",
4+
"compilerOptions": {
5+
"noEmit": false,
6+
"rootDir": ".",
7+
"outDir": "dist",
8+
"declaration": true,
9+
"declarationMap": true,
10+
"sourceMap": true,
11+
"allowImportingTsExtensions": false,
12+
"rewriteRelativeImportExtensions": true
13+
},
14+
"include": ["index.ts", "src/**/*.ts"],
15+
"exclude": ["src/web/client/**", "**/*.test.ts", "**/*.spec.ts"]
16+
}

0 commit comments

Comments
 (0)