Skip to content

[bug]: TUI plugin fails to load: 'stringify' not found in comment-json (Bun ESM/CJS) #84

@tim-hilde

Description

@tim-hilde

Pre-flight checks

  • I searched existing issues and did not find a duplicate.
  • I verified this on the current production released OpenCode version, or I explain why not below.

OpenCode version tested

1.3.17

opencode-quota version tested

3.7.1

Bug summary

The TUI plugin fails to load on OpenCode 1.3.17 with a Bun ESM linking error. dist/lib/jsonc.js uses a named ESM import (import { parse, stringify } from "comment-json") but comment-json v5.0.0 is a CJS-only module. Bun's static ESM linker cannot resolve stringify as a named export and throws a SyntaxError at link time before the module executes.

Steps to reproduce

  1. Install opencode-quota per the README (server plugin + TUI plugin in tui.json)
  2. Start OpenCode 1.3.17
  3. Observe the TUI plugin error in logs

Expected behavior

TUI plugin loads successfully; Sidebar panel and Compact status line are available.

Actual behavior

TUI plugin fails immediately on startup with:

[tui.plugin] failed to load tui plugin: Export named 'stringify' not found in module
'.../comment-json/src/index.js'.

The Sidebar panel and Compact status line are unavailable. The server plugin (slash commands, toasts) still works.

Relevant logs/output

[17:20:37] [ERROR] "[tui.plugin] failed to load tui plugin: Export named 'stringify' not found in module '/Users/tim/.cache/opencode/packages/@slkiser/opencode-quota@3.7.1/node_modules/comment-json/src/index.js'." {
  path: '@slkiser/opencode-quota@3.7.1',
  target: 'file:///Users/tim/.cache/opencode/packages/@slkiser/opencode-quota@3.7.1/node_modules/@slkiser/opencode-quota/dist/tui.tsx',
  retry: false,
  error: {
    type: 'SyntaxError',
    message: "Export named 'stringify' not found in module '.../comment-json/src/index.js'.",
    stack: "Error: Export named 'stringify' not found in module '.../comment-json/src/index.js'.\n
        at link (native)\n
        at linkAndEvaluateModule (native)\n
        at requestImportModule (native)\n
        at processTicksAndRejections (native)"
  }
}

Root cause: dist/lib/jsonc.js line 1:

import { parse, stringify } from "comment-json";

comment-json v5.0.0 uses module.exports = { stringify, ... } (no "exports" field). Bun's ESM linker does static named-export analysis and fails because stringify is assigned via const stringify = require('./stringify') — not a re-exported named binding.

Suggested fix in src/lib/jsonc.ts:

// before
import { parse, stringify } from "comment-json";

// after
import commentJson from "comment-json";
const { parse, stringify } = commentJson;

If not tested on current production OpenCode, explain why

Tested on OpenCode 1.3.17 (current release as of 2026-05-11).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions