summaryrefslogtreecommitdiff
path: root/cli/emit.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/emit.rs')
-rw-r--r--cli/emit.rs24
1 files changed, 15 insertions, 9 deletions
diff --git a/cli/emit.rs b/cli/emit.rs
index c9a90abb7..3aa2c4794 100644
--- a/cli/emit.rs
+++ b/cli/emit.rs
@@ -153,6 +153,7 @@ pub(crate) fn get_ts_config(
"isolatedModules": true,
"lib": lib,
"module": "esnext",
+ "resolveJsonModule": true,
"strict": true,
"target": "esnext",
"tsBuildInfoFile": "deno:///.tsbuildinfo",
@@ -186,6 +187,7 @@ pub(crate) fn get_ts_config(
"jsx": "react",
"jsxFactory": "React.createElement",
"jsxFragmentFactory": "React.Fragment",
+ "resolveJsonModule": true,
})),
ConfigType::RuntimeEmit { tsc_emit } => {
let mut ts_config = TsConfig::new(json!({
@@ -403,14 +405,15 @@ pub(crate) fn check_and_maybe_emit(
log::debug!("module missing, skipping emit for {}", specifier);
continue;
};
- // Sometimes if `tsc` sees a CommonJS file it will _helpfully_ output it
- // to ESM, which we don't really want to do unless someone has enabled
- // check_js.
- if !check_js
- && matches!(
- media_type,
- MediaType::JavaScript | MediaType::Cjs | MediaType::Mjs
- )
+ // Sometimes if `tsc` sees a CommonJS file or a JSON module, it will
+ // _helpfully_ output it, which we don't really want to do unless
+ // someone has enabled check_js.
+ if matches!(media_type, MediaType::Json)
+ || (!check_js
+ && matches!(
+ media_type,
+ MediaType::JavaScript | MediaType::Cjs | MediaType::Mjs
+ ))
{
log::debug!("skipping emit for {}", specifier);
continue;
@@ -429,7 +432,10 @@ pub(crate) fn check_and_maybe_emit(
MediaType::Dts | MediaType::Dcts | MediaType::Dmts => {
cache.set(CacheType::Declaration, &specifier, emit.data)?;
}
- _ => unreachable!(),
+ _ => unreachable!(
+ "unexpected media_type {} {}",
+ emit.media_type, specifier
+ ),
}
}
}