(build: EsbuildPluginBuild, cwd: string)
| 1155 | // a standalone bundle's externals, and the calls its folded helpers left, |
| 1156 | // checked once it's written |
| 1157 | const checkEsbuildBundle = (build: EsbuildPluginBuild, cwd: string) => { |
| 1158 | build.initialOptions.metafile = true |
| 1159 | build.onEnd(async result => { |
| 1160 | if (!result.metafile || result.errors.length) return |
| 1161 | const warnings: { text: string }[] = [] |
| 1162 | try { |
| 1163 | await checkBundledExternals( |
| 1164 | esbuildBundleOf(result.metafile, cwd), |
| 1165 | warning => warnings.push({ text: warning }) |
| 1166 | ) |
| 1167 | } catch (e) { |
| 1168 | return rejectEsbuild(build, cwd, result.metafile, (e as Error).message) |
| 1169 | } |
| 1170 | const problem = |
| 1171 | foldedHelpersById.size && |
| 1172 | unfoldedCallProblemOf( |
| 1173 | foldedHelpersById, |
| 1174 | esbuildImportsOf(result.metafile, cwd), |
| 1175 | isTransformedId, |
| 1176 | realCwd() |
| 1177 | ) |
| 1178 | // it wrote calls that throw at runtime |
| 1179 | if (problem) return rejectEsbuild(build, cwd, result.metafile, problem) |
| 1180 | return { warnings } |
| 1181 | }) |
| 1182 | } |
| 1183 | // the scan's facts hold only while the bundle is what it read |
| 1184 | const scanEsbuildBundle = ( |
| 1185 | build: EsbuildPluginBuild, |
no test coverage detected