Skip to content

Commit

Permalink
fix(cli): Explicitly cache NPM packages during deno install (denola…
Browse files Browse the repository at this point in the history
…nd#24190)

Fixes a regression introduced in
denoland#24170, where we wouldn't actually
set up the node modules dir on `deno install` if there was an up to date
deno lockfile present.

Previously we were relying on the fact that resolving pending module
resolution called `cache_packages` (which sets up the node modules dir).
When pending resolutions were removed, and the `resolve_pending`
function with it, we also removed the `cache_packages` call needed to
set up node modules.
  • Loading branch information
nathanwhit committed Jun 12, 2024
1 parent b30e5c0 commit a753136
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cli/module_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ pub async fn load_top_level_deps(factory: &CliFactory) -> Result<(), AnyError> {
let npm_resolver = factory.npm_resolver().await?;
if let Some(npm_resolver) = npm_resolver.as_managed() {
npm_resolver.ensure_top_level_package_json_install().await?;
// TODO(nathanwhit): we call `cache_packages` if the lockfile is modified,
// so by calling it here it's possible we end up calling it twice
npm_resolver.cache_packages().await?;
}
// cache as many entries in the import map as we can
if let Some(import_map) = factory.maybe_import_map().await? {
Expand Down
38 changes: 38 additions & 0 deletions tests/specs/install/future_install_node_modules/__test__.jsonc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions tests/specs/npm/npmrc_not_next_to_package_json/main.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
[WILDCARD]
Download http:https://localhost:4260/@denotest/esm-basic/1.0.0.tgz
Initialize @denotest/[email protected]
[WILDCARD]

0 comments on commit a753136

Please sign in to comment.