Skip to content

refactor: bundle xterm.js with esbuild instead of CDN runtime loading#8

Open
yuezanhao wants to merge 1 commit intocloudcli-ai:mainfrom
yuezanhao:refactor/esbuild-bundle-xterm
Open

refactor: bundle xterm.js with esbuild instead of CDN runtime loading#8
yuezanhao wants to merge 1 commit intocloudcli-ai:mainfrom
yuezanhao:refactor/esbuild-bundle-xterm

Conversation

@yuezanhao
Copy link
Copy Markdown

Summary

  • Replace dynamic CDN (esm.sh) imports with static ES module imports bundled by esbuild
  • Add @xterm/* packages as npm dependencies instead of loading from CDN at runtime
  • Inline xterm CSS via esbuild's CSS loader, removing external stylesheet link
  • Add tsconfig.server.json for server-side TypeScript compilation
  • Remove XtermModules interface and loadModules() helper (no longer needed)

Why

Runtime CDN loading introduces several issues:

  • Reliability: depends on esm.sh availability; fails on restricted networks
  • Latency: 6 separate HTTP requests to load xterm + addons
  • Offline: impossible to use without internet
  • Version drift: CDN caches can serve stale versions

Bundling at build time resolves all of these while keeping the same runtime behavior.

Test plan

  • npm install completes successfully
  • npm run build produces dist/index.js with bundled xterm
  • Terminal renders correctly in browser with all addons (fit, web-links, webgl, clipboard, unicode11)
  • Webgl addon falls back gracefully when not supported
  • Clipboard paste button works on mobile

🤖 Generated with Claude Code

Switch from loading xterm.js modules dynamically from esm.sh CDN at
runtime to bundling them with esbuild at build time. This eliminates
runtime CDN dependency, improves load reliability, and enables offline
usage.

Key changes:
- Add @xterm/* npm packages as direct dependencies
- Replace dynamic CDN imports with static ES module imports
- Use esbuild to bundle JS and inline CSS
- Add tsconfig.server.json for server-side compilation
- Remove XtermModules interface and loadModules() helper
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