Skip to content

Commit

Permalink
Make node requires conditional
Browse files Browse the repository at this point in the history
This converts the webpack errors to warnings. Individual users may use the ignore plugin to further mute these warnings.

Fixes #150
Fixes #153
  • Loading branch information
kpdecker committed Dec 28, 2016
1 parent f4c2bf2 commit 9999e1d
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions source-map-support.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var SourceMapConsumer = require('source-map').SourceMapConsumer;
var path = require('path');
var fs = require('fs');

// Only install once if called multiple times
var errorFormatterInstalled = false;
Expand Down Expand Up @@ -72,7 +71,7 @@ retrieveFileHandlers.push(function(path) {

// Otherwise, use the filesystem
else {
var contents = fs.readFileSync(path, 'utf8');
var contents = require('fs').readFileSync(path, 'utf8');
}
} catch (e) {
var contents = null;
Expand Down Expand Up @@ -460,7 +459,12 @@ exports.install = function(options) {

// Support runtime transpilers that include inline source maps
if (options.hookRequire && !isInBrowser()) {
var Module = require('module');
var Module;
try {
Module = require('module');
} catch (err) {
// NOP: Loading in catch block to convert webpack error to warning.
}
var $compile = Module.prototype._compile;

if (!$compile.__sourceMapSupport) {
Expand Down

0 comments on commit 9999e1d

Please sign in to comment.