evanw / evanw/node-source-map-support

Browser hangs on new Buffer(...).toString() for large source maps

Open
#94 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.2k
Forks
223
PR merge metrics
No merged PRs in 30d

Description

Hello. Found this issue during investigation of #93. We're using webpack, so I'm guessing it might be related to webpack's `Buffer` browser polyfill? (I think it uses [feross/buffer](https://github.com/feross/buffer), which is what Browserify uses?)

For large source maps, the following [line](https://github.com/evanw/node-source-map-support/blob/master/source-map-support.js#L111) caused the browser (Chrome 44.0.2403.155 (64-bit)) to choke:

``` js
sourceMapData = new Buffer(rawData, "base64").toString();
```

I tweaked this to use [`window.atob`](https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/atob) when in the browser:

``` js
if (isInBrowser()) {
sourceMapData = window.atob(rawData);
} else {
sourceMapData = new Buffer(rawData, "base64").toString();
}
```

If you think that's a reasonable solution, I'm happy to set up a PR? (Haven't actually checked this change against the test suite yet though :sweat_smile:)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.