mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 07:14:47 -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::ImportMapResolver;
|
||||||
use crate::resolver::JsxResolver;
|
use crate::resolver::JsxResolver;
|
||||||
|
|
||||||
|
use deno_ast::MediaType;
|
||||||
use deno_core::anyhow::anyhow;
|
use deno_core::anyhow::anyhow;
|
||||||
use deno_core::anyhow::bail;
|
use deno_core::anyhow::bail;
|
||||||
use deno_core::anyhow::Context;
|
use deno_core::anyhow::Context;
|
||||||
|
@ -598,15 +599,25 @@ impl ProcState {
|
||||||
code, media_type, ..
|
code, media_type, ..
|
||||||
} = entry
|
} = entry
|
||||||
{
|
{
|
||||||
emit_parsed_source(
|
let is_emittable = matches!(
|
||||||
&self.emit_cache,
|
media_type,
|
||||||
&self.parsed_source_cache,
|
MediaType::TypeScript
|
||||||
specifier,
|
| MediaType::Mts
|
||||||
*media_type,
|
| MediaType::Cts
|
||||||
code,
|
| MediaType::Jsx
|
||||||
&self.emit_options,
|
| MediaType::Tsx
|
||||||
self.emit_options_hash,
|
);
|
||||||
)?;
|
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(())
|
Ok(())
|
||||||
|
|
|
@ -92,3 +92,8 @@ itest!(check_local_by_default2 {
|
||||||
output: "cache/check_local_by_default2.out",
|
output: "cache/check_local_by_default2.out",
|
||||||
http_server: true,
|
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 {
|
let expected = if let Some(s) = self.output_str {
|
||||||
s.to_owned()
|
s.to_owned()
|
||||||
|
} else if self.output.is_empty() {
|
||||||
|
String::new()
|
||||||
} else {
|
} else {
|
||||||
let output_path = testdata_dir.join(self.output);
|
let output_path = testdata_dir.join(self.output);
|
||||||
println!("output path {}", output_path.display());
|
println!("output path {}", output_path.display());
|
||||||
|
|
Loading…
Reference in a new issue