Skip to content

Commit

Permalink
feat: keep browser support in serverless build
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Sep 5, 2023
1 parent f7f94b3 commit 49c3fb0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pdfjs.rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ export default defineConfig({
delimiters: ["", ""],
preventAssignment: true,
values: {
// Remove all references to the DOM
// Disable the `window` check (for requestAnimationFrame)
"typeof window": '"undefined"',
"typeof document": '"undefined"',
// Imitate the Node.js environment, unenv will take care of the rest
"const isNodeJS = typeof": "const isNodeJS = true // typeof",
// Replace the `isNodeJS` check to tree-shake some code
"_util.isNodeJS": "true",
// Inline the PDF.js worker
// Imitate the Node.js environment for all serverless environments, unenv will
// take care of the remaining Node.js polyfills. Keep support for browsers.
"const isNodeJS = typeof":
'const isNodeJS = typeof document === "undefined" // typeof',
// Force inlining the PDF.js worker
'_util.isNodeJS && typeof require === "function"': "true",
'GlobalWorkerOptions.workerSrc = ""':
'GlobalWorkerOptions.workerSrc = require("pdfjs-dist/build/pdf.worker.js")',
'eval("require")(this.workerSrc)':
Expand Down

0 comments on commit 49c3fb0

Please sign in to comment.