Skip to content

Commit 220368a

Browse files
bartlomiejuclaude
andauthored
chore: migrate docsearch and imagescript to npm/jsr imports (#3732)
## Summary - **docsearch**: Replaced `esm.sh` URL with `npm:@docsearch/js@^3.5.2`. Added a type cast workaround in `SearchButton.tsx` since Deno's type checker treats this npm package as CJS (missing `"type": "module"`). - **imagescript**: Replaced `deno.land/x` URL with `jsr:@matmen/imagescript@^1.3.0`. Clean swap, no code changes needed. These were legacy URL-based imports from before Deno had native `npm:` and `jsr:` support. --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 25e6357 commit 220368a

3 files changed

Lines changed: 200 additions & 33 deletions

File tree

deno.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"@types/node": "npm:@types/node@^24.3.0",
5555
"@types/pg": "npm:@types/pg@^8.15.5",
5656
"@types/prismjs": "npm:@types/prismjs@^1.26.5",
57-
"docsearch": "https://esm.sh/@docsearch/js@3.5.2?target=es2020",
57+
"docsearch": "npm:@docsearch/js@^3.5.2",
5858
"esbuild": "npm:esbuild@0.25.7",
5959
"esbuild-wasm": "npm:esbuild-wasm@0.25.7",
6060
"fresh": "jsr:@fresh/core@^2.0.0",
@@ -91,7 +91,7 @@
9191

9292
"@std/front-matter": "jsr:@std/front-matter@^1.0.5",
9393
"github-slugger": "npm:github-slugger@^2.0.0",
94-
"imagescript": "https://deno.land/x/imagescript@1.3.0/mod.ts",
94+
"imagescript": "jsr:@matmen/imagescript@^1.3.0",
9595
"marked": "npm:marked@^15.0.11",
9696
"marked-mangle": "npm:marked-mangle@^1.1.9",
9797
"prismjs": "npm:prismjs@^1.29.0",

deno.lock

Lines changed: 192 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

www/islands/SearchButton.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect, useRef } from "preact/hooks";
2-
import docsearch from "docsearch";
2+
import docsearchModule from "docsearch";
33

44
// Copied from algolia source code
55
type DocSearchProps = {
@@ -9,6 +9,11 @@ type DocSearchProps = {
99
container: HTMLElement | string;
1010
};
1111

12+
// Workaround: Deno resolves this npm package as CJS, hiding the callable default export
13+
const docsearch = docsearchModule as unknown as (
14+
props: DocSearchProps,
15+
) => void;
16+
1217
export default function SearchButton(
1318
props: { docsearch?: (args: DocSearchProps) => void; class?: string },
1419
) {

0 commit comments

Comments
 (0)