[PR #8828] fix(core): handle macro data as string in built artifacts #12884

Closed
opened 2026-02-16 18:17:46 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/8828

State: closed
Merged: No


Adds check for string type to handle Bun macros inlined at build time.

Changes

Modified the type check to include both function and string types:

// Before
if (typeof data === 'function') {
  const json = await data()
  return JSON.parse(json) as Record<string, Provider>
}

// After  
if (typeof data === 'function' || typeof data === 'string') {
  const json = await data()
  return JSON.parse(json) as Record<string, Provider>
}

Context

When Bun macros are enabled during compilation, the data() function may be executed and inlined as a string literal in the built artifacts. The original code only checked for function type, missing the string case.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/8828 **State:** closed **Merged:** No --- Adds check for string type to handle Bun macros inlined at build time. ## Changes Modified the type check to include both function and string types: ```typescript // Before if (typeof data === 'function') { const json = await data() return JSON.parse(json) as Record<string, Provider> } // After if (typeof data === 'function' || typeof data === 'string') { const json = await data() return JSON.parse(json) as Record<string, Provider> } ``` ## Context When Bun macros are enabled during compilation, the `data()` function may be executed and inlined as a string literal in the built artifacts. The original code only checked for function type, missing the string case.
yindo added the pull-request label 2026-02-16 18:17:46 -05:00
yindo closed this issue 2026-02-16 18:17:46 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12884