Skip to content

1. modify sourceMap regExp 2.dont't edit source map - #42

Open
yeatszhang wants to merge 2 commits into
hughsk:masterfrom
yeatszhang:master
Open

1. modify sourceMap regExp 2.dont't edit source map#42
yeatszhang wants to merge 2 commits into
hughsk:masterfrom
yeatszhang:master

Conversation

@yeatszhang

Copy link
Copy Markdown
  1. some times sourceMapUrl have a charset field
  2. do not need to modify generated sourceMap

When I use uglifyify writing a browserify plugin.
It do not work.

function createRevStream(dest, revdest, debug) {
  var min = uglifyify(dest, { sourcemap: true }).pipe(exorcist(dest + '.map'));
  var out = fs.createWriteStream(revdest)
  var s = through(function write(buf, enc, next) {
    min.write(buf)
    next()
  }, function end(next) {
    out.on('finish', next)
    min.end()
  })
  out.on('error', s.emit.bind(s, 'error'))
  min.pipe(out)
  return s
}

I found the problem is the source map browserify generated has a chartset field so matched is null

sourceMappingURL=data:application\/json;charset:utf-8;base64.

I modified the RegExp but it still do not work.

After reading the uglifyjs api, I though it is no need to add these code

var map = convert.fromJSON(min.map)
map.setProperty('sources', [file])
map.setProperty('sourcesContent', matched
  ? opts.inSourceMap.sourcesContent
  : [buffer]
)

I removed these code and it works well. 囧

张亦驰 added 2 commits November 17, 2015 17:45
2. do not need to modify generated sourceMap
@weilu

weilu commented Dec 13, 2015

Copy link
Copy Markdown
Collaborator

LGTM, granted I'm not familiar with sourcemap. Ping @hughsk, can you take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants