summaryrefslogtreecommitdiff
path: root/cli/emit.rs
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2021-12-15 07:39:20 +1100
committerGitHub <noreply@github.com>2021-12-15 07:39:20 +1100
commite8d7b430cecf4357bd9b2ea717266e339516aa19 (patch)
treeed363a243a4af31d8d06e0bba028f72f2900827e /cli/emit.rs
parentb220a58d1a678ffd46a42567909d0b0d59731d99 (diff)
chore: updates to support deno_graph API changes (#13080)
Diffstat (limited to 'cli/emit.rs')
-rw-r--r--cli/emit.rs23
1 files changed, 17 insertions, 6 deletions
diff --git a/cli/emit.rs b/cli/emit.rs
index 004171f42..c9a90abb7 100644
--- a/cli/emit.rs
+++ b/cli/emit.rs
@@ -264,7 +264,11 @@ fn get_root_names(
graph
.roots
.iter()
- .filter_map(|s| graph.get(s).map(|m| (m.specifier.clone(), m.media_type)))
+ .filter_map(|s| {
+ graph
+ .get(s)
+ .map(|m| (m.specifier().clone(), *m.media_type()))
+ })
.collect()
}
}
@@ -394,7 +398,7 @@ pub(crate) fn check_and_maybe_emit(
// resolve it via the graph.
let specifier = graph.resolve(&specifiers[0]);
let (media_type, source) = if let Some(module) = graph.get(&specifier) {
- (&module.media_type, module.source.clone())
+ (module.media_type(), module.maybe_source().unwrap_or(""))
} else {
log::debug!("module missing, skipping emit for {}", specifier);
continue;
@@ -479,8 +483,8 @@ impl swc::bundler::Load for BundleLoader<'_> {
if let Some(m) = self.graph.get(specifier) {
let (fm, module) = ast::transpile_module(
specifier,
- &m.source,
- m.media_type,
+ m.maybe_source().unwrap_or(""),
+ *m.media_type(),
self.emit_options,
self.cm.clone(),
)?;
@@ -725,7 +729,11 @@ pub(crate) fn valid_emit(
false
} else if let Some(version) = cache.get(CacheType::Version, s) {
if let Some(module) = graph.get(s) {
- version == get_version(module.source.as_bytes(), &config_bytes)
+ version
+ == get_version(
+ module.maybe_source().unwrap_or("").as_bytes(),
+ &config_bytes,
+ )
} else {
// We have a source module in the graph we can't find, so the emit is
// clearly wrong
@@ -798,7 +806,10 @@ pub(crate) fn to_file_map(
| MediaType::Unknown
) {
if let Some(module) = graph.get(&specifier) {
- files.insert(specifier.to_string(), module.source.to_string());
+ files.insert(
+ specifier.to_string(),
+ module.maybe_source().unwrap_or("").to_string(),
+ );
}
}
if let Some(declaration) = cache.get(CacheType::Declaration, &specifier) {