()
| 5 | let offset: number |
| 6 | |
| 7 | function calculateOffsetOnce() { |
| 8 | if (offset !== undefined) { |
| 9 | return |
| 10 | } |
| 11 | |
| 12 | try { |
| 13 | // `"use strict";` mirrors the directive prepended on its own line by |
| 14 | // `ESModulesEvaluator` |
| 15 | new Function('"use strict";\nthrow new Error(1)')() |
| 16 | } catch (e) { |
| 17 | // in Node 12, stack traces account for the function wrapper. |
| 18 | // in Node 13 and later, the function wrapper adds two lines, |
| 19 | // which must be subtracted to generate a valid mapping |
| 20 | const match = /:(\d+):\d+\)$/.exec(e.stack.split('\n')[1]) |
| 21 | offset = match ? +match[1] - 1 : 0 |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | export function ssrRewriteStacktrace( |
| 26 | stack: string, |
no outgoing calls
no test coverage detected