modes #23
@ -7,7 +7,7 @@ export const CSS = {
|
||||
hash:false
|
||||
};
|
||||
|
||||
if(Deno)
|
||||
if(!window.innerWidth)
|
||||
{
|
||||
import(import.meta.resolve("../../server.tsx")).then(()=>{console.log("...imported!");});
|
||||
}
|
||||
|
26
server.tsx
26
server.tsx
@ -1,4 +1,4 @@
|
||||
import * as ESBuild from 'https://deno.land/x/esbuild@v0.14.45/mod.js';
|
||||
import * as ESBuild from 'https://deno.land/x/esbuild@v0.17.4/mod.js';
|
||||
import * as MIME from "https://deno.land/std@0.180.0/media_types/mod.ts";
|
||||
import { debounce } from "https://deno.land/std@0.151.0/async/debounce.ts";
|
||||
import { parse as JSONC} from "https://deno.land/std@0.185.0/jsonc/mod.ts";
|
||||
@ -39,7 +39,11 @@ function Transpiler(inDevMode:boolean)
|
||||
};
|
||||
const Transpile =async(inCode:string, inKey:string):Promise<string>=>
|
||||
{
|
||||
const transpile = await ESBuild.transform(inCode, inDevMode ? { loader: "tsx", sourcemap:"inline", minify: false, sourcefile:inKey} : {loader:"tsx", minify: true});
|
||||
const transpile = await ESBuild.transform(inCode, inDevMode ? { loader: "tsx", sourcemap:"inline", minify: false, sourcefile:inKey} :
|
||||
{ loader: "tsx",
|
||||
minify:true,
|
||||
jsx:"automatic",
|
||||
jsxImportSource:"https://esm.sh/preact@10.13.2"});
|
||||
|
||||
Transpiled.set(inKey, transpile.code);
|
||||
return transpile.code;
|
||||
@ -268,7 +272,17 @@ async function Configure(inDevMode:boolean, inLibPath:string)
|
||||
return output;
|
||||
}
|
||||
|
||||
let DevMode = true;
|
||||
const Flags:Record<string, string|boolean> = {};
|
||||
Deno.args.forEach(arg=>
|
||||
{
|
||||
if(arg.startsWith("--"))
|
||||
{
|
||||
const kvp = arg.substring(2).split("=");
|
||||
Flags[kvp[0]] = kvp[1] ? kvp[1] : true;
|
||||
}
|
||||
});
|
||||
|
||||
let DevMode = Flags.dev ? true : false;
|
||||
let hosted = import.meta.resolve("./");
|
||||
const Path = {
|
||||
Hosted: hosted.substring(0, hosted.length-1),
|
||||
@ -277,7 +291,7 @@ const Path = {
|
||||
};
|
||||
console.log(Path);
|
||||
console.log(`Dev Mode: ${DevMode}`);
|
||||
console.log(`Args seen: ${Deno.args}`);
|
||||
console.log(`Args seen: `, Flags);
|
||||
|
||||
const {Transpileable, TranspileURL, SocketsHandler} = Transpiler(DevMode);
|
||||
const {Imports, App, TwindInst, Error} = await Configure(DevMode, Path.LibDir);
|
||||
@ -287,7 +301,7 @@ if(Error)
|
||||
}
|
||||
else if(App && TwindInst)
|
||||
{
|
||||
Deno.serve({ port: Deno.args[0]||3000 }, async(_req:Request) =>
|
||||
Deno.serve({ port: Flags?.port||3000 }, async(_req:Request) =>
|
||||
{
|
||||
const url:URL = new URL(_req.url);
|
||||
const pathParts = url.pathname.substring(1, url.pathname.endsWith("/") ? url.pathname.length-1 : url.pathname.length).split("/");
|
||||
@ -312,7 +326,7 @@ else if(App && TwindInst)
|
||||
{
|
||||
body = await TranspileURL(Path.Hosted+url.pathname, url.pathname, true);
|
||||
}
|
||||
else if(!url.searchParams.get("reload"))
|
||||
else if(DevMode && !url.searchParams.get("reload"))
|
||||
{
|
||||
const imp = await import(Path.Active+url.pathname);
|
||||
const members = [];
|
||||
|
Loading…
Reference in New Issue
Block a user