From a6ca4d0d61c95b9f7fa79ecce81a31a6d1f6cc5d Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 22 Feb 2023 14:15:25 -0500 Subject: refactor: use deno_graph for npm specifiers (#17858) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This changes npm specifiers to be handled by deno_graph and resolved to an npm package name and version when the specifier is encountered. It also slightly changes how npm specifier resolution occurs—previously it would collect all the npm specifiers and resolve them all at once, but now it resolves them on the fly as they are encountered in the module graph. https://github.com/denoland/deno_graph/pull/232 --------- Co-authored-by: Bartek Iwańczuk --- cli/tools/bundle.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'cli/tools/bundle.rs') diff --git a/cli/tools/bundle.rs b/cli/tools/bundle.rs index 6a9019cd8..d75da5ec7 100644 --- a/cli/tools/bundle.rs +++ b/cli/tools/bundle.rs @@ -6,6 +6,7 @@ use std::sync::Arc; use deno_core::error::AnyError; use deno_core::futures::FutureExt; use deno_core::resolve_url_or_path; +use deno_graph::Module; use deno_runtime::colors; use crate::args::BundleFlags; @@ -48,8 +49,12 @@ pub async fn bundle( let mut paths_to_watch: Vec = graph .specifiers() .filter_map(|(_, r)| { - r.ok() - .and_then(|module| module.specifier.to_file_path().ok()) + r.ok().and_then(|module| match module { + Module::Esm(m) => m.specifier.to_file_path().ok(), + Module::Json(m) => m.specifier.to_file_path().ok(), + // nothing to watch + Module::Node(_) | Module::Npm(_) | Module::External(_) => None, + }) }) .collect(); -- cgit v1.2.3