Skip to content

Commit

Permalink
fix(core): use jsr:@deno/graph for x/deno_graph
Browse files Browse the repository at this point in the history
  • Loading branch information
hasundue committed Apr 23, 2024
1 parent bb0a759 commit 49683e6
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 21 deletions.
2 changes: 1 addition & 1 deletion core/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
},
"imports": {
"@core/unknownutil": "jsr:@core/unknownutil@^3.18.0",
"@deno/graph": "jsr:@deno/graph@^0.73.1",
"@lambdalisue/async": "jsr:@lambdalisue/async@^2.1.1",
"@molt/lib": "jsr:@molt/lib@^0.18.0",
"@std/assert": "jsr:@std/assert@^0.222.1",
Expand All @@ -21,7 +22,6 @@
"@std/path": "jsr:@std/path@^0.222.1",
"@std/semver": "jsr:@std/semver@^0.222.1",
"@std/testing": "jsr:@std/testing@^0.222.1",
"x/deno_graph": "./vendor/deno.land/x/deno_graph@0.69.6/mod.ts",
"x/import_map": "./vendor/deno.land/x/import_map@v0.19.1/mod.ts"
},
"scopes": {
Expand Down
18 changes: 2 additions & 16 deletions core/graph.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,13 @@
import {
createGraph,
type CreateGraphOptions,
init as initDenoGraph,
load as defaultLoad,
} from "x/deno_graph";
} from "@deno/graph";

class DenoGraph {
static #initialized = false;

static async ensureInit() {
if (this.#initialized) {
return;
}
await initDenoGraph();
this.#initialized = true;
}
}

export async function createGraphLocally(
export function createGraphLocally(
specifiers: string[],
options?: CreateGraphOptions & { resolveLocal?: boolean },
) {
await DenoGraph.ensureInit();
return createGraph(specifiers, {
load: async (specifier) => {
const url = new URL(specifier); // should not throw
Expand Down
18 changes: 18 additions & 0 deletions core/graph_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { assertExists } from "@std/assert";

import { createGraph } from "@deno/graph";
import { createGraphLocally } from "./graph.ts";

Deno.test("createGraph", async () => {
const graph = await createGraph(
"https://deno.land/x/std/testing/asserts.ts",
);
assertExists(graph);
});

Deno.test("createGraphLocally", async () => {
const graph = await createGraphLocally([
new URL("../test/cases/import.ts", import.meta.url).href,
]);
assertExists(graph);
});
2 changes: 1 addition & 1 deletion core/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { findFileUp, toPath, toUrl } from "@molt/lib/path";
import { assertExists } from "@std/assert";
import { partition } from "@std/collections";
import { exists } from "@std/fs";
import type { ModuleJson } from "x/deno_graph";
import type { ModuleJson } from "@deno/graph";
import { createGraphLocally } from "./graph.ts";
import {
type ImportMap,
Expand Down
4 changes: 2 additions & 2 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
"@cliffy/ansi": "jsr:@cliffy/ansi@1.0.0-rc.4",
"@cliffy/command": "jsr:@cliffy/command@1.0.0-rc.4",
"@conventional-commits/parser": "npm:@conventional-commits/parser@^0.4.1",
"@core/unknownutil": "jsr:@core/unknownutil@^3.18.0",
"@core/match": "jsr:@core/match@^0.2.5",
"@core/unknownutil": "jsr:@core/unknownutil@^3.18.0",
"@david/dax": "jsr:@david/dax@^0.40.0",
"@deno/graph": "jsr:@deno/graph@^0.73.1",
"@lambdalisue/async": "jsr:@lambdalisue/async@^2.1.1",
"@octokit/rest": "npm:@octokit/rest@^20.1.0",
"@std/assert": "jsr:@std/assert@^0.222.1",
Expand All @@ -31,7 +32,6 @@
"@std/path": "jsr:@std/path@^0.222.1",
"@std/semver": "jsr:@std/semver@^0.222.1",
"@std/testing": "jsr:@std/testing@^0.222.1",
"x/deno_graph": "https://deno.land/x/deno_graph@0.69.6/mod.ts",
"x/import_map": "https://deno.land/x/import_map@v0.19.1/mod.ts"
},
"scopes": {
Expand Down
12 changes: 11 additions & 1 deletion deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 49683e6

Please sign in to comment.