(e: RolldownError)
| 75 | |
| 76 | // Copy from rolldown's packages/rolldown/src/utils/errors.ts |
| 77 | function getErrorMessage(e: RolldownError): string { |
| 78 | // If the `kind` field is present, we assume it represents |
| 79 | // a custom error defined by rolldown on the Rust side. |
| 80 | if (Object.hasOwn(e, 'kind')) { |
| 81 | return e.message |
| 82 | } |
| 83 | |
| 84 | let s = '' |
| 85 | if (e.plugin) { |
| 86 | s += `[plugin ${e.plugin}]` |
| 87 | } |
| 88 | const id = e.id ?? e.loc?.file |
| 89 | if (id) { |
| 90 | s += ' ' + id |
| 91 | if (e.loc) { |
| 92 | s += `:${e.loc.line}:${e.loc.column}` |
| 93 | } |
| 94 | } |
| 95 | if (s) { |
| 96 | s += '\n' |
| 97 | } |
| 98 | const message = `${e.name ?? 'Error'}: ${e.message}` |
| 99 | s += message |
| 100 | if (e.frame) { |
| 101 | s = joinNewLine(s, e.frame) |
| 102 | } |
| 103 | // copy stack since it's important for js plugin error |
| 104 | if (e.stack) { |
| 105 | s = joinNewLine(s, e.stack.replace(message, '')) |
| 106 | } |
| 107 | if (e.cause) { |
| 108 | s = joinNewLine(s, 'Caused by:') |
| 109 | s = joinNewLine( |
| 110 | s, |
| 111 | getErrorMessage(e.cause as any) |
| 112 | .split('\n') |
| 113 | .map((line) => ' ' + line) |
| 114 | .join('\n'), |
| 115 | ) |
| 116 | } |
| 117 | return s |
| 118 | } |
| 119 | |
| 120 | export async function transformWithOxc( |
| 121 | code: string, |
no test coverage detected