#!/usr/bin/env bash
':' // ; cat "$0" | node --input-type=module - $@ ; exit $?

import { build } from "esbuild";
import epeg from "esbuild-plugin-external-global";

const { externalGlobalPlugin } = epeg;

// See client/index.ts for the other side of this
await build({
  entryPoints: [process.argv[2]],
  bundle: true,
  outfile: process.argv[3],
  format: 'esm',
  plugins: [
    externalGlobalPlugin({
      'react': 'window.ReactExports',
      '@norskvideo/webrtc-client': 'window.WebRtcClient',
      'hls.js': "window.HlsJs",
      'react/jsx-runtime': "window.ReactJsx",
    })
  ]
})
