import { externalPlugin } from './chunk-OV4QUJV2.js';
import { compilerPlugin } from './chunk-UTOXKP6U.js';
import { __name } from './chunk-6AXVLTU5.js';
import { noop } from '@stryke/helpers/noop';
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(noop, {
        external: context.external,
        noExternal: context.noExternal,
        skipNodeModulesBundle: true
      }, context.resolvedTsconfig.tsconfigJson.compilerOptions?.paths),
      compilerPlugin(noop, 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-IRKSJ3RH.js.map
//# sourceMappingURL=chunk-IRKSJ3RH.js.map