Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
f8cb5d60
Unverified
Commit
f8cb5d60
authored
Nov 19, 2025
by
xusd320
Committed by
GitHub
Nov 19, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore(turbopack-node): remove some outdated codes (#86111)
These codes are outdated.
parent
bbfd5fb2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
3 additions
and
192 deletions
+3
-192
lib.rs
turbopack/crates/turbopack-node/src/lib.rs
+2
-102
pool.rs
turbopack/crates/turbopack-node/src/pool.rs
+0
-52
mod.rs
turbopack/crates/turbopack-node/src/source_map/mod.rs
+1
-38
No files found.
turbopack/crates/turbopack-node/src/lib.rs
View file @
f8cb5d60
...
@@ -2,27 +2,17 @@
...
@@ -2,27 +2,17 @@
#
!
[
feature
(
arbitrary_self_types
)]
#
!
[
feature
(
arbitrary_self_types
)]
#
!
[
feature
(
arbitrary_self_types_pointers
)]
#
!
[
feature
(
arbitrary_self_types_pointers
)]
use
std
::
thread
::
available_parallelism
;
use
anyhow
::
Result
;
use
anyhow
::{
Result
,
bail
};
use
rustc_hash
::
FxHashMap
;
use
rustc_hash
::
FxHashMap
;
use
turbo_rcstr
::{
RcStr
,
rcstr
};
use
turbo_tasks
::{
ResolvedVc
,
TryFlatJoinIterExt
,
Vc
};
use
turbo_tasks
::{
ResolvedVc
,
TryFlatJoinIterExt
,
Vc
};
use
turbo_tasks_env
::
ProcessEnv
;
use
turbo_tasks_fs
::{
File
,
FileSystemPath
};
use
turbo_tasks_fs
::{
File
,
FileSystemPath
,
to_sys_path
};
use
turbopack_core
::{
use
turbopack_core
::{
asset
::{
Asset
,
AssetContent
},
asset
::{
Asset
,
AssetContent
},
changed
::
content_changed
,
chunk
::{
ChunkingContext
,
ChunkingContextExt
,
EvaluatableAsset
,
EvaluatableAssets
},
module
::
Module
,
module_graph
::{
ModuleGraph
,
chunk_group_info
::
ChunkGroupEntry
},
output
::{
ExpandOutputAssetsInput
,
OutputAsset
,
OutputAssets
,
expand_output_assets
},
output
::{
ExpandOutputAssetsInput
,
OutputAsset
,
OutputAssets
,
expand_output_assets
},
source_map
::
GenerateSourceMap
,
source_map
::
GenerateSourceMap
,
virtual_output
::
VirtualOutputAsset
,
virtual_output
::
VirtualOutputAsset
,
};
};
use
self
::
pool
::
NodeJsPool
;
pub
mod
debug
;
pub
mod
debug
;
pub
mod
embed_js
;
pub
mod
embed_js
;
pub
mod
evaluate
;
pub
mod
evaluate
;
...
@@ -112,93 +102,3 @@ fn emit_package_json(dir: FileSystemPath) -> Result<Vc<()>> {
...
@@ -112,93 +102,3 @@ fn emit_package_json(dir: FileSystemPath) -> Result<Vc<()>> {
dir
,
dir
,
))
))
}
}
/// Creates a node.js renderer pool for an entrypoint.
#[turbo_tasks
::
function(operation)]
pub
async
fn
get_renderer_pool_operation
(
cwd
:
FileSystemPath
,
env
:
ResolvedVc
<
Box
<
dyn
ProcessEnv
>>
,
intermediate_asset
:
ResolvedVc
<
Box
<
dyn
OutputAsset
>>
,
intermediate_output_path
:
FileSystemPath
,
output_root
:
FileSystemPath
,
project_dir
:
FileSystemPath
,
debug
:
bool
,
)
->
Result
<
Vc
<
NodeJsPool
>>
{
emit_package_json
(
intermediate_output_path
.clone
())
?
.await
?
;
emit
(
*
intermediate_asset
,
output_root
.clone
())
.as_side_effect
()
.await
?
;
let
assets_for_source_mapping
=
internal_assets_for_source_mapping
(
*
intermediate_asset
,
output_root
.clone
());
let
entrypoint
=
intermediate_asset
.path
()
.owned
()
.await
?
;
let
Some
(
cwd
)
=
to_sys_path
(
cwd
.clone
())
.await
?
else
{
bail!
(
"can only render from a disk filesystem, but `cwd = {}`"
,
cwd
.value_to_string
()
.await
?
);
};
let
Some
(
entrypoint
)
=
to_sys_path
(
entrypoint
.clone
())
.await
?
else
{
bail!
(
"can only render from a disk filesystem, but `entrypoint = {}`"
,
entrypoint
.value_to_string
()
.await
?
);
};
// Invalidate pool when code content changes
content_changed
(
*
ResolvedVc
::
upcast
(
intermediate_asset
))
.await
?
;
Ok
(
NodeJsPool
::
new
(
cwd
,
entrypoint
,
env
.read_all
()
.await
?
.iter
()
.map
(|(
k
,
v
)|
(
k
.clone
(),
v
.clone
()))
.collect
(),
assets_for_source_mapping
.to_resolved
()
.await
?
,
output_root
,
project_dir
,
available_parallelism
()
.map_or
(
1
,
|
v
|
v
.get
()),
debug
,
)
.cell
())
}
/// Converts a module graph into node.js executable assets
#[turbo_tasks
::
function]
pub
async
fn
get_intermediate_asset
(
chunking_context
:
Vc
<
Box
<
dyn
ChunkingContext
>>
,
main_entry
:
ResolvedVc
<
Box
<
dyn
EvaluatableAsset
>>
,
other_entries
:
Vc
<
EvaluatableAssets
>
,
)
->
Result
<
Vc
<
Box
<
dyn
OutputAsset
>>>
{
Ok
(
chunking_context
.root_entry_chunk_group_asset
(
chunking_context
.chunk_path
(
None
,
main_entry
.ident
(),
None
,
rcstr!
(
".js"
))
.owned
()
.await
?
,
other_entries
.with_entry
(
*
main_entry
),
ModuleGraph
::
from_modules
(
Vc
::
cell
(
vec!
[
ChunkGroupEntry
::
Entry
(
other_entries
.await
?
.into_iter
()
.copied
()
.chain
(
std
::
iter
::
once
(
main_entry
))
.map
(
ResolvedVc
::
upcast
)
.collect
(),
)]),
false
,
),
OutputAssets
::
empty
(),
OutputAssets
::
empty
(),
))
}
#[derive(Clone,
Debug)]
#[turbo_tasks
::
value(shared)]
pub
struct
ResponseHeaders
{
pub
status
:
u16
,
pub
headers
:
Vec
<
(
RcStr
,
RcStr
)
>
,
}
turbopack/crates/turbopack-node/src/pool.rs
View file @
f8cb5d60
use
std
::{
use
std
::{
borrow
::
Cow
,
cmp
::
max
,
cmp
::
max
,
fmt
::{
Debug
,
Display
},
fmt
::{
Debug
,
Display
},
future
::
Future
,
future
::
Future
,
...
@@ -71,9 +70,6 @@ impl FormattingMode {
...
@@ -71,9 +70,6 @@ impl FormattingMode {
struct
NodeJsPoolProcess
{
struct
NodeJsPoolProcess
{
child
:
Option
<
Child
>
,
child
:
Option
<
Child
>
,
connection
:
TcpStream
,
connection
:
TcpStream
,
assets_for_source_mapping
:
ResolvedVc
<
AssetsForSourceMapping
>
,
assets_root
:
FileSystemPath
,
project_dir
:
FileSystemPath
,
stdout_handler
:
OutputStreamHandler
<
ChildStdout
,
Stdout
>
,
stdout_handler
:
OutputStreamHandler
<
ChildStdout
,
Stdout
>
,
stderr_handler
:
OutputStreamHandler
<
ChildStderr
,
Stderr
>
,
stderr_handler
:
OutputStreamHandler
<
ChildStderr
,
Stderr
>
,
debug
:
bool
,
debug
:
bool
,
...
@@ -107,39 +103,6 @@ impl PartialEq for NodeJsPoolProcess {
...
@@ -107,39 +103,6 @@ impl PartialEq for NodeJsPoolProcess {
}
}
}
}
impl
NodeJsPoolProcess
{
pub
async
fn
apply_source_mapping
<
'a
>
(
&
self
,
text
:
&
'a
str
,
formatting_mode
:
FormattingMode
,
)
->
Result
<
Cow
<
'a
,
str
>>
{
let
text
=
unmangle_identifiers
(
text
,
|
content
|
formatting_mode
.magic_identifier
(
content
));
match
text
{
Cow
::
Borrowed
(
text
)
=>
{
apply_source_mapping
(
text
,
*
self
.assets_for_source_mapping
,
self
.assets_root
.clone
(),
self
.project_dir
.clone
(),
formatting_mode
,
)
.await
}
Cow
::
Owned
(
ref
text
)
=>
{
let
cow
=
apply_source_mapping
(
text
,
*
self
.assets_for_source_mapping
,
self
.assets_root
.clone
(),
self
.project_dir
.clone
(),
formatting_mode
,
)
.await
?
;
Ok
(
Cow
::
Owned
(
cow
.into_owned
()))
}
}
}
}
const
CONNECT_TIMEOUT
:
Duration
=
Duration
::
from_secs
(
30
);
const
CONNECT_TIMEOUT
:
Duration
=
Duration
::
from_secs
(
30
);
#[derive(Clone,
PartialEq,
Eq,
Hash)]
#[derive(Clone,
PartialEq,
Eq,
Hash)]
...
@@ -456,9 +419,6 @@ impl NodeJsPoolProcess {
...
@@ -456,9 +419,6 @@ impl NodeJsPoolProcess {
let
mut
process
=
Self
{
let
mut
process
=
Self
{
child
:
Some
(
child
),
child
:
Some
(
child
),
connection
,
connection
,
assets_for_source_mapping
,
assets_root
:
assets_root
.clone
(),
project_dir
:
project_dir
.clone
(),
stdout_handler
,
stdout_handler
,
stderr_handler
,
stderr_handler
,
debug
,
debug
,
...
@@ -958,18 +918,6 @@ impl NodeJsOperation {
...
@@ -958,18 +918,6 @@ impl NodeJsOperation {
self
.allow_process_reuse
=
false
;
self
.allow_process_reuse
=
false
;
}
}
}
}
pub
async
fn
apply_source_mapping
<
'a
>
(
&
self
,
text
:
&
'a
str
,
formatting_mode
:
FormattingMode
,
)
->
Result
<
Cow
<
'a
,
str
>>
{
if
let
Some
(
process
)
=
self
.process
.as_ref
()
{
process
.apply_source_mapping
(
text
,
formatting_mode
)
.await
}
else
{
Ok
(
Cow
::
Borrowed
(
text
))
}
}
}
}
impl
Drop
for
NodeJsOperation
{
impl
Drop
for
NodeJsOperation
{
...
...
turbopack/crates/turbopack-node/src/source_map/mod.rs
View file @
f8cb5d60
...
@@ -9,7 +9,6 @@ use const_format::concatcp;
...
@@ -9,7 +9,6 @@ use const_format::concatcp;
use
once_cell
::
sync
::
Lazy
;
use
once_cell
::
sync
::
Lazy
;
use
regex
::
Regex
;
use
regex
::
Regex
;
pub
use
trace
::{
StackFrame
,
TraceResult
,
trace_source_map
};
pub
use
trace
::{
StackFrame
,
TraceResult
,
trace_source_map
};
use
tracing
::{
Level
,
instrument
};
use
turbo_tasks
::{
ReadRef
,
Vc
};
use
turbo_tasks
::{
ReadRef
,
Vc
};
use
turbo_tasks_fs
::{
use
turbo_tasks_fs
::{
FileLinesContent
,
FileSystemPath
,
source_context
::
get_source_context
,
to_sys_path
,
FileLinesContent
,
FileSystemPath
,
source_context
::
get_source_context
,
to_sys_path
,
...
@@ -17,12 +16,11 @@ use turbo_tasks_fs::{
...
@@ -17,12 +16,11 @@ use turbo_tasks_fs::{
use
turbopack_cli_utils
::
source_context
::
format_source_context_lines
;
use
turbopack_cli_utils
::
source_context
::
format_source_context_lines
;
use
turbopack_core
::{
use
turbopack_core
::{
PROJECT_FILESYSTEM_NAME
,
SOURCE_URL_PROTOCOL
,
PROJECT_FILESYSTEM_NAME
,
SOURCE_URL_PROTOCOL
,
output
::
OutputAsset
,
source_map
::{
GenerateSourceMap
,
SourceMap
},
source_map
::{
GenerateSourceMap
,
SourceMap
},
};
};
use
turbopack_ecmascript
::
magic_identifier
::
unmangle_identifiers
;
use
turbopack_ecmascript
::
magic_identifier
::
unmangle_identifiers
;
use
crate
::{
AssetsForSourceMapping
,
internal_assets_for_source_mapping
,
pool
::
FormattingMode
};
use
crate
::{
AssetsForSourceMapping
,
pool
::
FormattingMode
};
pub
mod
trace
;
pub
mod
trace
;
...
@@ -332,38 +330,3 @@ impl StructuredError {
...
@@ -332,38 +330,3 @@ impl StructuredError {
Ok
(
message
)
Ok
(
message
)
}
}
}
}
pub
async
fn
trace_stack
(
error
:
StructuredError
,
root_asset
:
Vc
<
Box
<
dyn
OutputAsset
>>
,
output_path
:
FileSystemPath
,
project_dir
:
FileSystemPath
,
)
->
Result
<
String
>
{
let
assets_for_source_mapping
=
internal_assets_for_source_mapping
(
root_asset
,
output_path
.clone
());
trace_stack_with_source_mapping_assets
(
error
,
assets_for_source_mapping
,
output_path
,
project_dir
,
)
.await
}
#[instrument(level
=
Level
::
TRACE,
skip_all)]
pub
async
fn
trace_stack_with_source_mapping_assets
(
error
:
StructuredError
,
assets_for_source_mapping
:
Vc
<
AssetsForSourceMapping
>
,
output_path
:
FileSystemPath
,
project_dir
:
FileSystemPath
,
)
->
Result
<
String
>
{
error
.print
(
assets_for_source_mapping
,
output_path
,
project_dir
,
FormattingMode
::
Plain
,
)
.await
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment