import{relative as p,resolve as d}from"node:path";import{readFileSync as E}from"node:fs";import{reportEsbuildError as n}from"../esbuild-logger.js";import{isDevelopMode as b}from"../../utils/is-develop-mode.js";import{babelCache as h}from"../babel-cache.js";const S=(a,r)=>({name:"esbuild-error-collector",setup:i=>{i.onEnd(l=>{if(!b())return;const m=l.errors.map(o=>{const e=o?.location?.file||"",t=p(r,e),f=E(e,"utf8"),s=n(o.text,t,f,o?.location);if(!s?.hasMatched){const u=d(r,t),c=h.get(u)?.contents;if(c)return n(o.text,t,c,o?.location)}return s});a.compilationErrors=m})}});export{S as EsbuildErrorCollector};
