refactor: allow deno_permissions to compile to wasm32-unknown-unknown (#29487)
Some checks are pending
ci / pre-build (push) Waiting to run
ci / test debug linux-aarch64 (push) Blocked by required conditions
ci / test release linux-aarch64 (push) Blocked by required conditions
ci / test debug macos-aarch64 (push) Blocked by required conditions
ci / test release macos-aarch64 (push) Blocked by required conditions
ci / bench release linux-x86_64 (push) Blocked by required conditions
ci / lint debug linux-x86_64 (push) Blocked by required conditions
ci / lint debug macos-x86_64 (push) Blocked by required conditions
ci / lint debug windows-x86_64 (push) Blocked by required conditions
ci / test debug linux-x86_64 (push) Blocked by required conditions
ci / test release linux-x86_64 (push) Blocked by required conditions
ci / test debug macos-x86_64 (push) Blocked by required conditions
ci / test release macos-x86_64 (push) Blocked by required conditions
ci / test debug windows-x86_64 (push) Blocked by required conditions
ci / test release windows-x86_64 (push) Blocked by required conditions
ci / build wasm32 (push) Blocked by required conditions
ci / publish canary (push) Blocked by required conditions

This commit is contained in:
David Sherret 2025-05-28 14:27:42 -04:00 committed by GitHub
parent 437afebf5c
commit cb23193f74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 411 additions and 106 deletions

28
cli/cache/mod.rs vendored
View file

@ -4,7 +4,6 @@ use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::Arc;
use deno_ast::MediaType;
use deno_cache_dir::file_fetcher::CacheSetting;
use deno_cache_dir::file_fetcher::FetchLocalOptions;
use deno_cache_dir::file_fetcher::FetchNoFollowErrorKind;
@ -75,7 +74,6 @@ pub struct FetchCacher {
file_fetcher: Arc<CliFileFetcher>,
global_http_cache: Arc<GlobalHttpCache>,
in_npm_pkg_checker: DenoInNpmPackageChecker,
module_info_cache: Arc<ModuleInfoCache>,
permissions: PermissionsContainer,
sys: CliSys,
is_deno_publish: bool,
@ -87,7 +85,6 @@ impl FetchCacher {
file_fetcher: Arc<CliFileFetcher>,
global_http_cache: Arc<GlobalHttpCache>,
in_npm_pkg_checker: DenoInNpmPackageChecker,
module_info_cache: Arc<ModuleInfoCache>,
sys: CliSys,
options: FetchCacherOptions,
) -> Self {
@ -95,7 +92,6 @@ impl FetchCacher {
file_fetcher,
global_http_cache,
in_npm_pkg_checker,
module_info_cache,
sys,
file_header_overrides: options.file_header_overrides,
permissions: options.permissions,
@ -287,28 +283,4 @@ impl Loader for FetchCacher {
}
.boxed_local()
}
fn cache_module_info(
&self,
specifier: &ModuleSpecifier,
media_type: MediaType,
source: &Arc<[u8]>,
module_info: &deno_graph::ModuleInfo,
) {
log::debug!("Caching module info for {}", specifier);
let source_hash = CacheDBHash::from_hashable(source);
let result = self.module_info_cache.set_module_info(
specifier,
media_type,
source_hash,
module_info,
);
if let Err(err) = result {
log::debug!(
"Error saving module cache info for {}. {:#}",
specifier,
err
);
}
}
}

View file

@ -136,6 +136,28 @@ impl ModuleInfoCache {
}
}
impl deno_graph::source::ModuleInfoCacher for ModuleInfoCache {
fn cache_module_info(
&self,
specifier: &ModuleSpecifier,
media_type: MediaType,
source: &Arc<[u8]>,
module_info: &deno_graph::ModuleInfo,
) {
log::debug!("Caching module info for {}", specifier);
let source_hash = CacheDBHash::from_hashable(source);
let result =
self.set_module_info(specifier, media_type, source_hash, module_info);
if let Err(err) = result {
log::debug!(
"Error saving module cache info for {}. {:#}",
specifier,
err
);
}
}
}
pub struct ModuleInfoCacheModuleAnalyzer<'a> {
module_info_cache: &'a ModuleInfoCache,
parsed_source_cache: &'a Arc<ParsedSourceCache>,

View file

@ -816,6 +816,7 @@ impl ModuleGraphBuilder {
jsr_url_provider: &CliJsrUrlProvider,
npm_resolver: Some(self.npm_graph_resolver.as_ref()),
module_analyzer: &analyzer,
module_info_cacher: self.module_info_cache.as_ref(),
reporter: maybe_file_watcher_reporter,
resolver: Some(&graph_resolver),
locker: locker.as_mut().map(|l| l as _),
@ -998,7 +999,6 @@ impl ModuleGraphBuilder {
self.file_fetcher.clone(),
self.global_http_cache.clone(),
self.in_npm_pkg_checker.clone(),
self.module_info_cache.clone(),
self.sys.clone(),
cache::FetchCacherOptions {
file_header_overrides: self.cli_options.resolve_file_header_overrides(),

View file

@ -1899,21 +1899,6 @@ impl deno_graph::source::Loader for OpenDocumentsGraphLoader<'_> {
None => self.inner_loader.load(specifier, options),
}
}
fn cache_module_info(
&self,
specifier: &deno_ast::ModuleSpecifier,
media_type: MediaType,
source: &Arc<[u8]>,
module_info: &deno_graph::ModuleInfo,
) {
self.inner_loader.cache_module_info(
specifier,
media_type,
source,
module_info,
)
}
}
fn parse_and_analyze_module(

View file

@ -582,7 +582,7 @@ impl sys_traits::BaseFsReadDir for DenoRtSys {
&self,
path: &Path,
) -> std::io::Result<
Box<dyn Iterator<Item = std::io::Result<Self::ReadDirEntry>> + '_>,
Box<dyn Iterator<Item = std::io::Result<Self::ReadDirEntry>>>,
> {
if self.0.is_path_within(path) {
let entries = self.0.read_dir_with_metadata(path)?;
@ -905,12 +905,21 @@ impl sys_traits::ThreadSleep for DenoRtSys {
}
impl sys_traits::EnvCurrentDir for DenoRtSys {
#[inline]
fn env_current_dir(&self) -> std::io::Result<PathBuf> {
#[allow(clippy::disallowed_types)] // ok because we're implementing the fs
sys_traits::impls::RealSys.env_current_dir()
}
}
impl sys_traits::EnvHomeDir for DenoRtSys {
#[inline]
fn env_home_dir(&self) -> Option<PathBuf> {
#[allow(clippy::disallowed_types)] // ok because we're implementing the fs
sys_traits::impls::RealSys.env_home_dir()
}
}
impl sys_traits::BaseEnvVar for DenoRtSys {
fn base_env_var_os(
&self,
@ -1381,16 +1390,23 @@ impl FileBackedVfs {
)
}
pub fn read_dir_with_metadata<'a>(
&'a self,
pub fn read_dir_with_metadata(
&self,
path: &Path,
) -> std::io::Result<impl Iterator<Item = FileBackedVfsDirEntry> + 'a> {
) -> std::io::Result<impl Iterator<Item = FileBackedVfsDirEntry>> {
let dir = self.dir_entry(path)?;
let path = path.to_path_buf();
Ok(dir.entries.iter().map(move |entry| FileBackedVfsDirEntry {
parent_path: path.to_path_buf(),
metadata: FileBackedVfsMetadata::from_vfs_entry_ref(entry.as_ref()),
}))
Ok(
dir
.entries
.iter()
.map(move |entry| FileBackedVfsDirEntry {
parent_path: path.to_path_buf(),
metadata: FileBackedVfsMetadata::from_vfs_entry_ref(entry.as_ref()),
})
.collect::<Vec<_>>()
.into_iter(),
)
}
pub fn read_link(&self, path: &Path) -> std::io::Result<PathBuf> {

View file

@ -81,6 +81,7 @@ async fn generate_doc_nodes_for_builtin_types(
jsr_url_provider: Default::default(),
locker: None,
module_analyzer: analyzer,
module_info_cacher: Default::default(),
npm_resolver: None,
reporter: None,
resolver: None,