1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 09:38:06 +02:00

[api-minor] Remove the, in legacy builds, bundled ReadableStream polyfill

According to the MDN compatibility data, see https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream#browser_compatibility, all browsers that we support have native `ReadableStream` implementations (since quite some time too).

Hence only Node.js is now lagging behind w.r.t. `ReadableStream` support, and its experimental implementation doesn't really help us given the life-span of the LTS releases (see https://en.wikipedia.org/wiki/Node.js#Releases).
It seems quite unfortunate to bundle a `ReadableStream` polyfill in the `legacy` builds when it's unnecessary in browsers, given its overall size, but fortunately we can avoid that by simply listing `web-streams-polyfill` as a dependency for the `pdfjs-dist` library.
This commit is contained in:
Jonas Jenwald 2022-02-12 17:30:39 +01:00
parent e9fd67a3f6
commit b89595fd20
5 changed files with 19 additions and 25 deletions

View file

@ -133,15 +133,15 @@ 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 (
(typeof PDFJSDev === "undefined" || PDFJSDev.test("SKIP_BABEL")) &&
typeof ReadableStream === "undefined"
) {
throw new Error(
if (typeof ReadableStream === "undefined") {
const partialMsg =
"The browser/environment lacks native support for critical " +
"functionality used by the PDF.js library (e.g. `ReadableStream`); " +
"please use a `legacy`-build instead."
);
"functionality used by the PDF.js library (e.g. `ReadableStream`); ";
if (isNodeJS) {
throw new Error(partialMsg + "please use a `legacy`-build instead.");
}
throw new Error(partialMsg + "please update to a supported browser.");
}
}