Skip to content

Commit 3aeef84

Browse files
committed
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.
1 parent 224613a commit 3aeef84

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

web/pdfjs.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PRODUCTION')) {
2121
var pdfjsLib;
2222
// The if below protected by __pdfjsdev_webpack__ check from webpack parsing.
2323
if (typeof __pdfjsdev_webpack__ === 'undefined') {
24-
if (typeof require === 'function') {
25-
pdfjsLib = require('../build/pdf.js'); // using a bundler to pull the core
24+
if (typeof window !== 'undefined' && window['pdfjs-dist/build/pdf']) {
25+
pdfjsLib = window['pdfjs-dist/build/pdf'];
26+
} else if (typeof require === 'function') {
27+
pdfjsLib = require('../build/pdf.js');
2628
} else {
27-
pdfjsLib = window['pdfjs-dist/build/pdf']; // loaded via html script tag
29+
throw new Error('Neither `require` nor `window` found');
2830
}
2931
}
3032
module.exports = pdfjsLib;

0 commit comments

Comments
 (0)