Skip to content

Commit f9e70c0

Browse files
nathanwhitbartlomieju
authored andcommitted
fix(install): cache json exports of JSR packages (#26552)
Fixes #26509. Ended up being a `deno_graph` bug causing the error to surface. This PR updates `deno_graph` to pick up the fix and reverts the temporary workaround that skipped JSON exports.
1 parent 1dff19a commit f9e70c0

File tree

13 files changed

+39
-15
lines changed

13 files changed

+39
-15
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ deno_cache_dir = { workspace = true }
7373
deno_config = { version = "=0.37.2", features = ["workspace", "sync"] }
7474
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
7575
deno_doc = { version = "0.154.0", default-features = false, features = ["rust", "html", "syntect"] }
76-
deno_graph = { version = "=0.83.3" }
76+
deno_graph = { version = "=0.83.4" }
7777
deno_lint = { version = "=0.67.0", features = ["docs"] }
7878
deno_lockfile.workspace = true
7979
deno_npm.workspace = true

cli/tools/registry/pm/cache_deps.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,8 @@ pub async fn cache_top_level_deps(
9090
while let Some(info_future) = info_futures.next().await {
9191
if let Some((specifier, info)) = info_future {
9292
let exports = info.exports();
93-
for (k, v) in exports {
93+
for (k, _) in exports {
9494
if let Ok(spec) = specifier.join(k) {
95-
if v.ends_with(".json") {
96-
// TODO(nathanwhit): this should work, there's a bug with
97-
// json roots in deno_graph. skip it for now
98-
continue;
99-
}
10095
roots.push(spec);
10196
}
10297
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "jsr:@denotest/add@1";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"a": 1
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "jsr:@denotest/subtract@1";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"exports": {
3+
"./add": "./add.ts",
4+
"./subtract": "./subtract.ts",
5+
"./data-json": "./data.json"
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"versions": {
3+
"1.0.0": {}
4+
}
5+
}
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"tempDir": true,
33
"steps": [
4-
{ "args": "install", "output": "install.out" }
4+
{ "args": "install", "output": "install.out" },
5+
{ "args": "run --cached-only main.ts", "output": "main.out" }
56
]
67
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"imports": {
3-
"@denotest/different-deps-per-export": "jsr:@denotest/different-deps-per-export@^1.0.0"
3+
"@denotest/multiple-exports": "jsr:@denotest/multiple-exports@^1.0.0"
44
}
55
}

tests/specs/install/jsr_exports/install.out

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[UNORDERED_START]
2-
Download http://127.0.0.1:4250/@denotest/different-deps-per-export/meta.json
3-
Download http://127.0.0.1:4250/@denotest/different-deps-per-export/1.0.0_meta.json
4-
Download http://127.0.0.1:4250/@denotest/different-deps-per-export/1.0.0/add.ts
5-
Download http://127.0.0.1:4250/@denotest/different-deps-per-export/1.0.0/subtract.ts
2+
Download http://127.0.0.1:4250/@denotest/multiple-exports/meta.json
3+
Download http://127.0.0.1:4250/@denotest/multiple-exports/1.0.0_meta.json
4+
Download http://127.0.0.1:4250/@denotest/multiple-exports/1.0.0/add.ts
5+
Download http://127.0.0.1:4250/@denotest/multiple-exports/1.0.0/subtract.ts
6+
Download http://127.0.0.1:4250/@denotest/multiple-exports/1.0.0/data.json
67
Download http://127.0.0.1:4250/@denotest/add/meta.json
78
Download http://127.0.0.1:4250/@denotest/subtract/meta.json
89
Download http://127.0.0.1:4250/@denotest/add/1.0.0_meta.json
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
3
2+
-1
3+
{ a: 1 }
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { add } from "@denotest/multiple-exports/add";
2+
import { subtract } from "@denotest/multiple-exports/subtract";
3+
import data from "@denotest/multiple-exports/data-json" with { type: "json" };
4+
5+
console.log(add(1, 2));
6+
console.log(subtract(1, 2));
7+
console.log(data);

0 commit comments

Comments
 (0)