MCPcopy
hub / github.com/vitejs/vite / extractStack

Function extractStack

packages/vite/src/node/build.ts:958–972  ·  view source on GitHub ↗

* The stack string usually contains a copy of the message at the start of the stack. * If the stack starts with the message, we remove it and just return the stack trace * portion. Otherwise the original stack trace is used.

(e: RollupError)

Source from the content-addressed store, hash-verified

956 * portion. Otherwise the original stack trace is used.
957 */
958function extractStack(e: RollupError) {
959 const { stack, name = 'Error', message } = e
960
961 // If we don't have a stack, not much we can do.
962 if (!stack) {
963 return stack
964 }
965
966 const expectedPrefix = `${name}: ${message}\n`
967 if (stack.startsWith(expectedPrefix)) {
968 return stack.slice(expectedPrefix.length)
969 }
970
971 return stack
972}
973
974/**
975 * Esbuild code frames have newlines at the start and end of the frame, rollup doesn't

Callers 1

enhanceRollupErrorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected