Skip to content
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

worker-loader support with webpack inlined #21972

Closed
ramasilveyra opened this issue Feb 8, 2021 · 9 comments
Closed

worker-loader support with webpack inlined #21972

ramasilveyra opened this issue Feb 8, 2021 · 9 comments
Labels
bug Issue was opened via the bug report template.

Comments

@ramasilveyra
Copy link
Contributor

What version of Next.js are you using?

10.0.7-canary.6

What version of Node.js are you using?

v12

What browser are you using?

Chrome

What operating system are you using?

macOs

How are you deploying your application?

Other platform

Describe the Bug

Latest next.js version with webpack inlined breaks worker-loader.

Build throws an exception.

Example:

➜  bug-repro-next-w5-inline-worker git:(main) ✗ yarn build
yarn run v1.22.5
$ next build
info  - Creating an optimized production build
Failed to compile.

./lib/hello.worker.js
TypeError: Cannot read property 'version' of undefined


> Build error occurred
Error: > Build failed because of webpack errors
    at /Users/ramirosilveyra/dev/personal/bug-repro-next-w5-inline-worker/node_modules/next/dist/build/index.js:15:918
    at async /Users/ramirosilveyra/dev/personal/bug-repro-next-w5-inline-worker/node_modules/next/dist/build/tracer.js:1:1450
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected Behavior

build to succeed

To Reproduce

Bug repro: https://github.com/ramasilveyra/bug-repro-next-w5-inline-worker

@ramasilveyra ramasilveyra added the bug Issue was opened via the bug report template. label Feb 8, 2021
@BayanBennett
Copy link

BayanBennett commented May 13, 2021

Whether inlined or not, I'm getting the same error. I'm using TypeScript

module.exports = {
  future: {
    webpack5: true,
  },
  reactStrictMode: true,
  webpack: (config) => {
    config.module.rules.unshift({
      test: /\.worker\.ts$/,
      loader: "worker-loader",
    });
    return config;
  },
};

Using a JS/TS file with new Worker(new URL(/* ... */), import.meta.url) works fine. Note that this workaround is still needed: #22813 (comment)

@thoo1
Copy link

thoo1 commented Jun 29, 2021

Did anyone manage to fix this or have a workaround?

@BayanBennett
Copy link

Did anyone manage to fix this or have a workaround?

Are you using Next v11?

I ended up continuing with the new Worker(...) syntax above.

@prvnsmpth
Copy link

@BayanBennett Could you please share an example of how you got it working using new Worker(...)? I tried that and got the exact same error (TypeError: Cannot read property 'version' of undefined).

@BayanBennett
Copy link

@prvnsmpth
Copy link

Thanks a lot!

@timneutkens
Copy link
Member

The example https://github.com/vercel/next.js/tree/canary/examples/with-web-worker has been updated to use new Worker which is supported in Next.js 11 + webpack 5.

@prvnsmpth
Copy link

@timneutkens Is there any support for SharedWorker in Next.js 11? I was able to get Worker running, but not SharedWorker.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

6 participants