make _lib_ accessable

This commit is contained in:
Seth Trowbridge 2023-06-08 16:59:56 -04:00
parent a9e4c0bb35
commit 6b8a207809
4 changed files with 17 additions and 17 deletions

View File

@ -31,18 +31,8 @@ Configure({
});
return inImports;
},
async Serve(inReq, inURL, inExt, inMap)
Serve(inReq, inURL, inExt, inMap)
{
if(inURL.pathname.startsWith("/hmr/"))
{
const path = import.meta.url+"/.."+inURL.pathname;
const code = await Transpile.Fetch(path, inURL.pathname, true);
if(code)
{
return new Response(code, {headers:{"content-type":"application/javascript"}})
}
}
if(inReq.headers.get("upgrade") == "websocket")
{
try
@ -54,9 +44,7 @@ Configure({
socket.onerror = (e) => console.log("Socket errored:", e);
return response;
}
catch(e)
{
}
catch(e){ /**/ }
}
}
});
@ -92,4 +80,4 @@ for await (const event of Deno.watchFs(Deno.cwd()))
}
, 1000);
}
}
}

View File

@ -178,8 +178,20 @@ HTTP.serve(async(req: Request)=>
// transpileable files
if(Transpile.Check(ext))
{
const lookup = await Transpile.Fetch(Configuration.Proxy + url.pathname, url.pathname);
return new Response(lookup, {status:lookup?200:404, headers:{...headers, "content-type":"application/javascript"}} );
if(url.pathname.startsWith("/_lib_/"))
{
const path = import.meta.url+"/.."+url.pathname;
const code = await Transpile.Fetch(path, url.pathname, true);
if(code)
{
return new Response(code, {headers:{"content-type":"application/javascript"}});
}
}
else
{
const lookup = await Transpile.Fetch(Configuration.Proxy + url.pathname, url.pathname);
return new Response(lookup, {status:lookup?200:404, headers:{...headers, "content-type":"application/javascript"}} );
}
}
// all other static files