Skip to content

Commit

Permalink
patch(hmr): use hostname for WS instantiation (#426)
Browse files Browse the repository at this point in the history
* patch(hmr): use hostname for WS instantiation

* test(hmr): add hostname shim for testing

* Move location shim somewhere common
  • Loading branch information
ksafranski authored and devongovett committed Dec 29, 2017
1 parent 8a65676 commit 06d5ffc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/builtins/hmr-runtime.js
Expand Up @@ -15,7 +15,7 @@ function Module() {
module.bundle.Module = Module;

if (!module.bundle.parent && typeof WebSocket !== 'undefined') {
var ws = new WebSocket('ws://localhost:{{HMR_PORT}}/');
var ws = new WebSocket('ws://' + window.location.hostname + ':{{HMR_PORT}}/');
ws.onmessage = function(event) {
var data = JSON.parse(event.data);

Expand Down
5 changes: 4 additions & 1 deletion test/utils.js
Expand Up @@ -78,11 +78,14 @@ function run(bundle, globals) {
{
document: fakeDocument,
WebSocket,
console
console,
location: {hostname: 'localhost'}
},
globals
);

ctx.window = ctx;

vm.createContext(ctx);
vm.runInContext(fs.readFileSync(bundle.name), ctx);
return ctx.require(bundle.entryAsset.id);
Expand Down

0 comments on commit 06d5ffc

Please sign in to comment.