diff --git a/package.json b/package.json index ea13889..a8ab50c 100644 --- a/package.json +++ b/package.json @@ -15,17 +15,17 @@ "author": "", "license": "ISC", "devDependencies": { - "prettier": "^3.3.3", - "vite": "^5.4.5", - "vite-tsconfig-paths": "^5.0.1", "@biomejs/biome": "^1.9.1", "@tsconfig/next": "^2.0.3", "@tsconfig/node-lts": "^20.1.3", + "payload": "beta", + "prettier": "^3.3.3", "tsx": "^4.19.1", - "vitest": "^2.1.1", "typescript": "^5.6.2", "unbuild": "^2.0.0", - "payload": "beta" + "vite": "^5.4.5", + "vite-tsconfig-paths": "^5.0.1", + "vitest": "^2.1.1" }, "prettier": {} } diff --git a/packages/chat/build.config.ts b/packages/chat/build.config.ts deleted file mode 100644 index 4524a72..0000000 --- a/packages/chat/build.config.ts +++ /dev/null @@ -1,15 +0,0 @@ -import {defineBuildConfig} from 'unbuild' - -export default defineBuildConfig([ - { - rollup:{ - esbuild:{ - jsx:'automatic', - target:'ES2022', - } - } - }, - { - preset: './build.preset', - }, -]) diff --git a/packages/chat/build.preset.ts b/packages/chat/build.preset.ts deleted file mode 100644 index f9787f9..0000000 --- a/packages/chat/build.preset.ts +++ /dev/null @@ -1,41 +0,0 @@ -import {definePreset} from 'unbuild' -import {execSync} from 'node:child_process' -import fs from 'node:fs' -import path from 'node:path' - -export default definePreset({ - declaration: 'compatible', - rollup: { - cjsBridge: true, - }, - hooks: { - 'build:before': () => { - console.log('Before build') - }, - 'build:done': (ctx) => { - try { - console.log('After build') - // Run tailwindcss to generate the stylesheet - execSync( - 'npx tailwindcss -i ./src/ui/tailwind.css -o dist/ui/tailwind.css', - {stdio: 'inherit'}, - ) - // Paths to the generated files - const mjsFilePath = path.resolve(__dirname, 'dist/ui/page/ChatView.mjs') - const cjsFilePath = path.resolve(__dirname, 'dist/ui/page/ChatView.cjs') - const cssImportStatement = "import '../tailwind.css';\n" - // Function to inject the import statement - const injectCssImport = (filePath: string) => { - const fileContent = fs.readFileSync(filePath, 'utf8') - if (!fileContent.includes(cssImportStatement)) { - const updatedContent = cssImportStatement + fileContent - fs.writeFileSync(filePath, updatedContent, 'utf8') - } - } - // Inject the import statement into the generated files - injectCssImport(mjsFilePath) - injectCssImport(cjsFilePath) - }catch (err){} - }, - }, -}) diff --git a/packages/chat/package.json b/packages/chat/package.json index 9e58041..a9868a0 100644 --- a/packages/chat/package.json +++ b/packages/chat/package.json @@ -3,11 +3,15 @@ "type": "module", "types": "./dist/index.d.ts", "module": "./dist/index.mjs", - "files": ["dist/", "*.css"], + "sources": "src/index.ts", + "files": [ + "dist/", + "*.css" + ], "exports": { "./ChatView": { - "types": "./dist/ui/page/ChatView.d.ts", - "import": "./dist/ui/page/ChatView.mjs", + "types": "./src/ui/page/ChatView.ts", + "import": "./dist/ui/page/ChatView.js", "default": "./dist/ui/page/ChatView.cjs" }, ".": { @@ -19,24 +23,26 @@ "scripts": { "test": "vitest --run", "bench": "vitest --run bench", - "build:stub": "unbuild --stub", - "build": "unbuild --sourcemap", - "postinstall": "pnpm build:stub", + "build:ui": "vite build", + "build:plugin": "unbuild --sourcemaps", + "build": "pnpm build:plugin && pnpm build:ui", "tailwind": "npx tailwindcss -i ./src/ui/tailwind.css -o ./dist/ui/tailwind.css" }, "dependencies": { - "tsup": "^8.3.0", "@payloadcms/next": "beta", "@payloadcms/ui": "beta", + "@vitejs/plugin-react": "^4.3.1", "@workspace/llm-utils": "workspace:*", "defu": "^6.1.4", "ollama": "^0.5.9", "openai": "^4.61.1", "pathe": "^1.1.2", + "postcss": "^8.4.47", "radash": "^12.1.0", + "tailwindcss": "^3.4.12", "type-fest": "^4.26.1", - "postcss": "^8.4.47", - "tailwindcss": "^3.4.12" + "vite-plugin-lib-inject-css": "^2.1.1", + "vite-plugin-node-polyfills": "^0.22.0" }, "peerDependencies": { "next": "^14.2.13", @@ -44,9 +50,20 @@ "react": "^18.3.1" }, "devDependencies": { - "@types/react": "18.3.7" + "@types/react": "18.3.8", + "unbuild": "^2.0.0", + "vite-plugin-dts": "^4.2.1", + "vite-plugin-externalize-deps": "^0.8.0" }, "unbuild": { - "sourcemap": true + "entries": [ + "./src/index" + ], + "sourcemap": true, + "declaration": "compatible", + "failOnWarn": false, + "rollup": { + "emitCJS": true + } } } diff --git a/packages/chat/src/ui/page/ChatView.tsx b/packages/chat/src/ui/page/ChatView.tsx index d7860d2..8aecb48 100644 --- a/packages/chat/src/ui/page/ChatView.tsx +++ b/packages/chat/src/ui/page/ChatView.tsx @@ -1,3 +1,5 @@ +import '../tailwind.css' + import type {AdminViewProps} from 'payload' //@ts-ignore // biome-ignore lint/style/useImportType: @@ -57,7 +59,7 @@ import {ConversationsList} from './ConversationsList' return ( <> -