UNPKG

alinea

Version:
32 lines (30 loc) 785 B
import "../../chunks/chunk-NZLE2WMY.js"; // src/cli/util/Watcher.ts import esbuild from "esbuild"; async function createWatcher(options) { let initial = true; const watcher = { name: "watcher", setup(build) { build.onResolve({ filter: /^watch$/ }, async (args) => { const { files, dirs } = await options.watchFiles(); return { external: true, watchFiles: files, watchDirs: dirs }; }); build.onStart(() => { if (initial) initial = false; else options.onChange(); }); } }; const context = await esbuild.context({ bundle: true, stdin: { contents: "import 'watch'" }, plugins: [watcher], write: false }); context.watch(); return context.dispose.bind(context); } export { createWatcher };