mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
147411e64b
Adds much better support for the unstable Deno workspaces as well as support for npm workspaces. npm workspaces is still lacking in that we only install packages into the root node_modules folder. We'll make it smarter over time in order for it to figure out when to add node_modules folders within packages. This includes a breaking change in config file resolution where we stop searching for config files on the first found package.json unless it's in a workspace. For the previous behaviour, the root deno.json needs to be updated to be a workspace by adding `"workspace": ["./path-to-pkg-json-folder-goes-here"]`. See details in https://github.com/denoland/deno_config/pull/66 Closes #24340 Closes #24159 Closes #24161 Closes #22020 Closes #18546 Closes #16106 Closes #24160
25 lines
769 B
Rust
25 lines
769 B
Rust
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
use deno_core::error::AnyError;
|
|
use deno_core::serde_json;
|
|
use deno_core::url::Url;
|
|
use deno_runtime::deno_permissions::PermissionsContainer;
|
|
|
|
use crate::file_fetcher::FileFetcher;
|
|
|
|
pub async fn resolve_import_map_value_from_specifier(
|
|
specifier: &Url,
|
|
file_fetcher: &FileFetcher,
|
|
) -> Result<serde_json::Value, AnyError> {
|
|
if specifier.scheme() == "data" {
|
|
let data_url_text =
|
|
deno_graph::source::RawDataUrl::parse(specifier)?.decode()?;
|
|
Ok(serde_json::from_str(&data_url_text)?)
|
|
} else {
|
|
let file = file_fetcher
|
|
.fetch(specifier, &PermissionsContainer::allow_all())
|
|
.await?
|
|
.into_text_decoded()?;
|
|
Ok(serde_json::from_str(&file.source)?)
|
|
}
|
|
}
|