Skip to content

Commit a0c6cd9

Browse files
use esm.run
1 parent 89bf0f7 commit a0c6cd9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Diff for: src/components/sketch/SketchMain/Preview/respond-with.ts

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ export async function respondWith(
2929
}
3030
}
3131

32+
if (pathname.startsWith("/npm/")) {
33+
const content = await fetch(
34+
`https://cdn.jsdelivr.net/npm/${pathname.slice("/npm/".length)}`
35+
).then((res) => res.arrayBuffer())
36+
37+
return { content, ext: ".js", path: pathname.slice("/npm/".length) }
38+
}
39+
3240
const requireImport = searchParams.has("import")
3341

3442
if (pathname === "/")

Diff for: src/logic/compiler/resolve-import-pkg.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function resolveImportPkg(name: string, pkgs: PackageJSON) {
1919
.map((item) => `${item[0]}@${item[1]}`)
2020
.join(",")
2121

22-
return `https://esm.sh/${`${pkgName}@${
22+
return `https://esm.run/${`${pkgName}@${
2323
pkgs.dependencies?.[pkgName] ?? "latest"
2424
}${
2525
indexSlashPath === -1 || indexSlashPath >= name.length

0 commit comments

Comments
 (0)