@rspack/dev-client
Advanced tools
Comparing version 0.0.0-20221026015301 to 0.0.0-20221028024548
# @rspack/dev-client | ||
## 0.0.0-20221026015301 | ||
## 0.0.0-20221028024548 | ||
### Patch Changes | ||
- Updated dependencies [e6d0926a2] | ||
- @rspack/core@0.0.0-20221026015301 | ||
- Updated dependencies [e6d0926a] | ||
- @rspack/core@0.0.0-20221028024548 |
@@ -9,5 +9,32 @@ "use strict"; | ||
// const socketURL = createSocketURL(parsedResourceQuery as any); | ||
function reloadApp(data) { | ||
// @ts-ignore | ||
self.__rspack_runtime__.__rspack_require__.hmrM = () => { | ||
return new Promise(resolve => { | ||
const { uri, content } = JSON.parse(data); | ||
const update = { | ||
c: ["main"], | ||
r: [], | ||
m: [], | ||
// TODO: remove this after hash | ||
updatedModule: { | ||
uri, | ||
content: `self["hotUpdate"]( | ||
"main", | ||
{ | ||
"${uri}": function (module, exports, __rspack_require__) { ${content} } | ||
} | ||
)` | ||
} | ||
}; | ||
resolve(update); | ||
}); | ||
}; | ||
// @ts-ignore | ||
self.__rspack_runtime__.hotEmitter.emit("hotUpdate"); | ||
} | ||
const onSocketMessage = { | ||
ok: function () { | ||
console.log("hit ok"); | ||
// TODO: remove data after jsonp | ||
ok: function (data) { | ||
reloadApp(data); | ||
}, | ||
@@ -21,3 +48,3 @@ close: function () { | ||
}; | ||
(0, socket_1.default)(`ws://${location.host}`, onSocketMessage); | ||
(0, socket_1.default)(`ws://${location.host}/ws`, onSocketMessage); | ||
//# sourceMappingURL=index.js.map |
export interface Handler { | ||
ok(): void; | ||
ok(data: any): void; | ||
close(): void; | ||
@@ -4,0 +4,0 @@ "static-changed"(): void; |
@@ -30,3 +30,2 @@ "use strict"; | ||
const message = JSON.parse(data); | ||
console.log("hit messge", message); | ||
if (handlers[message.type]) { | ||
@@ -33,0 +32,0 @@ handlers[message.type](message.data, message.params); |
{ | ||
"name": "@rspack/dev-client", | ||
"description": "", | ||
"version": "0.0.0-20221026015301", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"version": "0.0.0-20221028024548", | ||
"author": "", | ||
@@ -14,7 +12,12 @@ "license": "ISC", | ||
"dependencies": { | ||
"ws": "8.8.1" | ||
"ws": "8.8.1", | ||
"events": "3.3.0" | ||
}, | ||
"peerDependencies": { | ||
"@rspack/core": "0.0.0-20221026015301" | ||
"@rspack/core": "0.0.0-20221028024548" | ||
}, | ||
"exports": { | ||
".": "./dist/index.js", | ||
"./devServer": "./dist/devServer.js" | ||
}, | ||
"scripts": { | ||
@@ -21,0 +24,0 @@ "build": "tsc", |
@@ -9,5 +9,33 @@ import socket from "./socket"; | ||
function reloadApp(data: string) { | ||
// @ts-ignore | ||
self.__rspack_runtime__.__rspack_require__.hmrM = () => { | ||
return new Promise(resolve => { | ||
const { uri, content } = JSON.parse(data); | ||
const update = { | ||
c: ["main"], | ||
r: [], | ||
m: [], | ||
// TODO: remove this after hash | ||
updatedModule: { | ||
uri, | ||
content: `self["hotUpdate"]( | ||
"main", | ||
{ | ||
"${uri}": function (module, exports, __rspack_require__) { ${content} } | ||
} | ||
)` | ||
} | ||
}; | ||
resolve(update); | ||
}); | ||
}; | ||
// @ts-ignore | ||
self.__rspack_runtime__.hotEmitter.emit("hotUpdate"); | ||
} | ||
const onSocketMessage: Handler = { | ||
ok: function (): void { | ||
console.log("hit ok"); | ||
// TODO: remove data after jsonp | ||
ok: function (data): void { | ||
reloadApp(data); | ||
}, | ||
@@ -22,2 +50,2 @@ close: function (): void { | ||
socket(`ws://${location.host}`, onSocketMessage); | ||
socket(`ws://${location.host}/ws`, onSocketMessage); |
import { createWebSocketClient } from "./ws"; | ||
export interface Handler { | ||
ok(): void; | ||
// TODO: remove data after jsonp | ||
ok(data: any): void; | ||
close(): void; | ||
@@ -48,4 +49,2 @@ "static-changed"(): void; | ||
const message = JSON.parse(data); | ||
console.log("hit messge", message); | ||
if (handlers[message.type]) { | ||
@@ -52,0 +51,0 @@ handlers[message.type](message.data, message.params); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
71959
49
834
3
+ Addedevents@3.3.0
+ Added@rspack/binding@0.0.0-20221028024548(transitive)
+ Added@rspack/core@0.0.0-20221028024548(transitive)
+ Addedevents@3.3.0(transitive)
+ Addedreact-refresh@0.14.0(transitive)
- Removed@rspack/binding@0.0.0-20221026015301(transitive)
- Removed@rspack/core@0.0.0-20221026015301(transitive)