{"id":13828968,"url":"https://github.com/bloomberg/pasta-sourcemaps","last_synced_at":"2025-04-09T07:06:59.749Z","repository":{"id":34260081,"uuid":"172090343","full_name":"bloomberg/pasta-sourcemaps","owner":"bloomberg","description":"Pretty (and) Accurate Stack Trace Analysis is an extension to the JavaScript source map format that allows for accurate function name decoding.","archived":false,"fork":false,"pushed_at":"2024-08-16T15:58:08.000Z","size":615,"stargazers_count":171,"open_issues_count":2,"forks_count":10,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-02T05:09:58.985Z","etag":null,"topics":["javascript","javascript-tools","sourcemaps","stacktrace"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bloomberg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-22T15:37:22.000Z","updated_at":"2025-01-16T03:41:35.000Z","dependencies_parsed_at":"2024-01-21T21:12:25.617Z","dependency_job_id":"e12d4bfe-00f7-4a2e-bac8-49ed757a07ae","html_url":"https://github.com/bloomberg/pasta-sourcemaps","commit_stats":{"total_commits":60,"total_committers":7,"mean_commits":8.571428571428571,"dds":0.5166666666666666,"last_synced_commit":"f1f59e0efca0d7777cd0b8a1bd3a8e5f423004b2"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloomberg%2Fpasta-sourcemaps","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloomberg%2Fpasta-sourcemaps/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloomberg%2Fpasta-sourcemaps/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bloomberg%2Fpasta-sourcemaps/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bloomberg","download_url":"https://codeload.github.com/bloomberg/pasta-sourcemaps/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247994121,"owners_count":21030050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","javascript-tools","sourcemaps","stacktrace"],"created_at":"2024-08-04T09:03:23.477Z","updated_at":"2025-04-09T07:06:59.733Z","avatar_url":"https://github.com/bloomberg.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"\u003cimg src=\"assets/pasta_128.png\" align=\"right\"/\u003e\n\n# @bloomberg/pasta-sourcemaps\n\n[![npm Badge](https://img.shields.io/npm/v/@bloomberg/pasta-sourcemaps.svg)](https://www.npmjs.com/package/@bloomberg/pasta-sourcemaps)\n![Build Status](https://github.com/bloomberg/pasta-sourcemaps/actions/workflows/ci.yml/badge.svg)\n\n`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.\n\n## Background\n\nSource 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.\n\n```javascript\n// sample.js\nconst penne     = () =\u003e { throw Error(); }\nconst spaghetti = () =\u003e penne();\nconst orzo      = () =\u003e spaghetti();\norzo();\n```\n\n```javascript\n// **original** output                           // **compiled** output\nError                                            Error\n    at penne (sample.js:2:33)                        at r (out.js:1:82)\n    at spaghetti (sample.js:3:25)         vs         at o (out.js:1:97)\n    at orzo (sample.js:4:25)                         at n (out.js:1:107)\n```\n\nToday, [source maps](https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?hl=en_US\u0026pli=1\u0026pli=1)\nalready provide the ability to produce accurate _locations_ (filename, line number, column number) in a crash stack, but not _enclosing\nfunction names_. This hinders debugging and confuses automatic crash stack consolidation.\n\n`pasta` extends the source map format with a `x_com_bloomberg_sourcesFunctionMappings` field to allow for accurate function name decoding. See [spec.md](spec.md) to learn more about the `pasta` format.\n\n## Features\n\n- Native support for ECMAScript, TypeScript, JSX and TSX input source types\n- Encoder allows you to roll your own parser to support other languages\n\n## Installation\n\n```bash\nnpm install @bloomberg/pasta-sourcemaps\n```\n\n## API\n\n`@bloomberg/pasta-sourcemaps` exposes three utilities:\n\n- [parser](src/parser.ts)\n- [encoder](src/encoder.ts)\n- [decoder](src/decoder.ts)\n\nThe parser and the encoder are normally used in conjunction to parse a source file and encode the resulting function descriptions into a source map.\n\nThe decoder takes a pasta-enriched sourcemap and gives back enclosing function names for a given source file, line and column location.\n\nTo read the full API documentation please visit the [GitHub Pages](https://bloomberg.github.io/pasta-sourcemaps/)\n\n## Usage\n\n### Parser\n\n```javascript\nconst pasta = require(\"@bloomberg/pasta-sourcemaps\");\n\nconst source = \"function orzo(){}; function penne(){};\";\nconst functionDescs = pasta.parse(source, \"ECMAScript\");\n\nconsole.log(functionDescs);\n```\n\noutput\n\n```javascript\n[\n    {\n        name: '\u003ctop-level\u003e',\n        startLine: 0,\n        startColumn: 0,\n        endLine: 0,\n        endColumn: 38\n    },\n    {\n        name: 'orzo',\n        startLine: 0,\n        startColumn: 0,\n        endLine: 0,\n        endColumn: 17\n    },\n    {\n        name: 'penne',\n        startLine: 0,\n        startColumn: 18,\n        endLine: 0,\n        endColumn: 37\n    }\n]\n```\n\n### Encoder\n\n```javascript\nconst pasta = require(\"@bloomberg/pasta-sourcemaps\");\n\nconst sourceMap = {\n    version: 3,\n    file: 'out.js',\n    sources: [ 'barilla.js' ],\n    names: [ 'orzo', 'penne' ],\n    mappings: 'AAAA,SAASA,QAAU,SAASC'\n};\n\nconst functionDescs = new Map([\n    [\n        \"barilla.js\", [\n        {\n            name: '\u003ctop-level\u003e',\n            startLine: 0,\n            startColumn: 0,\n            endLine: 0,\n            endColumn: 38\n        },\n        {\n            name: 'orzo',\n            startLine: 0,\n            startColumn: 0,\n            endLine: 0,\n            endColumn: 17\n        },\n        {\n            name: 'penne',\n            startLine: 0,\n            startColumn: 18,\n            endLine: 0,\n            endColumn: 37\n        }\n        ]\n    ]\n]);\n\nconst enrichedSourceMap = pasta.encode(sourceMap, functionDescs);\n\nconsole.log(enrichedSourceMap);\n```\n\noutput\n\n```javascript\n{\n    version: 3,\n    file: 'out.js',\n    sources: [ 'barilla.js' ],\n    names: [ 'orzo', 'penne', '\u003ctop-level\u003e' ],\n    mappings: 'AAAA,SAASA,QAAU,SAASC',\n    x_com_bloomberg_sourcesFunctionMappings: [ 'EAAAsC,FAAArB,CAkBAoB' ]\n}\n```\n\n### Decoder\n\n```javascript\nconst pasta = require(\"@bloomberg/pasta-sourcemaps\");\n\nconst enrichedSourceMap = {\n    version: 3,\n    file: 'out.js',\n    sources: [ 'barilla.js' ],\n    names: [ 'orzo', 'penne', '\u003ctop-level\u003e' ],\n    mappings: 'AAAA,SAASA,QAAU,SAASC',\n    x_com_bloomberg_sourcesFunctionMappings: [ 'EAAAsC,FAAArB,CAkBAoB' ]\n};\n\nconst decoder = new pasta.SourceMapDecoder(enrichedSourceMap);\n\ndecoder.decode(\"barilla.js\", 0, 4);  // orzo\ndecoder.decode(\"barilla.js\", 0, 25); // penne\n```\n\n## Development\n\n- Clone this repository\n- Install dependencies:\n  - `npm install`\n- Write code, add tests!\n- To build code and run tests:\n  - `npm run build`\n  - `npm run test`\n- To run lint checks prior to committing:\n  - `npm run lint`\n\n## Contributions\n\nWe :heart: contributions.\n\nHave you had a good experience with pasta-sourcemaps? Why not share some love\nand contribute code, or just let us know about any issues you had with it?\n\nWe welcome issue reports [here](../../issues); be sure to choose the proper\nissue template for your issue, so that we can be sure you're providing the\nnecessary information.\n\nBefore sending a [Pull Request](../../pulls), please make sure you read our\n[Contribution Guidelines](https://github.com/bloomberg/.github/blob/main/CONTRIBUTING.md).\n\n## License\n\n[Apache 2.0](LICENSE)\n\n## Code of Conduct\n\nThis project has adopted a\n[Code of Conduct](https://github.com/bloomberg/.github/blob/main/CODE_OF_CONDUCT.md).\nIf you have any concerns about the Code, or behavior which you have experienced\nin the project, please contact us at opensource@bloomberg.net.\n\n## Security Vulnerability Reporting\n\nIf you believe you have identified a security vulnerability in this project,\nplease send email to the project team at opensource@bloomberg.net, detailing\nthe suspected issue and any methods you've found to reproduce it.\n\nPlease do NOT open an issue in the GitHub repository, as we'd prefer to keep\nvulnerability reports private until we've had an opportunity to review and\naddress them.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbloomberg%2Fpasta-sourcemaps","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbloomberg%2Fpasta-sourcemaps","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbloomberg%2Fpasta-sourcemaps/lists"}