From c44c1df257a6f52dc99f9da3fe3b1fec4330a9ac Mon Sep 17 00:00:00 2001 From: Seth Trowbridge Date: Thu, 12 Oct 2023 22:47:45 -0400 Subject: [PATCH] misc items --- checker.tsx | 1 + cli.tsx | 5 ++-- deno.jsonc | 5 ++-- hmr-signal.tsx | 0 run-browser.tsx | 2 +- run-local.tsx | 4 +++ run-serve.tsx | 79 ------------------------------------------------- 7 files changed, 12 insertions(+), 84 deletions(-) create mode 100644 hmr-signal.tsx diff --git a/checker.tsx b/checker.tsx index a5f1100..76287b0 100644 --- a/checker.tsx +++ b/checker.tsx @@ -170,6 +170,7 @@ export async function Check() importMap["react"] = `https://esm.sh/preact@10.17.1/compat`; importMap["react/"] = `https://esm.sh/preact@10.17.1/compat/`; importMap["@preact/signals"] = `https://esm.sh/@preact/signals@1.2.1`; + importMap["@twind/core"] = `https://esm.sh/@twind/core@1.1.3`; importMap[">able/"] = `${RootHost}`; if(!importMap[">able/app.tsx"]) { diff --git a/cli.tsx b/cli.tsx index 13b9f3e..931c240 100644 --- a/cli.tsx +++ b/cli.tsx @@ -123,9 +123,10 @@ if(arg._.length) `--project=${useProject}`, `--token=${useToken}`, `--import-map=${imports.path}`, - RootHost+"run.tsx", + ...scanProd, - ...Deno.args]); + ...Deno.args, + RootHost+"run.tsx"]); } case "upgrade" : { diff --git a/deno.jsonc b/deno.jsonc index 95b17a3..8e0c78d 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -2,9 +2,10 @@ "imports": { "react": "https://esm.sh/preact@10.17.1/compat", "react/": "https://esm.sh/preact@10.17.1/compat/", + "@preact/signals": "https://esm.sh/@preact/signals@1.2.1", + "@twind/core": "https://esm.sh/@twind/core@1.1.3", ">able/": "http://localhost:4507/", - ">able/app.tsx": "./app.tsx", - "@preact/signals": "https://esm.sh/@preact/signals@1.2.1" + ">able/app.tsx": "./app.tsx" }, "tasks": { "check": "deno run -A --no-lock http://localhost:4507/cli.tsx check", diff --git a/hmr-signal.tsx b/hmr-signal.tsx new file mode 100644 index 0000000..e69de29 diff --git a/run-browser.tsx b/run-browser.tsx index 018f55d..cf064c4 100644 --- a/run-browser.tsx +++ b/run-browser.tsx @@ -1,5 +1,5 @@ import React from "react"; -import * as TW from "https://esm.sh/v126/@twind/core@1.1.3/es2022/core.mjs"; +import * as TW from "@twind/core"; import TWPreTail from "https://esm.sh/v126/@twind/preset-tailwind@1.1.3/es2022/preset-tailwind.mjs"; import TWPreAuto from "https://esm.sh/v126/@twind/preset-autoprefix@1.0.7/es2022/preset-autoprefix.mjs"; diff --git a/run-local.tsx b/run-local.tsx index 94553e5..7042f27 100644 --- a/run-local.tsx +++ b/run-local.tsx @@ -27,6 +27,10 @@ Configure({ { inImports["react-original"] = inImports["react"]; inImports["react"] = `/>able/hmr-react.tsx`; + + inImports["signals-original"] = inImports["@preact/signals"]; + inImports["@preact/signals"] = `/>able/hmr-signals.tsx`; + return inImports; }, async Extra(inReq, inURL, inExt, inMap, inConfig) diff --git a/run-serve.tsx b/run-serve.tsx index 74e81a5..253f887 100644 --- a/run-serve.tsx +++ b/run-serve.tsx @@ -122,85 +122,6 @@ export const Transpile = ImportMapReload(); return size; }, - /** - * DONT USE - * Converts dynamic module imports in to static, also can resolve paths with an import map - */ - async Patch(inPath:string, inKey:string, inMap?:DenoConfig) - { - const check = this.Cache.get(inKey); - if(check) - { - return check; - } - - let file, text; - try - { - file = await fetch(inPath); - text = await file.text(); - } - catch(e) - { - return false; - } - - const remap = inMap ? (inPath:string)=> - { - const match = inMap.imports[inPath]; - if(match) - { - return match; - } - else if(inPath.includes("/")) - { - let bestKey = ""; - let bestLength = 0; - Object.keys(inMap.imports).forEach((key, i, arr)=> - { - if(key.endsWith("/") && inPath.startsWith(key) && key.length > bestLength) - { - bestKey = key; - bestLength = key.length; - } - }); - if(bestKey) - { - return inMap.imports[bestKey]+inPath.substring(bestKey.length); - } - } - return inPath; - } - : (inPath:string)=>inPath; - let match, regex; - let convertedBody = text; - - // remap static imports - regex = /from\s+(['"`])(.*?)\1/g; - while ((match = regex.exec(text))) - { - const importStatement = match[0]; - const importPath = match[2]; - convertedBody = convertedBody.replace(importStatement, `from "${remap(importPath)}"`); - } - - // convert dynamic imports into static (to work around deno deploy) - const staticImports = []; - regex = /(?