Changing the order of logical conditions to prefer 'window' in the case where webpack is not used.

Updating brace style.

Updating to throw new error vs. throwing a string.
This commit is contained in:
River Lune 2017-03-11 07:58:56 -08:00
parent 224613a511
commit 3aeef8402b

View File

@ -21,10 +21,12 @@ if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PRODUCTION')) {
var pdfjsLib;
// The if below protected by __pdfjsdev_webpack__ check from webpack parsing.
if (typeof __pdfjsdev_webpack__ === 'undefined') {
if (typeof require === 'function') {
pdfjsLib = require('../build/pdf.js'); // using a bundler to pull the core
if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
pdfjsLib = window['pdfjs-dist/build/pdf'];
} else if (typeof require === 'function') {
pdfjsLib = require('../build/pdf.js');
} else {
pdfjsLib = window['pdfjs-dist/build/pdf']; // loaded via html script tag
throw new Error('Neither `require` nor `window` found');
}
}
module.exports = pdfjsLib;