evanw / evanw/node-source-map-support
Browser hangs on new Buffer(...).toString() for large source maps
- Lingua principale
- JavaScript
- Stelle
- 2.2k
- Fork
- 223
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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:)
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.