summaryrefslogtreecommitdiff
path: root/cli/tools/bundle.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-02-22 14:15:25 -0500
committerGitHub <noreply@github.com>2023-02-22 14:15:25 -0500
commita6ca4d0d61c95b9f7fa79ecce81a31a6d1f6cc5d (patch)
tree278a915d7722a8a3d1fffbfa1f3a12752f44d13f /cli/tools/bundle.rs
parent0f9daaeacb402a7199e58b14ad01ec0091ac2c8d (diff)
refactor: use deno_graph for npm specifiers (#17858)
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 <biwanczuk@gmail.com>
Diffstat (limited to 'cli/tools/bundle.rs')
-rw-r--r--cli/tools/bundle.rs9
1 files changed, 7 insertions, 2 deletions
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<PathBuf> = 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();