From cd2cd0ba0def7af7a8e78748cf8679b39eb65edd Mon Sep 17 00:00:00 2001 From: Nathan Breit Date: Thu, 21 Mar 2013 19:23:13 -0700 Subject: [PATCH] Fixing accidental detection of require.js as common js I changed to code to check for common js by looking for exports and module instead. Also, would it be possible to require fs inside the function where it's used? --- xlsx.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xlsx.js b/xlsx.js index e19a402..2c30633 100644 --- a/xlsx.js +++ b/xlsx.js @@ -360,9 +360,11 @@ function parseZip(zip) { var fs, jszip; if(typeof JSZip !== "undefined") jszip = JSZip; -if(typeof require !== "undefined") { - if(typeof jszip === 'undefined') jszip = require('./jszip').JSZip; - fs = require('fs'); +if (typeof exports !== 'undefined') { + if (typeof module !== 'undefined' && module.exports) { + if(typeof jszip === 'undefined') jszip = require('./jszip').JSZip; + fs = require('fs'); + } } function readSync(data, options) {