UNPKG

radashi-helper

Version:
35 lines (32 loc) 825 B
import { generateUmbrella } from "./chunk-EGWAB2TU.js"; import { getEnv } from "./chunk-DSXY7YVB.js"; // src/esbuild/plugin.ts import { writeFile } from "node:fs/promises"; function esbuildRadashi(options) { const env = options?.env ?? getEnv(options?.root); return { name: "esbuild-radashi", setup(build) { build.onLoad({ filter: /\/mod\.ts$/, namespace: "file" }, async (args) => { if (args.path === env.modPath) { const code = await generateUmbrella(env); await writeFile( args.path, "// BEWARE: This file is *generated* by the esbuild-radashi plugin. Do not edit directly!\n\n" + code ); return { loader: "ts", contents: code }; } }); } }; } export { esbuildRadashi };