sourcemap-stacktrack-parser

0.0.3 • Public • Published

Sourcemap-Stacktrack-Parser

Codecov CoverageBuild StatusGitHub All ReleasesNPM

解析Stacktrack中的源码位置

根据sourcemap将解析stacktrack

Installing / Getting started

npm i sourcemap-stacktrack-parser
// ======== Input Data =======
const error = {
  stack:
    "ReferenceError: xxx is not defined\n" +
    "    at http://localhost:7001/public/bundle.e7877aa7bc4f04f5c33b.js:1:1392\n",
  message: "Uncaught ReferenceError: xxx is not defined", // 非必须
  filename: "http://localhost:7001/public/bundle.e7877aa7bc4f04f5c33b.js" // 非必须
};
// ====== Run ==========
const parser = new StackParser(resolve(__dirname, "./sourcemapFolder")); //sourcemap文件位置
const originStack = await parser.parseOriginStackTrack(
      error.stack,
      error.message
    );
// ====== Result =========
[{
      source: "webpack:///src/index.js",
      line: 24,
      column: 4,
      name: "xxx"
}]

Readme

Keywords

none

Package Sidebar

Install

npm i sourcemap-stacktrack-parser

Weekly Downloads

3

Version

0.0.3

License

MIT

Unpacked Size

116 kB

Total Files

17

Last publish

Collaborators

  • josephxia