From 1753e321cd1b62198925741ba902e8e92de19e6c Mon Sep 17 00:00:00 2001
From: Jonas Jenwald <jonas.jenwald@gmail.com>
Date: Fri, 14 Apr 2023 21:32:09 +0200
Subject: [PATCH] Remove the compatibility checks in
 `WorkerMessageHandler.createDocumentHandler`

For some time these checks have only targeted Node.js environments, since the features in question exist in all supported browsers (even when a `legacy`-build is used).

Now that we've updated the minimum supported Node.js version to 18, a number of polyfills are thus (finally) no longer necessary in that environment. Hence for certain *basic* functionality, such as e.g. text-extraction, it's now possible to use either a modern- or a `legacy`-build of the PDF.js library in Node.js environments.

*Please note:* For e.g. canvas-rendering in Node.js environments it's still necessary to use a `legacy`-build, since that functionality requires various polyfills.
---
 gulpfile.js        |  2 --
 src/core/worker.js | 14 --------------
 2 files changed, 16 deletions(-)

diff --git a/gulpfile.js b/gulpfile.js
index 4d574269f..a25dd399c 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -2165,8 +2165,6 @@ function packageJson() {
     license: DIST_LICENSE,
     optionalDependencies: {
       canvas: "^2.11.2",
-    },
-    dependencies: {
       "path2d-polyfill": "^2.0.1",
     },
     browser: {
diff --git a/src/core/worker.js b/src/core/worker.js
index b5b2f5059..d4b028156 100644
--- a/src/core/worker.js
+++ b/src/core/worker.js
@@ -129,20 +129,6 @@ class WorkerMessageHandler {
             "; thus breaking e.g. `for...in` iteration of `Array`s."
         );
       }
-
-      // Ensure that (primarily) Node.js users won't accidentally attempt to use
-      // a non-translated/non-polyfilled build of the library, since that would
-      // quickly fail anyway because of missing functionality.
-      if (isNodeJS && typeof Path2D === "undefined") {
-        const partialMsg =
-          "The browser/environment lacks native support for critical " +
-          "functionality used by the PDF.js library (e.g. `Path2D`); ";
-
-        if (isNodeJS) {
-          throw new Error(partialMsg + "please use a `legacy`-build instead.");
-        }
-        throw new Error(partialMsg + "please update to a supported browser.");
-      }
     }
     const workerHandlerName = docId + "_worker";
     let handler = new MessageHandler(workerHandlerName, docId, port);