All Projects → bloomberg → Pasta Sourcemaps

bloomberg / Pasta Sourcemaps

Licence: apache-2.0
Pretty (and) Accurate Stack Trace Analysis is an extension to the JavaScript source map format that allows for accurate function name decoding.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Pasta Sourcemaps

Javascriptenhancements
JavaScript Enhancements is a plugin for Sublime Text 3. It offers not only a smart javascript autocomplete but also a lot of features about creating, developing and managing javascript projects (real-time errors, code refactoring, etc.).
Stars: ✭ 592 (+428.57%)
Mutual labels:  javascript-tools
Memstrack
A memory allocation tracer combined with stack trace.
Stars: ✭ 60 (-46.43%)
Mutual labels:  stacktrace
Js Callgraph
Construct approximate static call graph for JavaScript & Typescript
Stars: ✭ 89 (-20.54%)
Mutual labels:  javascript-tools
Rxjava2debug
RxJava 2.x extension to provide meaningful Stack Traces
Stars: ✭ 673 (+500.89%)
Mutual labels:  stacktrace
Retrace
基于mapping.txt文件,根据原始class名或方法名获取混淆后的class名或方法名,根据混淆后的class名或方法名获取原始class名或方法名,堆栈还原等
Stars: ✭ 41 (-63.39%)
Mutual labels:  stacktrace
Npm Link Up
🔄 Link your NPM projects automatically, for sophisticated / modular local development.
Stars: ✭ 68 (-39.29%)
Mutual labels:  javascript-tools
Traceback with variables
Adds variables to python traceback. Simple, lightweight, controllable. Debug reasons of exceptions by logging or pretty printing colorful variable contexts for each frame in a stacktrace, showing every value. Dump locals environments after errors to console, files, and loggers. Works in Jupyter and IPython. Install with pip or conda.
Stars: ✭ 509 (+354.46%)
Mutual labels:  stacktrace
Jscost.org
JSCost.org - a JavaScript cost visualizer 💸
Stars: ✭ 101 (-9.82%)
Mutual labels:  javascript-tools
Panic Overlay
Displays JS errors in browsers. Shows sources. Use with any framework. 💥✨
Stars: ✭ 50 (-55.36%)
Mutual labels:  stacktrace
Errors
Drop-in replacement for the standard library errors package and github.com/pkg/errors
Stars: ✭ 88 (-21.43%)
Mutual labels:  stacktrace
Sentry Ruby
Sentry SDK for Ruby
Stars: ✭ 724 (+546.43%)
Mutual labels:  stacktrace
Thrift2flow
Converts Thrift specs into Flow JavaScript type definitions
Stars: ✭ 39 (-65.18%)
Mutual labels:  javascript-tools
Deps Report
Generate reports about dependencies and dependents of your JavaScript/TypeScript files through an AST. It supports import and require statements.
Stars: ✭ 76 (-32.14%)
Mutual labels:  javascript-tools
Tracerr
Golang errors with stack trace and source fragments.
Stars: ✭ 646 (+476.79%)
Mutual labels:  stacktrace
Object Explorer
🔥 A resource to help figure out what JavaScript object method would be best to use at any given time
Stars: ✭ 1,358 (+1112.5%)
Mutual labels:  javascript-tools
Patch Package
Fix broken node modules instantly 🏃🏽‍♀️💨
Stars: ✭ 6,062 (+5312.5%)
Mutual labels:  javascript-tools
Ishare.js
iShare.js是一个小巧的分享插件,纯JS编写,不依赖任何第三方库,使用简便。
Stars: ✭ 67 (-40.18%)
Mutual labels:  javascript-tools
Chakracore Delphi
Delphi and Free Pascal bindings and classes for Microsoft's ChakraCore library
Stars: ✭ 109 (-2.68%)
Mutual labels:  javascript-tools
Jscity
Visualizing JavaScript source code as navigable 3D cities
Stars: ✭ 1,367 (+1120.54%)
Mutual labels:  javascript-tools
Backtrace
Makes Python tracebacks human friendly
Stars: ✭ 80 (-28.57%)
Mutual labels:  stacktrace

@bloomberg/pasta-sourcemaps

npm Badge Build Status

pasta, or Pretty (and) Accurate Stack Trace Analysis, is an implementation of an extension to the source map format that allows for accurate function name decoding. It allows you to extract function-related metadata from a source file and encode it into a source map, as well as decode a pasta-enriched source map to query enclosing function names for a given location.

Background

Source code often gets modified one way or another before hitting production - through transpilation, minification, etc. Looking at a "raw" crash stack of generated code can be hard work.

