Comments (2)
I am also getting exactly same error. I am using nextjs 12 with default webpack config. I also tried
const worker = new Worker(new URL("./test.worker.js", import.meta.url), { type: 'module' });
but it also did't work.
Tested it on:
Chrome: 96.0.4664.93 (Official Build) (x86_64)
Firefox: 95.0 (64-bit)
@dandansoysauce would you kindly share your solution.
from worker-plugin.
A bit late for my reply, and also not much of a solution, but I've found that the only way for web Workers to actually work in Next.js and Webpack is to respect as closely as possible this example: https://github.com/vercel/next.js/tree/canary/examples/with-web-worker (the .babelrc file is not necessary).
Admittedly I don't know the reasons behind it (still starting out with Next.js and Webpack).
If for example you store import.meta.url
in a variable you get an opaque error like:
Security Error: Content at http://localhost:3000/ may not load data from file:///...../with-web-worker-app/worker.js.
Which happened during some tests and took some time to track down. And also if you try to create the Worker object in a separate function (say for a factory pattern) passing in the URL object as a parameter, you get another unrelated error:
SyntaxError: import declarations may only appear at top level of a module
Waiting for someone with more experience to shed some light on this.
from worker-plugin.
Related Issues (20)
- Warnings in terminal when using with vue cli (eslint + prettier configured) HOT 1
- parser.state.module.addPresentationalDependency is not a function HOT 3
- worker-plugin loader dependency not found
- Start ShareWorker from Worker
- Deprecation warning with webpack 5.42.0 HOT 1
- Using environment variables HOT 1
- entries[0].files.values is not a function
- Vue2 + Webpack not bundling? HOT 2
- Multiple functions inside a worker not supported? HOT 2
- Webpack 5: ParserHelpers.addParsedVariableToModule is not a function HOT 10
- Nested workers not resolved correctly output.publicPath is relative HOT 5
- vue use work-plugin. Error HOT 5
- Failed to using 'importScripts' on *worker.js HOT 1
- webpack build fails
- Error when using NPM module with Rollup worker bundled HOT 3
- ESLint errors for code injected by Babel HOT 6
- Angular 10, webpack, worker loader, large project HOT 3
- Are there similar plugin that support worklet? HOT 1
- SingleEntryPlugin has been removed from webpack
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from worker-plugin.