mirror of
https://github.com/denoland/deno.git
synced 2024-12-21 23:04:45 -05:00
fix(cache): do not attempt to emit non-emitable files (#15562)
This commit is contained in:
parent
86ef743c0f
commit
362af63c6f
5 changed files with 34 additions and 9 deletions
|
@ -30,6 +30,7 @@ use crate::npm::NpmPackageResolver;
|
|||
use crate::resolver::ImportMapResolver;
|
||||
use crate::resolver::JsxResolver;
|
||||
|
||||
use deno_ast::MediaType;
|
||||
use deno_core::anyhow::anyhow;
|
||||
use deno_core::anyhow::bail;
|
||||
use deno_core::anyhow::Context;
|
||||
|
@ -598,15 +599,25 @@ impl ProcState {
|
|||
code, media_type, ..
|
||||
} = entry
|
||||
{
|
||||
emit_parsed_source(
|
||||
&self.emit_cache,
|
||||
&self.parsed_source_cache,
|
||||
specifier,
|
||||
*media_type,
|
||||
code,
|
||||
&self.emit_options,
|
||||
self.emit_options_hash,
|
||||
)?;
|
||||
let is_emittable = matches!(
|
||||
media_type,
|
||||
MediaType::TypeScript
|
||||
| MediaType::Mts
|
||||
| MediaType::Cts
|
||||
| MediaType::Jsx
|
||||
| MediaType::Tsx
|
||||
);
|
||||
if is_emittable {
|
||||
emit_parsed_source(
|
||||
&self.emit_cache,
|
||||
&self.parsed_source_cache,
|
||||
specifier,
|
||||
*media_type,
|
||||
code,
|
||||
&self.emit_options,
|
||||
self.emit_options_hash,
|
||||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -92,3 +92,8 @@ itest!(check_local_by_default2 {
|
|||
output: "cache/check_local_by_default2.out",
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
itest!(json_import {
|
||||
// should not error
|
||||
args: "cache --quiet cache/json_import/main.ts",
|
||||
});
|
||||
|
|
2
cli/tests/testdata/cache/json_import/main.ts
vendored
Normal file
2
cli/tests/testdata/cache/json_import/main.ts
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
import asdf from "./test.json" assert { type: "json" };
|
||||
console.log(asdf);
|
5
cli/tests/testdata/cache/json_import/test.json
vendored
Normal file
5
cli/tests/testdata/cache/json_import/test.json
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"foo": {
|
||||
"bar": 1
|
||||
}
|
||||
}
|
|
@ -1904,6 +1904,8 @@ impl<'a> CheckOutputIntegrationTest<'a> {
|
|||
|
||||
let expected = if let Some(s) = self.output_str {
|
||||
s.to_owned()
|
||||
} else if self.output.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
let output_path = testdata_dir.join(self.output);
|
||||
println!("output path {}", output_path.display());
|
||||
|
|
Loading…
Reference in a new issue