Skip to content

Commit

Permalink
fix json assets (#3700)
Browse files Browse the repository at this point in the history
  • Loading branch information
ForsakenHarmony authored Feb 8, 2023
1 parent 33cbfb8 commit a44847f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion crates/turbopack-json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ impl EcmascriptChunkItem for JsonChunkItem {
let data = content.parse_json().await?;
match &*data {
FileJsonContent::Content(data) => {
let js_str_content = serde_json::to_string(data)?;
let js_str_content = serde_json::to_string(&data.to_string())?;
let inner_code =
format!("__turbopack_export_value__(JSON.parse({js_str_content}));");

Ok(EcmascriptChunkItemContent {
inner_code: inner_code.into(),
..Default::default()
Expand All @@ -139,6 +140,7 @@ impl EcmascriptChunkItem for JsonChunkItem {
} else {
write!(message, "{}", e)?;
}

Err(Error::msg(message))
}
FileJsonContent::NotFound => {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a44847f

Please sign in to comment.