summaryrefslogtreecommitdiff
path: root/cli/tools
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tools')
-rw-r--r--cli/tools/registry/unfurl.rs62
-rw-r--r--cli/tools/vendor/test.rs3
2 files changed, 51 insertions, 14 deletions
diff --git a/cli/tools/registry/unfurl.rs b/cli/tools/registry/unfurl.rs
index 758db0796..63c773f01 100644
--- a/cli/tools/registry/unfurl.rs
+++ b/cli/tools/registry/unfurl.rs
@@ -75,26 +75,59 @@ impl SpecifierUnfurler {
match resolved {
MappedResolution::Normal(specifier)
| MappedResolution::ImportMap(specifier) => Some(specifier),
+ MappedResolution::WorkspaceNpmPackage {
+ target_pkg_json: pkg_json,
+ pkg_name,
+ sub_path,
+ } => {
+ // todo(#24612): consider warning or error when this is also a jsr package?
+ ModuleSpecifier::parse(&format!(
+ "npm:{}{}{}",
+ pkg_name,
+ pkg_json
+ .version
+ .as_ref()
+ .map(|v| format!("@^{}", v))
+ .unwrap_or_default(),
+ sub_path
+ .as_ref()
+ .map(|s| format!("/{}", s))
+ .unwrap_or_default()
+ ))
+ .ok()
+ }
MappedResolution::PackageJson {
+ alias,
sub_path,
dep_result,
..
} => match dep_result {
Ok(dep) => match dep {
- PackageJsonDepValue::Req(req) => ModuleSpecifier::parse(&format!(
- "npm:{}{}",
- req,
- sub_path
- .as_ref()
- .map(|s| format!("/{}", s))
- .unwrap_or_default()
- ))
- .ok(),
- PackageJsonDepValue::Workspace(_) => {
- log::warn!(
- "package.json workspace entries are not implemented yet for publishing."
- );
- None
+ PackageJsonDepValue::Req(pkg_req) => {
+ // todo(#24612): consider warning or error when this is an npm workspace
+ // member that's also a jsr package?
+ ModuleSpecifier::parse(&format!(
+ "npm:{}{}",
+ pkg_req,
+ sub_path
+ .as_ref()
+ .map(|s| format!("/{}", s))
+ .unwrap_or_default()
+ ))
+ .ok()
+ }
+ PackageJsonDepValue::Workspace(version_req) => {
+ // todo(#24612): consider warning or error when this is also a jsr package?
+ ModuleSpecifier::parse(&format!(
+ "npm:{}@{}{}",
+ alias,
+ version_req,
+ sub_path
+ .as_ref()
+ .map(|s| format!("/{}", s))
+ .unwrap_or_default()
+ ))
+ .ok()
}
},
Err(err) => {
@@ -401,6 +434,7 @@ mod tests {
}),
);
let workspace_resolver = WorkspaceResolver::new_raw(
+ Arc::new(ModuleSpecifier::from_directory_path(&cwd).unwrap()),
Some(import_map),
vec![Arc::new(package_json)],
deno_config::workspace::PackageJsonDepResolution::Enabled,
diff --git a/cli/tools/vendor/test.rs b/cli/tools/vendor/test.rs
index ac07c47d1..dc851858e 100644
--- a/cli/tools/vendor/test.rs
+++ b/cli/tools/vendor/test.rs
@@ -234,6 +234,7 @@ impl VendorTestBuilder {
let loader = self.loader.clone();
let parsed_source_cache = ParsedSourceCache::default();
let resolver = Arc::new(build_resolver(
+ output_dir.parent().unwrap(),
self.jsx_import_source_config.clone(),
self.maybe_original_import_map.clone(),
));
@@ -287,6 +288,7 @@ impl VendorTestBuilder {
}
fn build_resolver(
+ root_dir: &Path,
maybe_jsx_import_source_config: Option<JsxImportSourceConfig>,
maybe_original_import_map: Option<ImportMap>,
) -> CliGraphResolver {
@@ -295,6 +297,7 @@ fn build_resolver(
npm_resolver: None,
sloppy_imports_resolver: None,
workspace_resolver: Arc::new(WorkspaceResolver::new_raw(
+ Arc::new(ModuleSpecifier::from_directory_path(root_dir).unwrap()),
maybe_original_import_map,
Vec::new(),
deno_config::workspace::PackageJsonDepResolution::Enabled,