From 98077e4b3ce5bf3fd7378d0c2b711fcd97bcc143 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Thu, 11 Apr 2024 19:52:35 -0400 Subject: [PATCH] fix(publish): do not warn about excluded external modules in node_modules directory (#23173) --- cli/tools/registry/mod.rs | 11 +++++++++-- tests/specs/publish/byonm_dep/__test__.jsonc | 4 ++++ tests/specs/publish/byonm_dep/deno.jsonc | 11 +++++++++++ tests/specs/publish/byonm_dep/mod.ts | 7 +++++++ .../publish/byonm_dep/node_modules/package/index.d.ts | 1 + .../publish/byonm_dep/node_modules/package/index.js | 3 +++ .../byonm_dep/node_modules/package/package.json | 4 ++++ tests/specs/publish/byonm_dep/package.json | 5 +++++ tests/specs/publish/byonm_dep/publish.out | 6 ++++++ 9 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 tests/specs/publish/byonm_dep/__test__.jsonc create mode 100644 tests/specs/publish/byonm_dep/deno.jsonc create mode 100644 tests/specs/publish/byonm_dep/mod.ts create mode 100644 tests/specs/publish/byonm_dep/node_modules/package/index.d.ts create mode 100644 tests/specs/publish/byonm_dep/node_modules/package/index.js create mode 100644 tests/specs/publish/byonm_dep/node_modules/package/package.json create mode 100644 tests/specs/publish/byonm_dep/package.json create mode 100644 tests/specs/publish/byonm_dep/publish.out diff --git a/cli/tools/registry/mod.rs b/cli/tools/registry/mod.rs index 3d13a52b77..de319281b5 100644 --- a/cli/tools/registry/mod.rs +++ b/cli/tools/registry/mod.rs @@ -212,8 +212,15 @@ fn collect_excluded_module_diagnostics( return; }; let specifiers = graph - .specifiers() - .map(|(s, _)| s) + .modules() + .filter_map(|m| match m { + deno_graph::Module::Js(_) | deno_graph::Module::Json(_) => { + Some(m.specifier()) + } + deno_graph::Module::Npm(_) + | deno_graph::Module::Node(_) + | deno_graph::Module::External(_) => None, + }) .filter(|s| s.as_str().starts_with(root.as_str())); for specifier in specifiers { if !file_patterns.matches_specifier(specifier) { diff --git a/tests/specs/publish/byonm_dep/__test__.jsonc b/tests/specs/publish/byonm_dep/__test__.jsonc new file mode 100644 index 0000000000..303718c998 --- /dev/null +++ b/tests/specs/publish/byonm_dep/__test__.jsonc @@ -0,0 +1,4 @@ +{ + "args": "publish --dry-run --allow-dirty", + "output": "publish.out" +} diff --git a/tests/specs/publish/byonm_dep/deno.jsonc b/tests/specs/publish/byonm_dep/deno.jsonc new file mode 100644 index 0000000000..37a2377308 --- /dev/null +++ b/tests/specs/publish/byonm_dep/deno.jsonc @@ -0,0 +1,11 @@ +{ + "name": "@scope/package", + "version": "0.0.0", + "exports": "./mod.ts", + "publish": { + // this was previously causing issues because it would cause + // external modules in the node_modules directory to be ignored + "include": ["mod.ts"] + }, + "unstable": ["byonm", "sloppy-imports"] +} diff --git a/tests/specs/publish/byonm_dep/mod.ts b/tests/specs/publish/byonm_dep/mod.ts new file mode 100644 index 0000000000..b7c276fd49 --- /dev/null +++ b/tests/specs/publish/byonm_dep/mod.ts @@ -0,0 +1,7 @@ +import { add } from "package"; + +export function myAdd(a: number, b: number): number { + return add(a, b); +} + +export { add }; diff --git a/tests/specs/publish/byonm_dep/node_modules/package/index.d.ts b/tests/specs/publish/byonm_dep/node_modules/package/index.d.ts new file mode 100644 index 0000000000..9b197eb1e4 --- /dev/null +++ b/tests/specs/publish/byonm_dep/node_modules/package/index.d.ts @@ -0,0 +1 @@ +export function add(a: number, b: number): number; diff --git a/tests/specs/publish/byonm_dep/node_modules/package/index.js b/tests/specs/publish/byonm_dep/node_modules/package/index.js new file mode 100644 index 0000000000..0ecf3b8750 --- /dev/null +++ b/tests/specs/publish/byonm_dep/node_modules/package/index.js @@ -0,0 +1,3 @@ +export function add(a, b) { + return a + b; +} \ No newline at end of file diff --git a/tests/specs/publish/byonm_dep/node_modules/package/package.json b/tests/specs/publish/byonm_dep/node_modules/package/package.json new file mode 100644 index 0000000000..07fe062282 --- /dev/null +++ b/tests/specs/publish/byonm_dep/node_modules/package/package.json @@ -0,0 +1,4 @@ +{ + "main": "index.js", + "type": "module" +} \ No newline at end of file diff --git a/tests/specs/publish/byonm_dep/package.json b/tests/specs/publish/byonm_dep/package.json new file mode 100644 index 0000000000..f0b3ee21dd --- /dev/null +++ b/tests/specs/publish/byonm_dep/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "package": "*" + } +} diff --git a/tests/specs/publish/byonm_dep/publish.out b/tests/specs/publish/byonm_dep/publish.out new file mode 100644 index 0000000000..f3b8a0dccd --- /dev/null +++ b/tests/specs/publish/byonm_dep/publish.out @@ -0,0 +1,6 @@ +Check file:///[WILDLINE]/mod.ts +Checking for slow types in the public API... +Check file:///[WILDLINE]/mod.ts +Simulating publish of @scope/package@0.0.0 with files: + file:///[WILDLINE]/mod.ts (129B) +Warning Aborting due to --dry-run