[worker-loader] window is not defined
See original GitHub issueVersion
3.0.1
Reproduction link
https://github.com/screendriver/vue-cli-worker-loader-bug
Node and OS info
Node 10.9.0 / yarn 1.9.4 / macOS high sierra
Steps to reproduce
Just do a yarn serve and open http://localhost:8080 in your browser. You can see the error immediately.
What is expected?
Should not throw Uncaught ReferenceError: window is not defined.
What is actually happening?
Throws the error and doesn’t work.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Webpack 4.0.1 | WebWorker window is not defined #6642
When requiring web-worker (using worker-loader) recieve error Uncaught ReferenceError: window is not defined .
Read more >Webpack worker-loader - import doesn't work - Stack Overflow
I understand that my problem is that window is not defined in web workers. The problem is that this error appear when I...
Read more >"not defined" window in web worker. Is this a bug?
I am running into an issue trying to load a model into a web-worker via the indexedDB. Specifically, I am getting a ReferenceError:...
Read more >#5 - Does not work in web worker - atob.js - CoolAJ86 on GIT
Uncaught ReferenceError : window is not defined browser-atob.js:44 ... Is atob defined on... self or whatever it is that workers have? Does globalThis...
Read more >Web Workers API - Web APIs - MDN Web Docs - Mozilla
While Window is not directly available to workers, many of the same methods are defined in a shared mixin ( WindowOrWorkerGlobalScope ) ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

this work for me, add to vue.config.js
configureWebpack: { output: { globalObject: 'this', }, },I ran into similar issues in a worker-loader + webpack-worker-wrapper setup. You can work around it by adding this to your vue.config.js :
… and doing something like this in your worker.js files :
and in workerGlobals.js