Skip to content

sourcemap生成格式错误,导致还原失败 #1822

@GendSmith

Description

@GendSmith

productionSourceMap: true的时候,sourcemap生成格式错误,mappings缺少分号

**mpvue 版本号:2.0.0

最小化复现代码:

[建议提供最小化可运行的代码:附件或文本代码]
直接用快速上手的demo就可以复现http://mpvue.com/mpvue/quickstart.html

// 还原脚本
const fs = require('fs')
const SourceMap = require('source-map')


async function originalPositionFor(line, column) {
   const sourceMapFilePath = "/Users/smithdeng/Desktop/testd/mpvue_demo_to_reappear_sourcemap_bug/reappear_sourcemap_bug/dist/wx/app.js.map"
   const sourceMapConsumer = await new SourceMap.SourceMapConsumer
                            (JSON.parse(fs.readFileSync(sourceMapFilePath, 'utf8')))
   const res = sourceMapConsumer.originalPositionFor({
      line,
      column,
   })
   console.log(res)
}

originalPositionFor(3,506)

问题复现步骤:

  1. 下载快速上手的demo,http://mpvue.com/mpvue/quickstart.html
  2. 把config/index.js的productionSourceMap改成true
  3. npm run build:wx

观察到的表现:
dist目录下生成的map文件的mappings缺少分号,无法使用map来还原

我手动把分号补齐之后,就可以还原成功了

请看下图:

截图或动态图:
image

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions