Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

963 B
Raw Blame
import { writeFile } from 'node:fs/promises'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { build } from 'esbuild'

const scriptDir = path.dirname(fileURLToPath(import.meta.url))

const { outputFiles } = await build({
    stdin: {
        contents: 'import { transform } from \'sucrase\'; globalThis.__apSucrase = { transform };',
        resolveDir: scriptDir,
    },
    bundle: true,
    format: 'iife',
    platform: 'neutral',
    mainFields: ['module', 'main'],
    minify: true,
    write: false,
})

const bundle = outputFiles[0].text
const target = path.join(scriptDir, '../src/lib/cache/flow/code/sucrase-source.ts')
await writeFile(
    target,
    `/* eslint-disable */\n// Generated by scripts/bundle-sucrase.mjs — do not edit. Regenerate after bumping the sucrase devDependency.\nexport const SUCRASE_SOURCE = ${JSON.stringify(bundle)}\n`,
)
console.log(`Wrote ${target} (${(bundle.length / 1024).toFixed(0)} KB)`)