Skip to content

Commit

Permalink
fix: build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ArslanSaleem committed Oct 17, 2024
1 parent dc398a7 commit bd77305
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
8 changes: 1 addition & 7 deletions frontend/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const nextConfig = {
swcMinify: false, // TODO - track and remove this later: https://github.com/wojtekmaj/react-pdf/issues/1822
async rewrites() {
return [
{
Expand All @@ -11,13 +12,6 @@ const nextConfig = {
},
];
},
webpack: (config) => {
config.module.rules.push({
test: /\.worker\.js$/,
use: { loader: "worker-loader" },
});
return config;
},
};

export default nextConfig;
22 changes: 11 additions & 11 deletions frontend/src/ee/components/HighlightPdfViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ const HighlightPdfViewer: React.FC<PdfViewerProps> = ({

useEffect(() => {
if (typeof window !== "undefined") {
// Polyfill for Promise.withResolvers
if (typeof Promise.withResolvers === "undefined") {
if (window)
// @ts-expect-error This does not exist outside of polyfill which this is doing
window.Promise.withResolvers = function () {
let resolve, reject;
const promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
return { promise, resolve, reject };
};
// @ts-expect-error This does not exist outside of polyfill which this is doing
window.Promise.withResolvers = function () {
let resolve, reject;
const promise = new Promise((res, rej) => {
resolve = res;
reject = rej;
});
return { promise, resolve, reject };
};
}

pdfjs.GlobalWorkerOptions.workerSrc = new URL(
"pdfjs-dist/legacy/build/pdf.worker.mjs",
"pdfjs-dist/legacy/build/pdf.worker.min.mjs",
import.meta.url
).toString();
}
Expand Down

0 comments on commit bd77305

Please sign in to comment.