From 52241cc9a6dc0565f3b3378c7ac00a3da4405ddf Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Thu, 24 Sep 2026 13:00:43 -0500 Subject: [PATCH] fix(plugin): let a generated package run deno test straight away With a package.json beside deno.json, Deno expects node_modules to be installed, so deno test failed until a deno install, and then failed to type-check node:assert without @types/node. nodeModulesDir "auto" installs on demand, and the package now passes deno test, node --test and bun test as generated. Signed-off-by: Diego Resendez --- src/plugin_files.rs | 1 + tests/plugin.rs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/plugin_files.rs b/src/plugin_files.rs index 0f6dc05..8867162 100644 --- a/src/plugin_files.rs +++ b/src/plugin_files.rs @@ -83,6 +83,7 @@ fn deno_json(p: &Package) -> String { "version": "0.1.0", "license": "MIT", "exports": "./src/index.ts", + "nodeModulesDir": "auto", "imports": {{ "@green-tea/core": "npm:@green-tea/core@{CORE_VERSION}" }}, diff --git a/tests/plugin.rs b/tests/plugin.rs index 4dc36e8..e26c726 100644 --- a/tests/plugin.rs +++ b/tests/plugin.rs @@ -192,6 +192,9 @@ fn package_jsr_writes_the_tree_into_dir() { let deno = std::fs::read_to_string(pkg.join("deno.json")).unwrap(); assert!(deno.contains("\"name\": \"@acme/plugin-algo\""), "{deno}"); assert!(deno.contains("npm:@green-tea/core@26.9.0-beta.2"), "{deno}"); + // Without it `deno test` needs a `deno install` first, and then fails to + // type-check `node:assert` for want of @types/node. + assert!(deno.contains("\"nodeModulesDir\": \"auto\""), "{deno}"); let pj = std::fs::read_to_string(pkg.join("package.json")).unwrap(); assert!(pj.contains("\"private\": true"), "{pj}"); assert!(pj.contains("\"devDependencies\""), "{pj}");