From bc288141be1ee4f92786ee64cf27dc85b6c7a229 Mon Sep 17 00:00:00 2001
From: Yury Delendik <ydelendik@mozilla.com>
Date: Mon, 20 Feb 2017 08:49:55 -0600
Subject: [PATCH] Allows to pull pdf.js from pdf_viewer using require().

---
 web/pdfjs.js | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/web/pdfjs.js b/web/pdfjs.js
index 6f891d5f0..8e5d642da 100644
--- a/web/pdfjs.js
+++ b/web/pdfjs.js
@@ -12,13 +12,22 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-/* globals module */
+/* globals module, __pdfjsdev_webpack__ */
 /* umdutils ignore */
 
 'use strict';
 
 if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('PRODUCTION')) {
-  module.exports = window['pdfjs-dist/build/pdf']; // loaded via html script tag
+  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
+    } else {
+      pdfjsLib = window['pdfjs-dist/build/pdf']; // loaded via html script tag
+    }
+  }
+  module.exports = pdfjsLib;
 } else {
   (function (root, factory) {
     if (typeof define === 'function' && define.amd) {