self.postMessage is not a function under webpack-dev-server
See original GitHub issueDo you want to request a feature or report a bug?
Bug
What is the current behavior?
Self is referring to a wrong object serviceworkerglobalscope instead of window.
PostMessage is not defined under serviceworkerglobalscope
If the current behavior is a bug, please provide the steps to reproduce.
Clone https://github.com/didi0613/electrode/tree/webpack-2.0 checkout branch webpack-2.0 npm i && npm run bootstrap goto samples/universal-react-node app npm install gulp dev
What is the expected behavior? There should be no error and pwa should work
If this is a feature request, what is motivation or use case for changing the behavior?
Please mention your webpack and Operating System version. webpack 2.2.0 wepack-dev-server 2.2.0 os: mac
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:14 (3 by maintainers)
Top Results From Across the Web
self.postMessage is not a function under webpack-dev-server -
self.postMessage is not a function under webpack-dev-server · Do you want to request a feature or report a bug? · What is the...
Read more >TypeError: e.postMessage is not a function - Stack Overflow
I'm trying to call window.postMesage from my java application for cross-origin communication with qlikview. I am getting below mentioned ...
Read more >Web Workers | webpack - JS.ORG
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser, yet it is also capable...
Read more >Uncaught TypeError: self.importScripts is not a function
在大文件上传的时候,如果在主线程操作,会导致页面卡顿,用户体验不加,就新建一个worker现成,在worker线程里面上传,主线程的交互内容不影响。
Read more >worker-loader - webpack 3 documentation
If not specified, the same public path used for other webpack assets is used. ... postMessage({ foo: 'foo' }) // Respond to message...
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

Sorry for bringing this thread back to life, but I’ve been dealing with this problem for a few days now on Webpack 3, and think I’ve narrowed it down to at least one possible solution for anyone having problems.
In my Vue project I was submitting Ajax requests from a component. In order to maintain access to update data tied to
thisfurther up in my component I usedself = thisto pass to my function. I missed thevardefinition in my markup, and Webpack’sself.postMessagewas trying to access my Vue data instead.No errors were presented on compilation since
selfwas already defined as a variable in Webpack.I have same issue, I fixed it with finding
selfvariable and make sure it redefined (usingletkeyword, e.glet self = this).