Skip to content

Commit

Permalink
reduce work and tasks during module analysis (#7080)
Browse files Browse the repository at this point in the history
### Description

* Avoid read_dir calls on files

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->


Closes PACK-2278
  • Loading branch information
sokra authored Jan 24, 2024
1 parent f885aec commit 64d5d60
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
7 changes: 6 additions & 1 deletion crates/turbopack-ecmascript/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,12 @@ impl EcmascriptModuleAsset {
}

let find_package_json = find_context_file(
self.origin_path().resolve().await?,
self.origin_path()
.resolve()
.await?
.parent()
.resolve()
.await?,
package_json().resolve().await?,
)
.await?;
Expand Down
8 changes: 1 addition & 7 deletions crates/turbopack-ecmascript/src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ async fn parse_internal(
let fs_path_vc = source.ident().path();
let fs_path = &*fs_path_vc.await?;
let ident = &*source.ident().to_string().await?;
let file_path_hash = *hash_ident(source.ident().to_string()).await? as u128;
let file_path_hash = hash_xxh3_hash64(&*source.ident().to_string().await?) as u128;
let ty = ty.into_value();
let content = match content.await {
Ok(content) => content,
Expand Down Expand Up @@ -389,12 +389,6 @@ async fn parse_content(
Ok(result.cell())
}

#[turbo_tasks::function]
async fn hash_ident(ident: Vc<String>) -> Result<Vc<u64>> {
let ident = &*ident.await?;
Ok(Vc::cell(hash_xxh3_hash64(ident)))
}

#[turbo_tasks::value]
struct ReadSourceIssue {
source: Vc<Box<dyn Source>>,
Expand Down

1 comment on commit 64d5d60

@vercel
Copy link

@vercel vercel bot commented on 64d5d60 Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.