fix(publish): remove incorrect relative-package-import diagnostic when root of workspace is package (#30333)

This commit is contained in:
David Sherret 2025-08-07 10:25:57 +02:00 committed by GitHub
parent 2b50970347
commit 0f865b474b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 23 additions and 15 deletions

View file

@ -1123,7 +1123,6 @@ fn collect_excluded_module_diagnostics(
}
if !had_excluded_specifier {
let mut found_outside_specifier = false;
// ensure no path being published references another package
// via a relative import
for publish_path in publish_paths {
@ -1148,7 +1147,6 @@ fn collect_excluded_module_diagnostics(
}
});
if let Some((outside_res, package)) = maybe_res.next() {
found_outside_specifier = true;
diagnostics_collector.push(
PublishDiagnostic::RelativePackageImport {
// Wasm modules won't have a referrer
@ -1166,19 +1164,6 @@ fn collect_excluded_module_diagnostics(
}
}
}
if !found_outside_specifier {
// just in case we didn't find an outside specifier above, add
// diagnostics for all the specifiers found outside the package
for (specifier, to_package) in outside_specifiers {
diagnostics_collector.push(PublishDiagnostic::RelativePackageImport {
specifier: specifier.clone(),
from_package_name: current_package_name.to_string(),
to_package_name: to_package.name.clone(),
maybe_referrer: None,
});
}
}
}
}

View file

@ -0,0 +1,5 @@
{
"args": "publish --dry-run",
// should succeed
"output": "[WILDCARD]"
}

View file

@ -0,0 +1,9 @@
{
"name": "@scope/package-a",
"version": "0.1.0",
"license": "MIT",
"workspace": [
"./package-b"
],
"exports": "./mod.ts"
}

View file

@ -0,0 +1,3 @@
import { Test } from "@scope/package-b";
export { Test };

View file

@ -0,0 +1,5 @@
{
"name": "@scope/package-b",
"version": "0.1.0",
"exports": "./mod.ts"
}

View file

@ -0,0 +1 @@
export class Test {}