Skip to content

Commit

Permalink
Fix postcss nitpicks (vercel/turbo#3077)
Browse files Browse the repository at this point in the history
Re: vercel/turbo#3065

It also fixes the gnarly stack trace error whenever the node code throws, but it doesn't look very pretty. Not sure how to handle it:

<img width="1280" alt="Screen Shot 2022-12-19 at 3 46 56 PM" src="https://user-images.githubusercontent.com/112982/208519095-ec7ad539-5c23-4b95-bcc1-71ba30381e60.png">
  • Loading branch information
jridgewell committed Dec 19, 2022
1 parent 78abb7e commit 3ce0c6a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 61 deletions.
44 changes: 0 additions & 44 deletions packages/next-swc/crates/next-core/js/src/ipc/evaluate.ts

This file was deleted.

37 changes: 20 additions & 17 deletions packages/next-swc/crates/next-core/src/next_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ use turbo_tasks::{
trace::TraceRawVcs,
Value,
};
use turbo_tasks_fs::FileSystemEntryType;
use turbopack::evaluate_context::node_evaluate_asset_context;
use turbopack_core::{
asset::Asset,
reference_type::{EntryReferenceSubType, ReferenceType},
resolve::options::{ImportMap, ImportMapping},
resolve::{
find_context_file,
options::{ImportMap, ImportMapping},
FindContextFileResult,
},
source_asset::SourceAssetVc,
};
use turbopack_ecmascript::{
Expand All @@ -27,7 +30,7 @@ use turbopack_node::{
use crate::embed_js::next_asset;

#[turbo_tasks::value(serialization = "custom")]
#[derive(Debug, Serialize, Deserialize, Clone)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
#[serde(rename_all = "camelCase")]
pub struct NextConfig {
pub config_file: Option<String>,
Expand Down Expand Up @@ -200,6 +203,15 @@ impl NextConfigVc {
}
}

fn next_configs() -> StringsVc {
StringsVc::cell(
["next.config.mjs", "next.config.js"]
.into_iter()
.map(ToOwned::to_owned)
.collect(),
)
}

#[turbo_tasks::function]
pub async fn load_next_config(execution_context: ExecutionContextVc) -> Result<NextConfigVc> {
let ExecutionContext {
Expand All @@ -212,20 +224,10 @@ pub async fn load_next_config(execution_context: ExecutionContextVc) -> Result<N
import_map.insert_wildcard_alias("next/", ImportMapping::External(None).into());

let context = node_evaluate_asset_context(Some(import_map.cell()));
let next_config_mjs_path = project_root.join("next.config.mjs").realpath();
let next_config_js_path = project_root.join("next.config.js").realpath();
let config_asset = if matches!(
&*next_config_mjs_path.get_type().await?,
FileSystemEntryType::File
) {
Some(SourceAssetVc::new(next_config_mjs_path))
} else if matches!(
&*next_config_js_path.get_type().await?,
FileSystemEntryType::File
) {
Some(SourceAssetVc::new(next_config_js_path))
} else {
None
let find_config_result = find_context_file(project_root, next_configs());
let config_asset = match &*find_config_result.await? {
FindContextFileResult::Found(config_path, _) => Some(SourceAssetVc::new(*config_path)),
FindContextFileResult::NotFound(_) => None,
};

let runtime_entries = config_asset.map(|config_asset| {
Expand Down Expand Up @@ -262,6 +264,7 @@ pub async fn load_next_config(execution_context: ExecutionContextVc) -> Result<N
let next_config: NextConfig = serde_json::from_reader(val.read())?;
Ok(next_config.cell())
}
JavaScriptValue::Error => Ok(NextConfig::default().cell()),
JavaScriptValue::Stream(_) => {
unimplemented!("Stream not supported now");
}
Expand Down

0 comments on commit 3ce0c6a

Please sign in to comment.