Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

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

wants to merge 2 commits into from

Conversation

yeatszhang
Copy link

  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
Copy link
Collaborator

weilu commented Dec 13, 2015

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