sourcemap-view

1.0.11 • Public • Published

sourcemap-view

View the original code from the sourcemap based on the error lineno and colno.

Installation

npm install sourcemap-view

Why would you want to do that?

When js throws an exception, we can view the original code without Chrome Console or Other.

Uncaught TypeError: Cannot read property 'a' of undefined
    at a.getSameError (app.07cd8612.js:1:3842)
    at app.07cd8612.js:1:3357

Usage

const fs = require('fs');
const sourcemapView = require('sourcemap-view');
 
const sourcemapRaw = fs.readFileSync('./app.07cd8612.js.map', { encoding: 'utf-8'});
 
const view = sourcemapView(JSON.parse(sourcemapRaw));
 
view(1, 3842); // { file: './HelloWorld.js', lineNo: 43, colNo: 29, name: 'a', content: <Original Code> }
view(1, 3357); // { file: './HelloWorld.js', lineNo: 35, colNo: 0, name: 'setTimeout', content: <Original Code> }

License

MIT.

Package Sidebar

Install

npm i sourcemap-view

Weekly Downloads

2

Version

1.0.11

License

MIT

Unpacked Size

11.7 kB

Total Files

6

Last publish

Collaborators

  • vilien