Skip to content

Commit

Permalink
Remove EnvironmentIntention
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkirsz committed Jun 29, 2023
1 parent b636d3d commit 9438a77
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ pub async fn get_page_chunks(
)
.into();

let node_compile_time_info = get_server_compile_time_info(node_ty, mode, env, node_addr);
let node_compile_time_info = get_server_compile_time_info(mode, env, node_addr);
let node_resolve_options_context = get_server_resolve_options_context(
project_root,
node_ty,
Expand Down
26 changes: 7 additions & 19 deletions packages/next-swc/crates/next-core/src/app_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use turbopack_binding::{
chunk::{EvaluatableAssetVc, EvaluatableAssetsVc},
compile_time_info::CompileTimeInfoVc,
context::{AssetContext, AssetContextVc},
environment::{EnvironmentIntention, ServerAddrVc},
environment::ServerAddrVc,
issue::{Issue, IssueSeverity, IssueSeverityVc, IssueVc},
reference_type::{
EcmaScriptModulesReferenceSubType, EntryReferenceSubType, InnerAssetsVc,
Expand Down Expand Up @@ -195,7 +195,7 @@ fn next_ssr_client_module_transition(
next_config,
execution_context,
),
ssr_environment: get_server_compile_time_info(ty, mode, process_env, server_addr),
ssr_environment: get_server_compile_time_info(mode, process_env, server_addr),
}
.cell()
.into()
Expand All @@ -213,7 +213,7 @@ fn next_server_component_transition(
) -> TransitionVc {
let ty = Value::new(ServerContextType::AppRSC { app_dir });
let mode = NextMode::Development;
let rsc_compile_time_info = get_server_compile_time_info(ty, mode, process_env, server_addr);
let rsc_compile_time_info = get_server_compile_time_info(mode, process_env, server_addr);
let rsc_resolve_options_context =
get_server_resolve_options_context(project_path, ty, mode, next_config, execution_context);
let rsc_module_options_context =
Expand All @@ -240,11 +240,7 @@ fn next_edge_server_component_transition(
) -> TransitionVc {
let ty = Value::new(ServerContextType::AppRSC { app_dir });
let mode = NextMode::Development;
let rsc_compile_time_info = get_edge_compile_time_info(
project_path,
server_addr,
Value::new(EnvironmentIntention::ServerRendering),
);
let rsc_compile_time_info = get_edge_compile_time_info(project_path, server_addr);
let rsc_resolve_options_context =
get_edge_resolve_options_context(project_path, ty, next_config, execution_context);
let rsc_module_options_context =
Expand Down Expand Up @@ -272,11 +268,7 @@ fn next_edge_route_transition(
) -> TransitionVc {
let server_ty = Value::new(ServerContextType::AppRoute { app_dir });

let edge_compile_time_info = get_edge_compile_time_info(
project_path,
server_addr,
Value::new(EnvironmentIntention::Api),
);
let edge_compile_time_info = get_edge_compile_time_info(project_path, server_addr);

let edge_chunking_context = DevChunkingContextVc::builder(
project_path,
Expand Down Expand Up @@ -316,11 +308,7 @@ fn next_edge_page_transition(
) -> TransitionVc {
let server_ty = Value::new(ServerContextType::AppRoute { app_dir });

let edge_compile_time_info = get_edge_compile_time_info(
project_path,
server_addr,
Value::new(EnvironmentIntention::ServerRendering),
);
let edge_compile_time_info = get_edge_compile_time_info(project_path, server_addr);

let edge_chunking_context = DevChunkingContextVc::builder(
project_path,
Expand Down Expand Up @@ -457,7 +445,7 @@ fn app_context(
let ssr_ty = Value::new(ServerContextType::AppSSR { app_dir });
ModuleAssetContextVc::new(
TransitionsByNameVc::cell(transitions),
get_server_compile_time_info(ssr_ty, mode, env, server_addr),
get_server_compile_time_info(mode, env, server_addr),
get_server_module_options_context(
project_path,
execution_context,
Expand Down
13 changes: 5 additions & 8 deletions packages/next-swc/crates/next-core/src/next_client/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ use turbopack_binding::{
FreeVarReference, FreeVarReferencesVc,
},
context::AssetContextVc,
environment::{
BrowserEnvironment, EnvironmentIntention, EnvironmentVc, ExecutionEnvironment,
},
environment::{BrowserEnvironment, EnvironmentVc, ExecutionEnvironment},
free_var_references,
resolve::{parse::RequestVc, pattern::Pattern},
},
Expand Down Expand Up @@ -107,18 +105,17 @@ async fn next_client_free_vars(mode: NextMode) -> Result<FreeVarReferencesVc> {

#[turbo_tasks::function]
pub fn get_client_compile_time_info(mode: NextMode, browserslist_query: &str) -> CompileTimeInfoVc {
CompileTimeInfo::builder(EnvironmentVc::new(
Value::new(ExecutionEnvironment::Browser(
CompileTimeInfo::builder(EnvironmentVc::new(Value::new(
ExecutionEnvironment::Browser(
BrowserEnvironment {
dom: true,
web_worker: false,
service_worker: false,
browserslist_query: browserslist_query.to_owned(),
}
.into(),
)),
Value::new(EnvironmentIntention::Client),
))
),
)))
.defines(next_client_defines(mode))
.free_var_references(next_client_free_vars(mode))
.cell()
Expand Down
13 changes: 4 additions & 9 deletions packages/next-swc/crates/next-core/src/next_edge/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use turbopack_binding::{
FreeVarReference, FreeVarReferencesVc,
},
environment::{
EdgeWorkerEnvironment, EnvironmentIntention, EnvironmentVc, ExecutionEnvironment,
ServerAddrVc,
EdgeWorkerEnvironment, EnvironmentVc, ExecutionEnvironment, ServerAddrVc,
},
free_var_references,
},
Expand Down Expand Up @@ -64,14 +63,10 @@ fn next_edge_free_vars(project_path: FileSystemPathVc) -> FreeVarReferencesVc {
pub fn get_edge_compile_time_info(
project_path: FileSystemPathVc,
server_addr: ServerAddrVc,
intention: Value<EnvironmentIntention>,
) -> CompileTimeInfoVc {
CompileTimeInfo::builder(EnvironmentVc::new(
Value::new(ExecutionEnvironment::EdgeWorker(
EdgeWorkerEnvironment { server_addr }.into(),
)),
intention,
))
CompileTimeInfo::builder(EnvironmentVc::new(Value::new(
ExecutionEnvironment::EdgeWorker(EdgeWorkerEnvironment { server_addr }.into()),
)))
.defines(next_edge_defines())
.free_var_references(next_edge_free_vars(project_path))
.cell()
Expand Down
23 changes: 4 additions & 19 deletions packages/next-swc/crates/next-core/src/next_server/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ use turbopack_binding::{
CompileTimeDefines, CompileTimeDefinesVc, CompileTimeInfo, CompileTimeInfoVc,
FreeVarReferencesVc,
},
environment::{
EnvironmentIntention, EnvironmentVc, ExecutionEnvironment, NodeJsEnvironmentVc,
ServerAddrVc,
},
environment::{EnvironmentVc, ExecutionEnvironment, NodeJsEnvironmentVc, ServerAddrVc},
free_var_references,
},
ecmascript::TransformPluginVc,
Expand Down Expand Up @@ -245,25 +242,13 @@ async fn next_server_free_vars(mode: NextMode) -> Result<FreeVarReferencesVc> {

#[turbo_tasks::function]
pub fn get_server_compile_time_info(
ty: Value<ServerContextType>,
mode: NextMode,
process_env: ProcessEnvVc,
server_addr: ServerAddrVc,
) -> CompileTimeInfoVc {
CompileTimeInfo::builder(EnvironmentVc::new(
Value::new(ExecutionEnvironment::NodeJsLambda(
NodeJsEnvironmentVc::current(process_env, server_addr),
)),
match ty.into_value() {
ServerContextType::Pages { .. } | ServerContextType::PagesData { .. } => {
Value::new(EnvironmentIntention::ServerRendering)
}
ServerContextType::AppSSR { .. } => Value::new(EnvironmentIntention::Prerendering),
ServerContextType::AppRSC { .. } => Value::new(EnvironmentIntention::ServerRendering),
ServerContextType::AppRoute { .. } => Value::new(EnvironmentIntention::Api),
ServerContextType::Middleware => Value::new(EnvironmentIntention::Middleware),
},
))
CompileTimeInfo::builder(EnvironmentVc::new(Value::new(
ExecutionEnvironment::NodeJsLambda(NodeJsEnvironmentVc::current(process_env, server_addr)),
)))
.defines(next_server_defines(mode))
.free_var_references(next_server_free_vars(mode))
.cell()
Expand Down
10 changes: 3 additions & 7 deletions packages/next-swc/crates/next-core/src/page_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use turbopack_binding::{
asset::{AssetVc, AssetsVc},
chunk::{ChunkingContextVc, EvaluatableAssetVc, EvaluatableAssetsVc},
context::{AssetContext, AssetContextVc},
environment::{EnvironmentIntention, ServerAddrVc},
environment::ServerAddrVc,
reference_type::{EntryReferenceSubType, InnerAssetsVc, ReferenceType},
source_asset::SourceAssetVc,
},
Expand Down Expand Up @@ -152,11 +152,7 @@ pub async fn create_page_source(
.cell()
.into();

let edge_compile_time_info = get_edge_compile_time_info(
project_root,
server_addr,
Value::new(EnvironmentIntention::Api),
);
let edge_compile_time_info = get_edge_compile_time_info(project_root, server_addr);

let edge_chunking_context = DevChunkingContextVc::builder(
project_root,
Expand Down Expand Up @@ -186,7 +182,7 @@ pub async fn create_page_source(
.cell()
.into();

let server_compile_time_info = get_server_compile_time_info(server_ty, mode, env, server_addr);
let server_compile_time_info = get_server_compile_time_info(mode, env, server_addr);
let server_resolve_options_context = get_server_resolve_options_context(
project_root,
server_ty,
Expand Down
5 changes: 2 additions & 3 deletions packages/next-swc/crates/next-core/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use turbopack_binding::{
changed::any_content_changed,
chunk::ChunkingContext,
context::{AssetContext, AssetContextVc},
environment::{EnvironmentIntention::Middleware, ServerAddrVc, ServerInfo},
environment::{ServerAddrVc, ServerInfo},
ident::AssetIdentVc,
issue::IssueVc,
reference_type::{EcmaScriptModulesReferenceSubType, InnerAssetsVc, ReferenceType},
Expand Down Expand Up @@ -240,8 +240,7 @@ fn edge_transition_map(
next_config: NextConfigVc,
execution_context: ExecutionContextVc,
) -> TransitionsByNameVc {
let edge_compile_time_info =
get_edge_compile_time_info(project_path, server_addr, Value::new(Middleware));
let edge_compile_time_info = get_edge_compile_time_info(project_path, server_addr);

let edge_chunking_context = DevChunkingContextVc::builder(
project_path,
Expand Down
13 changes: 5 additions & 8 deletions packages/next-swc/crates/next-core/src/web_entry_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ use turbopack_binding::{
CompileTimeDefines, CompileTimeDefinesVc, CompileTimeInfo, CompileTimeInfoVc,
FreeVarReferencesVc,
},
environment::{
BrowserEnvironment, EnvironmentIntention, EnvironmentVc, ExecutionEnvironment,
},
environment::{BrowserEnvironment, EnvironmentVc, ExecutionEnvironment},
free_var_references,
reference_type::{EntryReferenceSubType, ReferenceType},
resolve::{origin::PlainResolveOriginVc, parse::RequestVc},
Expand Down Expand Up @@ -62,18 +60,17 @@ async fn web_free_vars() -> Result<FreeVarReferencesVc> {

#[turbo_tasks::function]
pub fn get_compile_time_info(browserslist_query: &str) -> CompileTimeInfoVc {
CompileTimeInfo::builder(EnvironmentVc::new(
Value::new(ExecutionEnvironment::Browser(
CompileTimeInfo::builder(EnvironmentVc::new(Value::new(
ExecutionEnvironment::Browser(
BrowserEnvironment {
dom: true,
web_worker: false,
service_worker: false,
browserslist_query: browserslist_query.to_owned(),
}
.into(),
)),
Value::new(EnvironmentIntention::Client),
))
),
)))
.defines(web_defines())
.free_var_references(web_free_vars())
.cell()
Expand Down

0 comments on commit 9438a77

Please sign in to comment.