Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: event for a resolved package nv #59

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,19 @@ pub trait NpmRegistryApi {
name: &str,
) -> Result<Arc<NpmPackageInfo>, NpmRegistryPackageInfoLoadError>;

/// Optional method an implementer can use to start downloading a package
/// name and version and doing a basic setup of the node_modules directory.
///
/// deno_npm will call this method indistriminately for every package nv it sees.
/// It is up to the implementer to not do extra work.
fn preload_package_nv(
&self,
_nv: &PackageNv,
_dist: &NpmPackageVersionDistInfo,
dsherret marked this conversation as resolved.
Show resolved Hide resolved
) {
// do nothing by default
}

/// Marks that new requests for package information should retrieve it
/// from the npm registry
///
Expand Down
3 changes: 3 additions & 0 deletions src/resolution/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,9 @@ impl<'a, TNpmRegistryApi: NpmRegistryApi>
pkg_nv.to_string(),
);

// fire off an event to start downloading this nv
self.api.preload_package_nv(&pkg_nv, &info.dist);

Ok((pkg_nv, node_id))
}

Expand Down
4 changes: 4 additions & 0 deletions src/resolution/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,10 @@ pub async fn snapshot_from_lockfile<'a>(
);
}
}

// fire off an event to start downloading this nv
api.preload_package_nv(&snapshot_package.id.nv, &version_info.dist);

packages.push(SerializedNpmResolutionSnapshotPackage {
id: snapshot_package.id.clone(),
dependencies: snapshot_package.dependencies.clone(),
Expand Down
Loading