@myrialabs/clopen 0.4.13 → 0.4.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/backend/index.ts CHANGED
@@ -8,11 +8,12 @@ if (typeof globalThis.Bun === 'undefined') {
8
8
  process.exit(1);
9
9
  }
10
10
 
11
- // MUST be first import — patches Bun's missing node:v8 isBuildingSnapshot before
12
- // any module (transitively mongodb/bson) loads and crashes at import time.
13
- import './utils/bun-compat';
11
+ // Note: the node:v8 isBuildingSnapshot shim (backend/utils/bun-compat.ts) is
12
+ // applied via Bun `preload` (bunfig.toml + --preload in bin/clopen.ts), NOT a
13
+ // plain import here — Bun does not guarantee side-effect import order ahead of
14
+ // the transitive mongodb/bson CJS import, so an import would run too late.
14
15
 
15
- // Cleans process.env before any other feature module reads it.
16
+ // MUST be first import — cleans process.env before any other module reads it.
16
17
  import { SERVER_ENV } from './utils/env';
17
18
 
18
19
  import { Elysia } from 'elysia';
@@ -14,7 +14,11 @@
14
14
  * reports "not building a snapshot" — always true for a normally-running
15
15
  * process, so `bson` skips its snapshot branch and loads cleanly.
16
16
  *
17
- * Import this before any module that (transitively) imports `mongodb`/`bson`.
17
+ * This file MUST be loaded via Bun's `--preload` / `bunfig.toml preload`, NOT a
18
+ * plain `import`. Bun does not guarantee that an earlier ESM side-effect import
19
+ * runs before a later CJS import is evaluated, so `import './bun-compat'` at the
20
+ * top of an entry still lets `mongodb`/`bson` load (and crash) first. `preload`
21
+ * is the only mechanism that reliably runs before the entry's import graph.
18
22
  */
19
23
 
20
24
  if (typeof globalThis.Bun !== 'undefined') {
package/bin/clopen.ts CHANGED
@@ -374,6 +374,9 @@ function ensureBuild() {
374
374
  }
375
375
 
376
376
  async function startServer(options: CLIOptions) {
377
+ // cwd is set to __dirname (package root) below so Bun picks up bunfig.toml,
378
+ // which preloads the node:v8 isBuildingSnapshot shim before the backend's
379
+ // import graph — see bunfig.toml and backend/utils/bun-compat.ts.
377
380
  const startScript = join(__dirname, 'scripts/start.ts');
378
381
 
379
382
  const env = { ...process.env, ...loadEnvFile(ENV_FILE) };
package/bunfig.toml ADDED
@@ -0,0 +1,4 @@
1
+ # Preload Bun compatibility shims before any entry's import graph is evaluated.
2
+ # Required because Bun does not guarantee ESM side-effect import order ahead of
3
+ # CJS imports — see backend/utils/bun-compat.ts (node:v8 isBuildingSnapshot / bson).
4
+ preload = ["./backend/utils/bun-compat.ts"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myrialabs/clopen",
3
- "version": "0.4.13",
3
+ "version": "0.4.14",
4
4
  "description": "All-in-one web workspace for AI coding agents — Claude Code, OpenCode, Codex, Copilot, and Qwen Code — with chat, terminal, git, browser preview, database client, checkpoints, and real-time collaboration",
5
5
  "author": "Myria Labs",
6
6
  "license": "MIT",
@@ -54,6 +54,7 @@
54
54
  "shared",
55
55
  "dist",
56
56
  "tsconfig.json",
57
+ "bunfig.toml",
57
58
  ".env.example"
58
59
  ],
59
60
  "engines": {