next.js/test/e2e/app-dir/bun-externals/app/server-action/actions.ts
actions.ts34 lines813 B
'use server'

export async function testBunExternals() {
  const modules = [
    'bun:ffi',
    'bun:jsc',
    'bun:sqlite',
    'bun:test',
    'bun:wrap',
    'bun',
  ]
  const results: Record<string, string> = {}

  for (const mod of modules) {
    try {
      require(mod)
      results[mod] = 'loaded'
    } catch (e: any) {
      // Expected: Cannot find module error when not in Bun runtime
      results[mod] = e.message.includes('Cannot find module')
        ? 'external (not found)'
        : 'error'
    }
  }

  // All modules should be external (not found when not in Bun)
  const allExternal = Object.values(results).every(
    (r) => r === 'external (not found)' || r === 'loaded'
  )
  return allExternal
    ? 'All Bun modules are external'
    : 'Some modules were not properly externalized'
}
Quest for Codev2.0.0
/
SIGN IN