stompjs icon indicating copy to clipboard operation
stompjs copied to clipboard

window is not defined

Open Digister opened this issue 8 years ago • 4 comments

After doing all the necessary steps in the usage instructions section, only requiring stompJs leads to an error: abc.js: const WebSocket = require('websocket').w3cwebsocket; const StompJs = require('@stomp/stompjs');

$ node abc.js c:\Users....\Desktop\node_test\node_modules@stomp\stompjs\bundles\stomp.umd.js:10 })(window, function() { ^ ReferenceError: window is not defined at Object. (c:\Users....\Desktop\node_test\node_modules@stomp\stompjs\bundles\stomp.umd.js:10:4) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object. (c:\Users....\Desktop\node_test\abc.js:2:17) at Module._compile (module.js:652:30)

ref: https://stomp-js.github.io/guide/stompjs/2018/06/28/using-stompjs-v5.html

Digister avatar Nov 21 '18 20:11 Digister

Please change it to:

const WebSocket = require('websocket').w3cwebsocket;
const StompJs = require('@stomp/stompjs/esm5');

I will update the instructions as well.

kum-deepak avatar Nov 22 '18 03:11 kum-deepak

Updated instructions at https://stomp-js.github.io/guide/stompjs/2018/06/28/using-stompjs-v5.html

Thanks for pointing out 😄

kum-deepak avatar Nov 22 '18 03:11 kum-deepak

In this case we were able to bypass it. However the underlying cause is a breaking change between webpack 3 and 4.

https://github.com/webpack/webpack/issues/6677 and https://github.com/webpack/webpack/issues/6525

I will test the workaround at https://github.com/webpack/webpack/issues/6525#issuecomment-417580843

kum-deepak avatar Nov 25 '18 16:11 kum-deepak

https://github.com/webpack/webpack/issues/6525#issuecomment-417580843 seems to resolve the issue. It will be released as part of 5.1

kum-deepak avatar Dec 04 '18 11:12 kum-deepak