Skip to content

Commit

Permalink
fix(install): cache json exports of JSR packages (#26552)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nathanwhit authored and bartlomieju committed Oct 29, 2024
1 parent 1dff19a commit f9e70c0
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ deno_cache_dir = { workspace = true }
deno_config = { version = "=0.37.2", features = ["workspace", "sync"] }
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_doc = { version = "0.154.0", default-features = false, features = ["rust", "html", "syntect"] }
deno_graph = { version = "=0.83.3" }
deno_graph = { version = "=0.83.4" }
deno_lint = { version = "=0.67.0", features = ["docs"] }
deno_lockfile.workspace = true
deno_npm.workspace = true
Expand Down
7 changes: 1 addition & 6 deletions cli/tools/registry/pm/cache_deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,8 @@ pub async fn cache_top_level_deps(
while let Some(info_future) = info_futures.next().await {
if let Some((specifier, info)) = info_future {
let exports = info.exports();
for (k, v) in exports {
for (k, _) in exports {
if let Ok(spec) = specifier.join(k) {
if v.ends_with(".json") {
// TODO(nathanwhit): this should work, there's a bug with
// json roots in deno_graph. skip it for now
continue;
}
roots.push(spec);
}
}
Expand Down
1 change: 1 addition & 0 deletions tests/registry/jsr/@denotest/multiple-exports/1.0.0/add.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "jsr:@denotest/add@1";
3 changes: 3 additions & 0 deletions tests/registry/jsr/@denotest/multiple-exports/1.0.0/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"a": 1
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "jsr:@denotest/subtract@1";
7 changes: 7 additions & 0 deletions tests/registry/jsr/@denotest/multiple-exports/1.0.0_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"exports": {
"./add": "./add.ts",
"./subtract": "./subtract.ts",
"./data-json": "./data.json"
}
}
5 changes: 5 additions & 0 deletions tests/registry/jsr/@denotest/multiple-exports/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"versions": {
"1.0.0": {}
}
}
3 changes: 2 additions & 1 deletion tests/specs/install/jsr_exports/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"tempDir": true,
"steps": [
{ "args": "install", "output": "install.out" }
{ "args": "install", "output": "install.out" },
{ "args": "run --cached-only main.ts", "output": "main.out" }
]
}
2 changes: 1 addition & 1 deletion tests/specs/install/jsr_exports/deno.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"imports": {
"@denotest/different-deps-per-export": "jsr:@denotest/different-deps-per-export@^1.0.0"
"@denotest/multiple-exports": "jsr:@denotest/multiple-exports@^1.0.0"
}
}
9 changes: 5 additions & 4 deletions tests/specs/install/jsr_exports/install.out
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[UNORDERED_START]
Download http://127.0.0.1:4250/@denotest/different-deps-per-export/meta.json
Download http://127.0.0.1:4250/@denotest/different-deps-per-export/1.0.0_meta.json
Download http://127.0.0.1:4250/@denotest/different-deps-per-export/1.0.0/add.ts
Download http://127.0.0.1:4250/@denotest/different-deps-per-export/1.0.0/subtract.ts
Download http://127.0.0.1:4250/@denotest/multiple-exports/meta.json
Download http://127.0.0.1:4250/@denotest/multiple-exports/1.0.0_meta.json
Download http://127.0.0.1:4250/@denotest/multiple-exports/1.0.0/add.ts
Download http://127.0.0.1:4250/@denotest/multiple-exports/1.0.0/subtract.ts
Download http://127.0.0.1:4250/@denotest/multiple-exports/1.0.0/data.json
Download http://127.0.0.1:4250/@denotest/add/meta.json
Download http://127.0.0.1:4250/@denotest/subtract/meta.json
Download http://127.0.0.1:4250/@denotest/add/1.0.0_meta.json
Expand Down
3 changes: 3 additions & 0 deletions tests/specs/install/jsr_exports/main.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
3
-1
{ a: 1 }
7 changes: 7 additions & 0 deletions tests/specs/install/jsr_exports/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { add } from "@denotest/multiple-exports/add";
import { subtract } from "@denotest/multiple-exports/subtract";
import data from "@denotest/multiple-exports/data-json" with { type: "json" };

console.log(add(1, 2));
console.log(subtract(1, 2));
console.log(data);

0 comments on commit f9e70c0

Please sign in to comment.