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