Skip to content

Commit 43f8b96

Browse files
authored
chore(tabby-chat-panel): add build script output for browser. (#4058)
* chore(tabby-chat-panel): add build script output for browser. * chore: update pnpm-lock. * fix(tabby-chat-panel): fix build script. * chore: update pnpm-lock.
1 parent a4fcaa9 commit 43f8b96

File tree

4 files changed

+1096
-571
lines changed

4 files changed

+1096
-571
lines changed

clients/tabby-chat-panel/package.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@
3131
"dist"
3232
],
3333
"scripts": {
34-
"build": "unbuild",
34+
"build": "pnpm build:unbuild & pnpm build:rollup",
35+
"build:unbuild": "unbuild",
36+
"build:rollup": "rollup -c rollup.config.js",
3537
"dev": "unbuild --stub",
3638
"lint": "eslint .",
3739
"lint:fix": "eslint . --fix",
@@ -51,6 +53,10 @@
5153
"devDependencies": {
5254
"@antfu/eslint-config": "^2.16.0",
5355
"@antfu/ni": "^0.21.12",
56+
"@rollup/plugin-commonjs": "^28.0.3",
57+
"@rollup/plugin-node-resolve": "^16.0.0",
58+
"@rollup/plugin-terser": "^0.4.4",
59+
"@rollup/plugin-typescript": "^12.1.1",
5460
"@types/node": "^20.12.7",
5561
"@types/react": "18.2.23",
5662
"@types/semver": "^7.5.8",
@@ -59,6 +65,7 @@
5965
"eslint-formatter-mo": "^1.2.0",
6066
"lint-staged": "^15.2.2",
6167
"rimraf": "^5.0.5",
68+
"rollup": "^4.27.3",
6269
"tsx": "^4.7.3",
6370
"typescript": "^5.4.5",
6471
"unbuild": "^2.0.0",
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import typescript from '@rollup/plugin-typescript'
2+
import commonjs from '@rollup/plugin-commonjs'
3+
import resolve from '@rollup/plugin-node-resolve'
4+
import terser from '@rollup/plugin-terser'
5+
import { defineConfig } from 'rollup'
6+
7+
export default defineConfig([{
8+
input: 'src/browser.ts',
9+
output: {
10+
dir: 'dist',
11+
format: 'iife',
12+
entryFileNames: 'iife/tabby-chat-panel.min.js',
13+
name: 'TabbyChatPanel',
14+
},
15+
treeshake: true,
16+
plugins: [
17+
resolve({
18+
browser: true,
19+
}),
20+
commonjs(),
21+
terser(),
22+
typescript({
23+
tsconfig: './tsconfig.json',
24+
noEmitOnError: true,
25+
}),
26+
],
27+
}])
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { createThreadFromIframe } from 'tabby-threads'
2+
import { createClient as createClientFromThread } from './thread'
3+
import type { ClientApi } from './client'
4+
import type { ServerApi, ServerApiList } from './server'
5+
6+
export async function createClient(iframe: HTMLIFrameElement, api: ClientApi): Promise<ServerApiList> {
7+
const thread = createThreadFromIframe<ClientApi, ServerApi>(iframe, { expose: api })
8+
return await createClientFromThread(thread)
9+
}

0 commit comments

Comments
 (0)