opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix(core): handle macro data as string in built artifacts

Open junmediatek opened this issue 1 day ago • 4 comments

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.

junmediatek avatar Jan 16 '26 07:01 junmediatek