// sample.js
const penne     = () => { throw Error(); }
const spaghetti = () => penne();
const orzo      = () => spaghetti();
orzo();
// **original** output                           // **compiled** output
Error                                            Error
    at penne (sample.js:2:33)                        at r (out.js:1:82)
    at spaghetti (sample.js:3:25)         vs         at o (out.js:1:97)
    at orzo (sample.js:4:25)                         at n (out.js:1:107)

Today, source maps already provide the ability to produce accurate locations (filename, line number, column number) in a crash stack, but not enclosing function names. This hinders debugging and confuses automatic crash stack consolidation.

pasta extends the source map format with a x_com_bloomberg_sourcesFunctionMappings field to allow for accurate function name decoding. See spec.md to learn more about the pasta format.

Features

  • Native support for ECMAScript, TypeScript, JSX and TSX input source types
  • Encoder allows you to roll your own parser to support other languages

Installation

npm install @bloomberg/pasta-sourcemaps

API

@bloomberg/pasta-sourcemaps exposes three utilities:

The parser and the encoder are normally used in conjunction to parse a source file and encode the resulting function descriptions into a source map.

The decoder takes a pasta-enriched sourcemap and gives back enclosing function names for a given source file, line and column location.

To read the full API documentation please visit the GitHub Pages

Usage

Parser

const pasta = require("@bloomberg/pasta-sourcemaps");

const source = "function orzo(){}; function penne(){};";
const functionDescs = pasta.parse(source, "ECMAScript");

console.log(functionDescs);

output

[
    {
        name: '<top-level>',
        startLine: 0,
        startColumn: 0,
        endLine: 0,
        endColumn: 38
    },
    {
        name: 'orzo',
        startLine: 0,
        startColumn: 0,
        endLine: 0,
        endColumn: 17
    },
    {
        name: 'penne',
        startLine: 0,
        startColumn: 18,
        endLine: 0,
        endColumn: 37
    }
]

Encoder

const pasta = require("@bloomberg/pasta-sourcemaps");

const sourceMap = {
    version: 3,
    file: 'out.js',
    sources: [ 'barilla.js' ],
    names: [ 'orzo', 'penne' ],
    mappings: 'AAAA,SAASA,QAAU,SAASC'
};

const functionDescs = new Map([
    [
        "barilla.js", [
        {
            name: '<top-level>',
            startLine: 0,
            startColumn: 0,
            endLine: 0,
            endColumn: 38
        },
        {
            name: 'orzo',
            startLine: 0,
            startColumn: 0,
            endLine: 0,
            endColumn: 17
        },
        {
            name: 'penne',
            startLine: 0,
            startColumn: 18,
            endLine: 0,
            endColumn: 37
        }
        ]
    ]
]);

const enrichedSourceMap = pasta.encode(sourceMap, functionDescs);

console.log(enrichedSourceMap);

output

{
    version: 3,
    file: 'out.js',
    sources: [ 'barilla.js' ],
    names: [ 'orzo', 'penne', '<top-level>' ],
    mappings: 'AAAA,SAASA,QAAU,SAASC',
    x_com_bloomberg_sourcesFunctionMappings: [ 'EAAAsC,FAAArB,CAkBAoB' ]
}

Decoder

const pasta = require("@bloomberg/pasta-sourcemaps");

const enrichedSourceMap = {
    version: 3,
    file: 'out.js',
    sources: [ 'barilla.js' ],
    names: [ 'orzo', 'penne', '<top-level>' ],
    mappings: 'AAAA,SAASA,QAAU,SAASC',
    x_com_bloomberg_sourcesFunctionMappings: [ 'EAAAsC,FAAArB,CAkBAoB' ]
};

const decoder = new pasta.SourceMapDecoder(enrichedSourceMap);

decoder.decode("barilla.js", 0, 4);  // orzo
decoder.decode("barilla.js", 0, 25); // penne

Development

  • Clone this repository
  • Install dependencies:
    • npm install
  • Write code, add tests!
  • To build code and run tests:
    • npm run build
    • npm run test
  • To run lint checks prior to committing:
    • npm run lint

Contributions

We ❤️ contributions.

Have you had a good experience with pasta-sourcemaps? Why not share some love and contribute code, or just let us know about any issues you had with it?

We welcome issue reports here; be sure to choose the proper issue template for your issue, so that we can be sure you're providing the necessary information.

Before sending a Pull Request, please make sure you read our Contribution Guidelines.

License

Apache 2.0

Code of Conduct

This project has adopted a Code of Conduct. If you have any concerns about the Code, or behavior which you have experienced in the project, please contact us at [email protected].

Security Vulnerability Reporting

If you believe you have identified a security vulnerability in this project, please send email to the project team at [email protected], detailing the suspected issue and any methods you've found to reproduce it.

Please do NOT open an issue in the GitHub repository, as we'd prefer to keep vulnerability reports private until we've had an opportunity to review and address them.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].