dreaded-fixes #7
@ -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["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["@preact/signals"] = `https://esm.sh/@preact/signals@1.2.1`;
|
||||||
|
importMap["@twind/core"] = `https://esm.sh/@twind/core@1.1.3`;
|
||||||
importMap[">able/"] = `${RootHost}`;
|
importMap[">able/"] = `${RootHost}`;
|
||||||
if(!importMap[">able/app.tsx"])
|
if(!importMap[">able/app.tsx"])
|
||||||
{
|
{
|
||||||
|
5
cli.tsx
5
cli.tsx
@ -123,9 +123,10 @@ if(arg._.length)
|
|||||||
`--project=${useProject}`,
|
`--project=${useProject}`,
|
||||||
`--token=${useToken}`,
|
`--token=${useToken}`,
|
||||||
`--import-map=${imports.path}`,
|
`--import-map=${imports.path}`,
|
||||||
RootHost+"run.tsx",
|
|
||||||
...scanProd,
|
...scanProd,
|
||||||
...Deno.args]);
|
...Deno.args,
|
||||||
|
RootHost+"run.tsx"]);
|
||||||
}
|
}
|
||||||
case "upgrade" :
|
case "upgrade" :
|
||||||
{
|
{
|
||||||
|
@ -2,9 +2,10 @@
|
|||||||
"imports": {
|
"imports": {
|
||||||
"react": "https://esm.sh/preact@10.17.1/compat",
|
"react": "https://esm.sh/preact@10.17.1/compat",
|
||||||
"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/": "http://localhost:4507/",
|
||||||
">able/app.tsx": "./app.tsx",
|
">able/app.tsx": "./app.tsx"
|
||||||
"@preact/signals": "https://esm.sh/@preact/signals@1.2.1"
|
|
||||||
},
|
},
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"check": "deno run -A --no-lock http://localhost:4507/cli.tsx check",
|
"check": "deno run -A --no-lock http://localhost:4507/cli.tsx check",
|
||||||
|
0
hmr-signal.tsx
Normal file
0
hmr-signal.tsx
Normal file
@ -1,5 +1,5 @@
|
|||||||
import React from "react";
|
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 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";
|
import TWPreAuto from "https://esm.sh/v126/@twind/preset-autoprefix@1.0.7/es2022/preset-autoprefix.mjs";
|
||||||
|
|
||||||
|
@ -27,6 +27,10 @@ Configure({
|
|||||||
{
|
{
|
||||||
inImports["react-original"] = inImports["react"];
|
inImports["react-original"] = inImports["react"];
|
||||||
inImports["react"] = `/>able/hmr-react.tsx`;
|
inImports["react"] = `/>able/hmr-react.tsx`;
|
||||||
|
|
||||||
|
inImports["signals-original"] = inImports["@preact/signals"];
|
||||||
|
inImports["@preact/signals"] = `/>able/hmr-signals.tsx`;
|
||||||
|
|
||||||
return inImports;
|
return inImports;
|
||||||
},
|
},
|
||||||
async Extra(inReq, inURL, inExt, inMap, inConfig)
|
async Extra(inReq, inURL, inExt, inMap, inConfig)
|
||||||
|
@ -122,85 +122,6 @@ export const Transpile =
|
|||||||
ImportMapReload();
|
ImportMapReload();
|
||||||
return size;
|
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 = /(?<![\w.])import\(([^)]+)(?!import\b)\)/g;
|
|
||||||
while ((match = regex.exec(text)))
|
|
||||||
{
|
|
||||||
const importStatement = match[0];
|
|
||||||
const importPath = remap(match[1].substring(1, match[1].length-1));
|
|
||||||
const moduleName = `_dyn_${staticImports.length}` as string;
|
|
||||||
|
|
||||||
staticImports.push(`import ${moduleName} from ${importPath};`);
|
|
||||||
convertedBody = convertedBody.replace(importStatement, `Promise.resolve(${moduleName})`);
|
|
||||||
}
|
|
||||||
convertedBody = staticImports.join("\n") + convertedBody;
|
|
||||||
|
|
||||||
inKey && this.Cache.set(inKey, convertedBody);
|
|
||||||
return convertedBody;
|
|
||||||
},
|
|
||||||
async Fetch(inPath:string, inKey:string, inCheckCache=true)
|
async Fetch(inPath:string, inKey:string, inCheckCache=true)
|
||||||
{
|
{
|
||||||
const check = this.Cache.get(inPath);
|
const check = this.Cache.get(inPath);
|
||||||
|
Loading…
Reference in New Issue
Block a user