import { BuildOptions } from 'esbuild' export function eraseFilePathPrefix(raw: string): string { const anchorIndex = raw.indexOf('__tests__') if (anchorIndex < 0) throw Error('should find __tests__ in path') const prefix = '' const postfix = raw.slice(anchorIndex) return `${prefix}/${postfix}` } export function eraseEsbuildOptionsBasePath(raw: BuildOptions): BuildOptions { const result = raw if (raw.entryPoints) { result.entryPoints = raw.entryPoints.map(eraseFilePathPrefix) } if (raw.outdir) { result.outdir = eraseFilePathPrefix(raw.outdir) } return result }