Skip to content

bundleCode

bundleCode(options): Promise<BundleResult>

Bundle code using esbuild (client-side)

Transforms and bundles TypeScript/JavaScript code into a single file that can be executed by the Fluxbase Deno runtime.

Requires esbuild as a peer dependency.

ParameterTypeDescription
optionsBundleOptionsBundle options including source code

Promise<BundleResult>

Promise resolving to bundled code

Error if esbuild is not available

import { bundleCode } from '@fluxbase/sdk'
const bundled = await bundleCode({
code: `
import { helper } from './utils'
export default async function handler(req) {
return helper(req.payload)
}
`,
minify: true,
})
// Use bundled code in sync
await client.admin.functions.sync({
namespace: 'default',
functions: [{
name: 'my-function',
code: bundled.code,
is_pre_bundled: true,
}]
})