Skip to content

Commit

Permalink
[api-minor] Update the minimum supported Node.js version to 18
Browse files Browse the repository at this point in the history
This patch updates the minimum supported environments as follows:
 - Node.js 18, which was released on 2022-04-19; see https://en.wikipedia.org/wiki/Node.js#Releases

Note also that Node.js 16 will soon reach EOL, and thus no longer receive any security updates.
  • Loading branch information
Snuffleupagus authored and pull[bot] committed Oct 11, 2024
1 parent a192feb commit c4c0888
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 41 deletions.
5 changes: 2 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const ENV_TARGETS = [
"Chrome >= 88",
"Firefox ESR",
"Safari >= 14.1",
"Node >= 16",
"Node >= 18",
"> 1%",
"not IE > 0",
"not dead",
Expand Down Expand Up @@ -2168,7 +2168,6 @@ function packageJson() {
},
dependencies: {
"path2d-polyfill": "^2.0.1",
"web-streams-polyfill": "^3.2.1",
},
browser: {
canvas: false,
Expand All @@ -2184,7 +2183,7 @@ function packageJson() {
url: DIST_REPO_URL,
},
engines: {
node: ">=16",
node: ">=18",
},
};

Expand Down
18 changes: 1 addition & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
"typogr": "^0.6.8",
"vinyl": "^3.0.0",
"vinyl-fs": "^3.0.3",
"web-streams-polyfill": "^3.2.1",
"webpack": "^5.80.0",
"webpack-stream": "^7.0.0",
"wintersmith": "^2.5.0",
Expand All @@ -69,7 +68,7 @@
"url": "git://github.com/mozilla/pdf.js.git"
},
"engines": {
"node": ">=16"
"node": ">=18"
},
"license": "Apache-2.0"
}
8 changes: 2 additions & 6 deletions src/core/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,10 @@ class WorkerMessageHandler {
// 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") ||
typeof ReadableStream === "undefined"
) {
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` and/or `ReadableStream`); ";
"functionality used by the PDF.js library (e.g. `Path2D`); ";

if (isNodeJS) {
throw new Error(partialMsg + "please use a `legacy`-build instead.");
Expand Down
16 changes: 3 additions & 13 deletions src/shared/compatibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,23 @@ import { isNodeJS } from "./is_node.js";
polyfillPath2D(globalThis);
})();

// Support: Node.js<18.0.0
(function checkReadableStream() {
if (globalThis.ReadableStream || !isNodeJS) {
return;
}
globalThis.ReadableStream = __non_webpack_require__(
"web-streams-polyfill/dist/ponyfill.js"
).ReadableStream;
})();

// Support: Firefox<90, Chrome<92, Safari<15.4, Node.js<16.6.0
// Support: Chrome<92, Safari<15.4
(function checkArrayAt() {
if (Array.prototype.at) {
return;
}
require("core-js/es/array/at.js");
})();

// Support: Firefox<90, Chrome<92, Safari<15.4, Node.js<16.6.0
// Support: Chrome<92, Safari<15.4
(function checkTypedArrayAt() {
if (Uint8Array.prototype.at) {
return;
}
require("core-js/es/typed-array/at.js");
})();

// Support: Firefox<94, Chrome<98, Safari<15.4, Node.js<17.0.0
// Support: Chrome<98, Safari<15.4
(function checkStructuredClone() {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("IMAGE_DECODERS")) {
// The current image decoders are synchronous, hence `structuredClone`
Expand Down

0 comments on commit c4c0888

Please # to comment.