@@ -51,6 +51,7 @@ use turbopack_core::{
5151 compile_time_info:: CompileTimeInfo ,
5252 context:: AssetContext ,
5353 diagnostics:: DiagnosticExt ,
54+ environment:: NodeJsVersion ,
5455 file_source:: FileSource ,
5556 ident:: Layer ,
5657 issue:: {
@@ -186,6 +187,9 @@ pub struct ProjectOptions {
186187 /// local names for variables, functions etc., which can be useful for
187188 /// debugging/profiling purposes.
188189 pub no_mangling : bool ,
190+
191+ /// The version of Node.js that is available/currently running.
192+ pub current_node_js_version : RcStr ,
189193}
190194
191195#[ derive(
@@ -442,6 +446,7 @@ impl ProjectContainer {
442446 let preview_props;
443447 let browserslist_query;
444448 let no_mangling;
449+ let current_node_js_version;
445450 {
446451 let options = self . options_state . get ( ) ;
447452 let options = options
@@ -464,7 +469,8 @@ impl ProjectContainer {
464469 build_id = options. build_id . clone ( ) ;
465470 preview_props = options. preview_props . clone ( ) ;
466471 browserslist_query = options. browserslist_query . clone ( ) ;
467- no_mangling = options. no_mangling
472+ no_mangling = options. no_mangling ;
473+ current_node_js_version = options. current_node_js_version . clone ( ) ;
468474 }
469475
470476 let dist_dir = next_config
@@ -493,6 +499,7 @@ impl ProjectContainer {
493499 encryption_key,
494500 preview_props,
495501 no_mangling,
502+ current_node_js_version,
496503 }
497504 . cell ( ) )
498505 }
@@ -570,6 +577,8 @@ pub struct Project {
570577 /// local names for variables, functions etc., which can be useful for
571578 /// debugging/profiling purposes.
572579 no_mangling : bool ,
580+
581+ current_node_js_version : RcStr ,
573582}
574583
575584#[ turbo_tasks:: value]
@@ -737,6 +746,11 @@ impl Project {
737746 * self . env
738747 }
739748
749+ #[ turbo_tasks:: function]
750+ pub ( super ) fn current_node_js_version ( & self ) -> Vc < NodeJsVersion > {
751+ NodeJsVersion :: Static ( ResolvedVc :: cell ( self . current_node_js_version . clone ( ) ) ) . cell ( )
752+ }
753+
740754 #[ turbo_tasks:: function]
741755 pub ( super ) fn next_config ( & self ) -> Vc < NextConfig > {
742756 * self . next_config
@@ -974,10 +988,10 @@ impl Project {
974988 pub ( super ) async fn server_compile_time_info ( self : Vc < Self > ) -> Result < Vc < CompileTimeInfo > > {
975989 let this = self . await ?;
976990 Ok ( get_server_compile_time_info (
977- self . env ( ) ,
978- this. define_env . nodejs ( ) ,
979991 // `/ROOT` corresponds to `[project]/`, so we need exactly the `path` part.
980992 format ! ( "/ROOT/{}" , self . project_path( ) . await ?. path) . into ( ) ,
993+ this. define_env . nodejs ( ) ,
994+ self . current_node_js_version ( ) ,
981995 ) )
982996 }
983997
@@ -987,7 +1001,7 @@ impl Project {
9871001 Ok ( get_edge_compile_time_info (
9881002 self . project_path ( ) ,
9891003 this. define_env . edge ( ) ,
990- self . env ( ) ,
1004+ self . current_node_js_version ( ) ,
9911005 ) )
9921006 }
9931007
0 commit comments