`next dev` fails with webpack error when importing functions inside web worker
See original GitHub issueWhat version of Next.js are you using?
10.2.3
What version of Node.js are you using?
16.2.0
What browser are you using?
Firefox
What operating system are you using?
macOS
How are you deploying your application?
next dev
Describe the Bug
Using a web worker, similar to the with-web-worker example. The web worker file (located under worker/search.js
) imports functions from another local file like this:
import { getIndexRange, getTextItemWithNeighbors } from '../lib/search';
Which then results in the following error with Next.js >=10.2.1:
error - webpack/runtime/compat
The "path" argument must be of type string. Received undefined
I’m able to resolve this error by in-lining the functions directly in the web worker file (worker/search.js
) instead of importing them.
This issue appeared with v10.2.1-canary.9, so probably introduced by https://github.com/vercel/next.js/pull/25035. It used to work before.
Expected Behavior
I would like to be able to import the functions in the web worker file without an error, as it used to work in the past.
To Reproduce
Honestly, it’s pretty hard to reproduce this issue… I’ve tried to apply a similar structure as in my project to the with-web-worker example, but wasn’t able to reproduce it. Maybe @nemanja-tosic (https://github.com/vercel/next.js/issues/25276#issuecomment-847681082) has some clues about it…
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:35 (4 by maintainers)
OMG, unbelieve that I was able to reproduce this. It happens when there are 2 different webworker sharing same dependencies.
https://github.com/Lagz0ne/web-worker-build-error
Those backgrounds are sharing those imports and those imports exceed a certain size threshold (the data file is pretty big). Only then the
yarn build
yellsIt won’t happen if we remove that data from the background bundle.
And,
yarn dev
works.yarn build
yells that errorNext version is 11.0.1
@balazsorban44 You’ve got to be kidding, we’ve got several reproductions and this is impacting lots of people in production. I’ve brought this up with our company’s account rep repeatedly and been ignored, and here it also seems to be something the team would rather ignore than seriously look at our reproductions and solve.