fixes still broken
This commit is contained in:
parent
4441a6d8f2
commit
6a0a110242
55
mod.ts
55
mod.ts
@ -2,35 +2,13 @@ import * as ESBuild from "https://deno.land/x/esbuild@v0.25.0/wasm.js";
|
|||||||
import * as Mapper from "https://esm.sh/esbuild-plugin-importmaps@1.0.0"; // https://github.com/andstellar/esbuild-plugin-importmaps
|
import * as Mapper from "https://esm.sh/esbuild-plugin-importmaps@1.0.0"; // https://github.com/andstellar/esbuild-plugin-importmaps
|
||||||
import Introspect from "./introspect.ts";
|
import Introspect from "./introspect.ts";
|
||||||
|
|
||||||
const REG = {
|
|
||||||
pathRel: RegExp("/^(\.\/|\.\.\/).*/"),
|
|
||||||
pathAbs: RegExp("^\/.*"),
|
|
||||||
pathHTTP: RegExp("/^https?:\/\//"),
|
|
||||||
wildcard: RegExp("/.*/")
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
const prefix = "/_dot_importer_/";
|
const prefix = "/_dot_importer_/";
|
||||||
const resolvePlugin =(fullPathDir:string):ESBuild.Plugin=>({
|
const resolvePlugin =(fullPathDir:string):ESBuild.Plugin=>({
|
||||||
name: "resolve-plugin",
|
name: "resolve-plugin",
|
||||||
setup(build) {
|
setup(build) {
|
||||||
|
|
||||||
build.onResolve({ filter: REG.pathHTTP }, args => {
|
build.onResolve({ /*path relative*/ filter: /^(\.\/|\.\.\/).*/ }, (args)=>
|
||||||
console.log(`LOCAL RESOLVE`, args);
|
|
||||||
return { path: args.path, namespace:"remote", pluginData:{origin:new URL(args.path).origin} };
|
|
||||||
});
|
|
||||||
build.onLoad({ filter: REG.wildcard, namespace:"remote" }, async(args)=> {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
console.log(`REMOTE LOADING`, {args}, "\n");
|
|
||||||
const contents = await fetch(args.path).then(r=>r.text());
|
|
||||||
|
|
||||||
return { contents, loader: `tsx` };
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
build.onResolve({ filter: REG.pathRel }, (args)=>
|
|
||||||
{
|
{
|
||||||
let resolveRoot = args.importer||fullPathDir;
|
let resolveRoot = args.importer||fullPathDir;
|
||||||
if(resolveRoot.startsWith(prefix))
|
if(resolveRoot.startsWith(prefix))
|
||||||
@ -46,7 +24,7 @@ const resolvePlugin =(fullPathDir:string):ESBuild.Plugin=>({
|
|||||||
console.log(`LOCAL RESOLVE`, {args, resolveRoot, output}, "\n");
|
console.log(`LOCAL RESOLVE`, {args, resolveRoot, output}, "\n");
|
||||||
return output;
|
return output;
|
||||||
});
|
});
|
||||||
build.onLoad({ filter: REG.wildcard, namespace:"local" }, async(args)=> {
|
build.onLoad({ /*wildcard*/ filter: /.*/, namespace:"local" }, async(args)=> {
|
||||||
|
|
||||||
const fetchPath = args.path.substring(prefix.length);
|
const fetchPath = args.path.substring(prefix.length);
|
||||||
|
|
||||||
@ -56,6 +34,35 @@ const resolvePlugin =(fullPathDir:string):ESBuild.Plugin=>({
|
|||||||
|
|
||||||
return { contents, loader: `tsx` };
|
return { contents, loader: `tsx` };
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
build.onResolve({/* path abs */ filter:/^\/.*/}, args=>{
|
||||||
|
console.log(`ABS RESOLVE`, {args}, "\n");
|
||||||
|
|
||||||
|
return {
|
||||||
|
path:args.path,
|
||||||
|
namespace:"ABS",
|
||||||
|
}
|
||||||
|
});
|
||||||
|
build.onLoad({/*wildcard*/ filter: /.*/, namespace:"ABS"}, async(args)=>{
|
||||||
|
console.log(`ABS LOADING`, {args}, "\n");
|
||||||
|
return { contents:"export default 'IDK';", loader: `tsx` };
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
build.onResolve({ /* path HTTP */ filter: /^https?:\/\// }, args => {
|
||||||
|
console.log(`REMOTE RESOLVE`, args);
|
||||||
|
return { path: args.path, namespace:"REMOTE", pluginData:{origin:new URL(args.path).origin} };
|
||||||
|
});
|
||||||
|
build.onLoad({ /*wildcard*/ filter: /.*/, namespace:"REMOTE" }, async(args)=> {
|
||||||
|
console.log(`REMOTE LOADING`, {args}, "\n");
|
||||||
|
|
||||||
|
const contents = await fetch(args.path).then(r=>r.text());
|
||||||
|
|
||||||
|
return { contents, loader: `tsx` };
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user