mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 14:48:08 +02:00
[api-minor] Attempt to improve support for using the PDF.js builds with Vite
Similar to Webpack there's apparently other bundlers that will not leave `import`-calls alone unless magic comments are used. Hence we extend the builder to also append `/* @vite-ignore */` comments to `import`-calls, in order to attempt to improve support for using the PDF.js builds together with Vite. This patch also renames `__non_webpack_import__` to `__raw_import__` since the functionality is no longer bundler-specific. ***PLEASE NOTE:*** This patch is provided as-is, and it does *not* mean that the PDF.js project can/will provide official support for Vite.
This commit is contained in:
parent
34136d7775
commit
8bcc3664c9
8 changed files with 19 additions and 12 deletions
|
@ -286,7 +286,7 @@ const PDFViewerApplication = {
|
|||
const { PDFBug } =
|
||||
typeof PDFJSDev === "undefined"
|
||||
? await import(AppOptions.get("debuggerSrc")) // eslint-disable-line no-unsanitized/method
|
||||
: await __non_webpack_import__(AppOptions.get("debuggerSrc"));
|
||||
: await __raw_import__(AppOptions.get("debuggerSrc"));
|
||||
|
||||
this._PDFBug = PDFBug;
|
||||
};
|
||||
|
@ -299,7 +299,7 @@ const PDFViewerApplication = {
|
|||
if (typeof PDFJSDev === "undefined") {
|
||||
globalThis.pdfjsWorker = await import("pdfjs/pdf.worker.js");
|
||||
} else {
|
||||
await __non_webpack_import__(PDFWorker.workerSrc);
|
||||
await __raw_import__(PDFWorker.workerSrc);
|
||||
}
|
||||
} catch (ex) {
|
||||
console.error("_parseHashParams:", ex);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue