Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 830 Bytes

readme.md

File metadata and controls

32 lines (23 loc) · 830 Bytes

resolve-stack-sources

Rewrite a stack trace with source maps. This package was extracted from wrangler to be used by other frameworks.

pnpm add resolve-stack-sources

Usage

import { getSourceMappedString } from 'resolve-stack-sources'

const sourceMappedStackTrace = getSourceMappedString(error.stack)
// => string

You may pass a custom retrieveSourceMap function to the getSourceMappedString function.

import { getSourceMappedString } from 'resolve-stack-sources'

function retrieveSourceMap(source: string) {
  // The `source` is the path to the source file.
  // You must return either null or a { url, map } object.
}

const sourceMappedStackTrace = getSourceMappedString(
  error.stack,
  retrieveSourceMap
)