Skip to content

Commit

Permalink
Fix Uncaught Type Error
Browse files Browse the repository at this point in the history
Fixes #167

Since version 0.4.9, we require `fs` but it should fail if we are in
a browser. However, `browser-source-map-support.js` is bundled with
browserify which converts unsupported builtins to empty object. See
https://github.com/substack/node-browserify/blob/8f5ebbf505/lib/builtins.js#L12
This PR checks if required `fs` contains `readFileSync` which is part
of `fs` API.
  • Loading branch information
ardeois committed Jan 16, 2017
1 parent b70e2fe commit 3facb3f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions source-map-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ var path = require('path');
var fs;
try {
fs = require('fs');
if (!fs.readFileSync || !fs.readFileSync) {
// fs doesn't have all methods we need
fs = null;
}
} catch (err) {
/* nop */
}
Expand Down

0 comments on commit 3facb3f

Please sign in to comment.