import { compilerPlugin } from './chunk-VWB436XK.js';
import { externalPlugin } from './chunk-7RCSW6NX.js';
import { __name } from './chunk-6AXVLTU5.js';
import { relativePath, findFilePath } from '@stryke/path/file-path-fns';
import defu from 'defu';
import { build } from 'esbuild';

async function bundle(context, entryPoint, outputDir, override = {}, options) {
  const esbuildOptions = defu(override ?? {}, context.override, {
    entryPoints: [
      entryPoint
    ],
    platform: "node",
    format: "esm",
    minify: false,
    sourcemap: false,
    bundle: true,
    treeShaking: true,
    keepNames: true,
    splitting: false,
    preserveSymlinks: true,
    outdir: outputDir,
    logLevel: "silent",
    plugins: [
      externalPlugin({
        external: context.options.external,
        noExternal: context.options.noExternal,
        skipNodeModulesBundle: true
      }, context.tsconfig.options?.paths),
      compilerPlugin(context, options)
    ]
  });
  esbuildOptions.alias = Object.entries(esbuildOptions.alias ?? {}).reduce((ret, [key, value]) => {
    ret[key] = relativePath(findFilePath(entryPoint), value);
    return ret;
  }, {});
  return build(esbuildOptions);
}
__name(bundle, "bundle");

export { bundle };
//# sourceMappingURL=chunk-BHCYZWKJ.js.map
//# sourceMappingURL=chunk-BHCYZWKJ.js.map