{"version":3,"sources":["../../src/writeFilePlugin.ts"],"sourcesContent":["import { mkdir, writeFile } from \"node:fs/promises\";\nimport { dirname } from \"node:path\";\nimport { type Plugin } from \"esbuild\";\n\nexport const writeFilePlugin = (): Plugin => ({\n  name: \"writeFilePlugin\",\n\n  setup: (build) => {\n    // (optional) helps make output paths predictable/absolute\n    // ensure you pass absWorkingDir in your build() calls:\n    // absWorkingDir: process.cwd(),\n\n    build.onEnd(async (result) => {\n      if (result.errors.length) return;\n\n      const files = result.outputFiles ?? [];\n      await Promise.all(\n        files.map(async (file) => {\n          await mkdir(dirname(file.path), { recursive: true });\n          // file.contents is a Uint8Array; write as-is\n          await writeFile(file.path, file.contents);\n        })\n      );\n      // done: the same paths esbuild would use are now written to disk\n    });\n  },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAAiC;AACjC,uBAAwB;AAGjB,MAAM,kBAAkB,OAAe;AAAA,EAC5C,MAAM;AAAA,EAEN,OAAO,CAAC,UAAU;AAKhB,UAAM,MAAM,OAAO,WAAW;AAC5B,UAAI,OAAO,OAAO,OAAQ;AAE1B,YAAM,QAAQ,OAAO,eAAe,CAAC;AACrC,YAAM,QAAQ;AAAA,QACZ,MAAM,IAAI,OAAO,SAAS;AACxB,oBAAM,2BAAM,0BAAQ,KAAK,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;AAEnD,oBAAM,2BAAU,KAAK,MAAM,KAAK,QAAQ;AAAA,QAC1C,CAAC;AAAA,MACH;AAAA,IAEF,CAAC;AAAA,EACH;AACF;","names":[]}