Skip to content

Commit

Permalink
Work even when 'fs' not available for require;
Browse files Browse the repository at this point in the history
and don't let webpack trip on it either (by using string variable as require argument which prevents static analysis/bundling failure).
  • Loading branch information
Lance committed Sep 17, 2018
1 parent b642ec7 commit 879947d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/html-to-text.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
var fs = require('fs');
var fs;
try {
var fsStr = 'fs'; // helps with webpack
fs = require(fsStr);
} catch(e) {
fs = {
readFile: function(file, enc, callback) {
callback('failed to require fs');
}
};
}
var util = require('util');

var includes = require('lodash/includes');
Expand Down

0 comments on commit 879947d

Please sign in to comment.