diff --git a/example/deno.jsonc b/example/deno.jsonc index 2c2f6e0..e191d55 100644 --- a/example/deno.jsonc +++ b/example/deno.jsonc @@ -3,8 +3,6 @@ "imports": { "react": "https://esm.sh/stable/preact@10.13.2/compat", - "preact": "https://esm.sh/stable/preact@10.13.2/", - "@deep/": "./deep/", "@eno/app": "./app.tsx", "@eno/iso": "http://localhost:4507/lib/iso.tsx" }, diff --git a/lib/hmr.tsx b/lib/hmr.tsx index 59e1d1d..198981e 100644 --- a/lib/hmr.tsx +++ b/lib/hmr.tsx @@ -1,7 +1,8 @@ let reloads = 0; const listeners = new Map() as Mapvoid>>; -new WebSocket("ws://"+document.location.host).addEventListener('message', (event) => +const socket:WebSocket = new WebSocket("ws://"+document.location.host); +socket.addEventListener('message', (event) => { let handlers = listeners.get(event.data)??[]; reloads++; @@ -13,6 +14,7 @@ new WebSocket("ws://"+document.location.host).addEventListener('message', (event }) ).then(()=>HMR.update()); }); +const socketTimer = setInterval(()=>{socket.send("ping")}, 1000); export const FileListen =(inPath:string, inHandler:()=>void)=> { diff --git a/server.tsx b/server.tsx index f912b27..ca01277 100644 --- a/server.tsx +++ b/server.tsx @@ -89,6 +89,7 @@ function Transpiler(inDevMode:boolean) : ()=>false; + let reloads = 0; const watcher =async()=> { const FilesChanged:Map = new Map(); @@ -99,6 +100,13 @@ function Transpiler(inDevMode:boolean) const key = path.substring(Deno.cwd().length).replaceAll("\\", "/"); if(action != "remove") { + if(Imports?.imports) + { + reloads++; + const importApp = Imports.imports["@eno/app"]; + const imp = await import(Path.Active+importApp+"?reloads="+reloads); + App = imp.default; + } await TranspileURL(Path.Active+key, key, false); SocketsBroadcast(key); } @@ -294,7 +302,8 @@ console.log(`Dev Mode: ${DevMode}`); console.log(`Args seen: `, Flags); const {Transpileable, TranspileURL, SocketsHandler} = Transpiler(DevMode); -const {Imports, App, TwindInst, Error} = await Configure(DevMode, Path.LibDir); +let {Imports, App, TwindInst, Error} = await Configure(DevMode, Path.LibDir); + if(Error) { console.log(Error);