Skip to content

Conversation

@gary149
Copy link
Collaborator

@gary149 gary149 commented Jan 19, 2026

Summary

  • Enable building chat-ui with both adapter-node (web/SSR) and adapter-static (Capacitor/Tauri SPA) from the same codebase
  • Refactor hooks.server.ts to use lazy dynamic imports gated by building checks to avoid database module evaluation during static build
  • Add conditional adapter selection via ADAPTER environment variable

Changes

File Change
src/lib/server/hooks/*.ts New files extracting hook implementations
src/hooks.server.ts Thin wrapper with dynamic imports
src/lib/server/config.ts Added building check in init()
svelte.config.js Conditional adapter selection
package.json Added build:static script and @sveltejs/adapter-static

Usage

# Node adapter (web/SSR) - default
npm run build

# Static adapter (Capacitor/Tauri SPA)
npm run build:static

Test plan

  • npm run build succeeds (node adapter)
  • npm run build:static succeeds (static adapter)
  • npm run check passes (TypeScript validation)
  • Static build produces index.html fallback for SPA routing

Enable building chat-ui with both adapter-node (web/SSR) and adapter-static
(Capacitor/Tauri SPA) from the same codebase.

Key changes:
- Refactor hooks.server.ts to use lazy dynamic imports with building checks
- Extract hook implementations to separate files under src/lib/server/hooks/
- Add building check to config.ts init() to skip database access during static builds
- Add conditional adapter selection in svelte.config.js based on ADAPTER env var
- Add build:static npm script and adapter-static dependency

Usage:
- npm run build (node adapter, default)
- npm run build:static (static adapter for SPA)
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 41c240907b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

During static builds, replace %gaId% with empty string to prevent
the GA script from attempting to load with an invalid ID.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants