-
Notifications
You must be signed in to change notification settings - Fork 27k
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
new Worker() doesn't work with Nextjs version 12.0.8 #33217
Comments
You might have opened this in the wrong repo or the reproduction is not complete, I see a Create React App codebase. Could you please add a proper reproduction? 🙏 |
Hi @balazsorban44 , I have created a sample repo using It will give the error error - ReferenceError: Worker is not defined I have taken the sample code given by wasm-imagemagick. You can check their working example here https://codesandbox.io/s/wasm-imagemagick-basic-demo-y00u2. It is working fine with React but not with NextJS |
So there seem to be a few issues. Since From their docs, it seems that this is not something const Magick = await import("wasm-imagemagick") This way it only gets imported when being used (in the browser). This brings up a different error though: SecurityError: Failed to construct 'Worker': Script at 'webpack-internal:///./node_modules/wasm-imagemagick/dist/src/magick.js' cannot be accessed from origin 'http://localhost:3000'. Which I'm not entirely sure about, but in their README there is this section with an IMPORTANT note to copy some files from I also found a more up-to-date package that seems to have the same purpose, you could test that one out: https://github.com/dlemstra/magick-wasm For reference, So the issue is specific to |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Run
next info
(available from version 12.0.8 and up)What version of Next.js are you using?
12.0.8
What version of Node.js are you using?
16.13.1
What browser are you using?
Chrome Version 97.0.4692.71 (Official Build) (64-bit)
What operating system are you using?
Windows 10
How are you deploying your application?
Other
Describe the Bug
Nextjs gives the below error while importing wasm-imagemagick package
ReferenceError: Worker is not defined on the following line when I import that package in my component
import { execute} from 'wasm-imagemagick'
if (currentJavascriptURL.startsWith('http')) { magickWorker = new Worker(window.URL.createObjectURL(new Blob([GenerateMagickWorkerText(magickWorkerUrl)]))); } else { magickWorker = new Worker(magickWorkerUrl); }
How can I import packages which have new Worker syntax in them, Do I have to make any changes in next.config.js
Expected Behavior
I should be able to import packages.
To Reproduce
Run this code with Nextjs
https://codesandbox.io/s/wasm-imagemagick-basic-demo-y00u2
The text was updated successfully, but these errors were encountered: