Skip to content

Commit

Permalink
build(next_font): update build error
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Mar 27, 2023
1 parent 1435944 commit 33fca53
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 22 deletions.
3 changes: 1 addition & 2 deletions packages/next-swc/crates/next-core/src/next_config.rs
Expand Up @@ -7,7 +7,6 @@ use turbo_tasks::{
trace::TraceRawVcs,
CompletionVc, Value,
};
use turbo_tasks_bytes::stream::SingleValue;
use turbo_tasks_env::EnvMapVc;
use turbo_tasks_fs::{json::parse_json_with_source_context, FileSystemPathVc};
use turbopack::evaluate_context::node_evaluate_asset_context;
Expand Down Expand Up @@ -605,7 +604,7 @@ pub async fn load_next_config_internal(
)
.await?;

let SingleValue::Single(val) = config_value.try_into_single().await.context("Evaluation of Next.js config failed")? else {
let turbo_tasks_bytes::stream::SingleValue::Single(val) = config_value.try_into_single().await.context("Evaluation of Next.js config failed")? else {
return Ok(NextConfig::default().cell());
};
let next_config: NextConfig = parse_json_with_source_context(val.to_str()?)?;
Expand Down
27 changes: 12 additions & 15 deletions packages/next-swc/crates/next-core/src/next_font/google/mod.rs
Expand Up @@ -5,6 +5,7 @@ use turbo_tasks::{
primitives::{OptionStringVc, StringVc, U32Vc},
Value,
};

use turbo_tasks_fs::{json::parse_json_with_source_context, FileContent, FileSystemPathVc};
use turbopack_core::{
resolve::{
Expand Down Expand Up @@ -383,19 +384,15 @@ async fn get_mock_stylesheet(
use std::{collections::HashMap, path::Path};

use turbo_tasks::CompletionVc;
use turbo_tasks_bytes::stream::SingleValue;
use turbo_tasks_env::{CommandLineProcessEnvVc, ProcessEnv};
use turbo_tasks_fs::{
json::parse_json_with_source_context, DiskFileSystemVc, File, FileSystem,
};
use turbo_tasks_fs::{DiskFileSystemVc, File, FileSystem};
use turbopack::evaluate_context::node_evaluate_asset_context;
use turbopack_core::{context::AssetContext, ident::AssetIdentVc};
use turbopack_ecmascript::{
EcmascriptInputTransformsVc, EcmascriptModuleAssetType, EcmascriptModuleAssetVc,
};
use turbopack_node::{
evaluate::{evaluate, JavaScriptValue},
execution_context::ExecutionContext,
};
use turbopack_node::{evaluate::evaluate, execution_context::ExecutionContext};

let env = CommandLineProcessEnvVc::new().as_process_env();
let mocked_response_js = &*env.read("NEXT_FONT_GOOGLE_MOCKED_RESPONSES").await?;
Expand Down Expand Up @@ -438,6 +435,7 @@ async fn get_mock_stylesheet(
context,
Value::new(EcmascriptModuleAssetType::Ecmascript),
EcmascriptInputTransformsVc::cell(vec![]),
Default::default(),
context.compile_time_info(),
)
.into();
Expand All @@ -457,15 +455,14 @@ async fn get_mock_stylesheet(
)
.await?;

match &*val {
JavaScriptValue::Value(val) => {
let mock_map: HashMap<String, Option<String>> =
parse_json_with_source_context(&val.to_str()?)?;
Ok((mock_map.get(url).context("url not found")?).clone())
match &val.try_into_single().await? {
SingleValue::Single(val) => {
let val: HashMap<String, Option<String>> =
parse_json_with_source_context(val.to_str()?)?;
Ok(val.get(url).context("url not found")?.clone())
}
JavaScriptValue::Error => panic!("Unexpected error evaluating JS"),
JavaScriptValue::Stream(_) => {
unimplemented!("Stream not supported now");
_ => {
panic!("Unexpected error evaluating JS")
}
}
}
8 changes: 3 additions & 5 deletions packages/next-swc/crates/next-dev-tests/tests/integration.rs
Expand Up @@ -410,12 +410,10 @@ async fn run_browser(addr: SocketAddr) -> Result<JestRunResult> {
message
))
}
} else if expected_error {
println!("Exception throw in page:\n{}", message);
} else {
if expected_error {
println!("Exception throw in page:\n{}", message);
} else {
println!("Exception throw in page (this would fail the test case without TURBOPACK_DEBUG_BROWSER):\n{}", message);
}
println!("Exception throw in page (this would fail the test case without TURBOPACK_DEBUG_BROWSER):\n{}", message);
}
} else {
return Err(anyhow!("Error events channel ended unexpectedly"));
Expand Down

0 comments on commit 33fca53

Please sign in to comment.