1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-28 16:20:57 -05:00

fix(cli/vendor): handle assert type json during vendoring (#16059)

This commit is contained in:
Sylvain Cau 2022-09-28 02:01:43 +08:00 committed by GitHub
parent 7a47321b09
commit 9bb3ccbab2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -473,7 +473,7 @@ mod test {
"/mod.ts",
r#"import data from "https://localhost/data.json" assert { type: "json" };"#,
)
.add("https://localhost/data.json", "{}");
.add("https://localhost/data.json", "{ \"a\": \"b\" }");
})
.build()
.await
@ -489,7 +489,7 @@ mod test {
);
assert_eq!(
output.files,
to_file_vec(&[("/vendor/localhost/data.json", "{}"),]),
to_file_vec(&[("/vendor/localhost/data.json", "{ \"a\": \"b\" }"),]),
);
}

View file

@ -4,6 +4,7 @@ use deno_ast::LineAndColumnIndex;
use deno_ast::ModuleSpecifier;
use deno_ast::SourceTextInfo;
use deno_core::error::AnyError;
use deno_graph::MediaType;
use deno_graph::Module;
use deno_graph::ModuleGraph;
use deno_graph::Position;
@ -204,6 +205,11 @@ fn visit_modules(
parsed_source_cache: &ParsedSourceCache,
) -> Result<(), AnyError> {
for module in modules {
if module.media_type == MediaType::Json {
// skip visiting Json modules as they are leaves
continue;
}
let text_info =
match parsed_source_cache.get_parsed_source_from_module(module)? {
Some(source) => source.text_info().clone(),