-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pdfjs-dist fails to compile with Turbopack (webpackIgnore comment not respected) #65406
Comments
This issue came out of #63385 (comment) |
This comment was marked as off-topic.
This comment was marked as off-topic.
@enricoros adding screenshots of CLI output is not helpful in general. If you want to share that you're running into the same issue you can use GitHub's emoji reactions on the initial post to add a 👍 Thanks! |
@timneutkens this is the only thing preventing me from using turbopack with |
Used bun patch for a workaround. patch-package should work too. diff --git a/build/pdf.mjs b/build/pdf.mjs
--- a/build/pdf.mjs
+++ b/build/pdf.mjs
@@ -11936,7 +11936,8 @@ class PDFWorker {
if (this.#mainThreadWorkerMessageHandler) {
return this.#mainThreadWorkerMessageHandler;
}
- const worker = await import( /*webpackIgnore: true*/this.workerSrc);
+ // https://github.com/vercel/next.js/issues/65406
+ const worker = await import( /*webpackIgnore: true*/this.workerSrc ?? "./pdf.worker.mjs");
return worker.WorkerMessageHandler;
};
return shadow(this, "_setupFakeWorkerGlobal", loader()); |
It seems Vercel has made progress in handling Workers within Turbopack. As of Next.js 15.0.0-canary.148, the previously reported error has been resolved. This error was still present in canary.146, but no longer appears in the latest canary release. Thx! |
Thanks for checking @gurkerl83 this issue has indeed been resolved, we added support for Related PR: #69768 |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/pdf-viewer-forked-h3gdsc?file=%2Fcomponents%2FTestPage.tsx
To Reproduce
Module not found
(example: https://h3gdsc-3000.csb.app/)Current vs. Expected behavior
pdfjs-dist
ships with a webpack specific ignore comment (:til: that is a feature) as they useimport()
to load a file based on an option being passed in.Specifically
const worker = await import(/* webpackIgnore: true */ this.workerSrc);
fails to compile as it can't findthis.workerSrc
statically.I'm not sure what the best behavior is for this, adding support for the comment or ignoring such imports when they don't include a path.
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP PREEMPT_DYNAMIC Sun Aug 6 20:05:33 UTC 2023 Available memory (MB): 4102 Available CPU cores: 2 Binaries: Node: 20.12.0 npm: 10.5.0 Yarn: 1.22.19 pnpm: 8.15.6 Relevant Packages: next: 14.3.0-canary.40 // Latest available version is detected (14.3.0-canary.40). eslint-config-next: 14.1.0 react: 18.2.0 react-dom: 18.2.0 typescript: 5.3.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Turbopack
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local), next start (local), Vercel (Deployed), Other (Deployed)
Additional context
This is failing on all versions with Turbopack as it doesn't support the ignore comment.
PACK-3046
The text was updated successfully, but these errors were encountered: