Open babie opened 1 year ago
I added an importmap test: https://github.com/babie/tauri-with-deno-fresh/blob/add-importmap-test/test-importmap.ts
import {
ImportMap,
resolveImportMap,
resolveModuleSpecifier,
} from "https://deno.land/x/importmap@0.2.1/mod.ts";
const importMap: ImportMap = {
imports: {
"./foo/": "./bar/",
"$fresh/": "https://deno.land/x/fresh@1.2.0/",
"@preact/signals": "https://esm.sh/*@preact/signals@1.1.3",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.2.3",
"$std/": "https://deno.land/std@0.190.0/",
},
};
const importMapBaseURL = new URL(import.meta.url);
const resolvedImportMap = resolveImportMap(importMap, importMapBaseURL);
console.log("resolved importmap:");
console.dir(resolvedImportMap);
const moduleSpecifiers = [
"./foo/test.js",
"$fresh/server.ts",
"@preact/signals",
"@preact/signals-core",
"$std/dotenv/load.ts",
];
const baseURL = new URL(import.meta.url);
console.log("resolved module specifiers:");
for (const moduleSpecifier of moduleSpecifiers) {
const resolvedModuleSpecifier = resolveModuleSpecifier(
moduleSpecifier,
resolvedImportMap,
baseURL,
);
console.log(`${moduleSpecifier} -> ${resolvedModuleSpecifier}`);
}
but importmap
module ran as expacted:
$ deno run test-importmap.ts
resolved importmap:
{
imports: {
"file:///Users/babie/src/github.com/babie/tauri-deno-fresh/foo/": "file:///Users/babie/src/github.com/babie/tauri-deno-fresh/bar/",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.2.3",
"@preact/signals": "https://esm.sh/*@preact/signals@1.1.3",
"$fresh/": "https://deno.land/x/fresh@1.2.0/",
"$std/": "https://deno.land/std@0.190.0/"
},
scopes: {}
}
resolved module specifiers:
./foo/test.js -> file:///Users/babie/src/github.com/babie/tauri-deno-fresh/bar/test.js
$fresh/server.ts -> https://deno.land/x/fresh@1.2.0/server.ts
@preact/signals -> https://esm.sh/*@preact/signals@1.1.3
@preact/signals-core -> https://esm.sh/*@preact/signals-core@1.2.3
$std/dotenv/load.ts -> https://deno.land/std@0.190.0/dotenv/load.ts
there might be a bug on esbuild_deno_loader
.
memo:
parhaps because esbuild_deno_loader
uses args.namespace
(default: file
) on build.onLoad()
and build.onResolve()
as it is.
I tried to run Tauri with Deno Fresh. So, I used deno_esbuild for compile to deno-fresh entrypoint file. And I used esbuild_deno_loader for module resolution. But, I failed.
all codes is here: https://github.com/babie/tauri-with-deno-fresh/tree/with-special-character
Expect
No errors.
Actual
I guess that importmap module cannot resolve specifiers starts with
$
or@
. I will send an issue to importmap repo and connect here later.