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
fe523042
Commit
fe523042
authored
Sep 24, 2025
by
Luke Sandberg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve errors when there is a misconfigured loader that prevent parsing
parent
dc1f2cc4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
29 deletions
+52
-29
project.rs
crates/napi/src/next_api/project.rs
+30
-29
utils.rs
crates/napi/src/next_api/utils.rs
+4
-0
operation.rs
crates/next-api/src/operation.rs
+18
-0
No files found.
crates/napi/src/next_api/project.rs
View file @
fe523042
...
@@ -69,7 +69,7 @@ use crate::{
...
@@ -69,7 +69,7 @@ use crate::{
},
},
utils
::{
utils
::{
DetachedVc
,
NapiDiagnostic
,
NapiIssue
,
RootTask
,
TurbopackResult
,
get_diagnostics
,
DetachedVc
,
NapiDiagnostic
,
NapiIssue
,
RootTask
,
TurbopackResult
,
get_diagnostics
,
get_issues
,
subscribe
,
get_issues
,
s
trongly_consistent_catch_collectables
,
s
ubscribe
,
},
},
},
},
util
::
DhatProfilerGuard
,
util
::
DhatProfilerGuard
,
...
@@ -740,16 +740,13 @@ pub struct NapiMiddleware {
...
@@ -740,16 +740,13 @@ pub struct NapiMiddleware {
}
}
impl
NapiMiddleware
{
impl
NapiMiddleware
{
fn
from_middleware
(
fn
from_middleware
(
value
:
&
MiddlewareOperation
,
turbopack_ctx
:
&
NextTurbopackContext
)
->
Self
{
value
:
&
MiddlewareOperation
,
NapiMiddleware
{
turbopack_ctx
:
&
NextTurbopackContext
,
)
->
Result
<
Self
>
{
Ok
(
NapiMiddleware
{
endpoint
:
External
::
new
(
ExternalEndpoint
(
DetachedVc
::
new
(
endpoint
:
External
::
new
(
ExternalEndpoint
(
DetachedVc
::
new
(
turbopack_ctx
.clone
(),
turbopack_ctx
.clone
(),
value
.endpoint
,
value
.endpoint
,
))),
))),
}
)
}
}
}
}
}
...
@@ -763,8 +760,8 @@ impl NapiInstrumentation {
...
@@ -763,8 +760,8 @@ impl NapiInstrumentation {
fn
from_instrumentation
(
fn
from_instrumentation
(
value
:
&
InstrumentationOperation
,
value
:
&
InstrumentationOperation
,
turbopack_ctx
:
&
NextTurbopackContext
,
turbopack_ctx
:
&
NextTurbopackContext
,
)
->
Result
<
Self
>
{
)
->
Self
{
Ok
(
NapiInstrumentation
{
NapiInstrumentation
{
node_js
:
External
::
new
(
ExternalEndpoint
(
DetachedVc
::
new
(
node_js
:
External
::
new
(
ExternalEndpoint
(
DetachedVc
::
new
(
turbopack_ctx
.clone
(),
turbopack_ctx
.clone
(),
value
.node_js
,
value
.node_js
,
...
@@ -773,7 +770,7 @@ impl NapiInstrumentation {
...
@@ -773,7 +770,7 @@ impl NapiInstrumentation {
turbopack_ctx
.clone
(),
turbopack_ctx
.clone
(),
value
.edge
,
value
.edge
,
))),
))),
}
)
}
}
}
}
}
...
@@ -791,7 +788,7 @@ impl NapiEntrypoints {
...
@@ -791,7 +788,7 @@ impl NapiEntrypoints {
fn
from_entrypoints_op
(
fn
from_entrypoints_op
(
entrypoints
:
&
EntrypointsOperation
,
entrypoints
:
&
EntrypointsOperation
,
turbopack_ctx
:
&
NextTurbopackContext
,
turbopack_ctx
:
&
NextTurbopackContext
,
)
->
Result
<
Self
>
{
)
->
Self
{
let
routes
=
entrypoints
let
routes
=
entrypoints
.routes
.routes
.iter
()
.iter
()
...
@@ -800,13 +797,11 @@ impl NapiEntrypoints {
...
@@ -800,13 +797,11 @@ impl NapiEntrypoints {
let
middleware
=
entrypoints
let
middleware
=
entrypoints
.middleware
.middleware
.as_ref
()
.as_ref
()
.map
(|
m
|
NapiMiddleware
::
from_middleware
(
m
,
turbopack_ctx
))
.map
(|
m
|
NapiMiddleware
::
from_middleware
(
m
,
turbopack_ctx
));
.transpose
()
?
;
let
instrumentation
=
entrypoints
let
instrumentation
=
entrypoints
.instrumentation
.instrumentation
.as_ref
()
.as_ref
()
.map
(|
i
|
NapiInstrumentation
::
from_instrumentation
(
i
,
turbopack_ctx
))
.map
(|
i
|
NapiInstrumentation
::
from_instrumentation
(
i
,
turbopack_ctx
));
.transpose
()
?
;
let
pages_document_endpoint
=
External
::
new
(
ExternalEndpoint
(
DetachedVc
::
new
(
let
pages_document_endpoint
=
External
::
new
(
ExternalEndpoint
(
DetachedVc
::
new
(
turbopack_ctx
.clone
(),
turbopack_ctx
.clone
(),
entrypoints
.pages_document_endpoint
,
entrypoints
.pages_document_endpoint
,
...
@@ -819,19 +814,20 @@ impl NapiEntrypoints {
...
@@ -819,19 +814,20 @@ impl NapiEntrypoints {
turbopack_ctx
.clone
(),
turbopack_ctx
.clone
(),
entrypoints
.pages_error_endpoint
,
entrypoints
.pages_error_endpoint
,
)));
)));
Ok
(
NapiEntrypoints
{
NapiEntrypoints
{
routes
,
routes
,
middleware
,
middleware
,
instrumentation
,
instrumentation
,
pages_document_endpoint
,
pages_document_endpoint
,
pages_app_endpoint
,
pages_app_endpoint
,
pages_error_endpoint
,
pages_error_endpoint
,
}
)
}
}
}
}
}
#[turbo_tasks
::
value(serialization
=
"none"
)]
#[turbo_tasks
::
value(serialization
=
"none"
)]
struct
EntrypointsWithIssues
{
struct
EntrypointsWithIssues
{
// Will be an empty set of entrypoints if there were fatal issues.
entrypoints
:
ReadRef
<
EntrypointsOperation
>
,
entrypoints
:
ReadRef
<
EntrypointsOperation
>
,
issues
:
Arc
<
Vec
<
ReadRef
<
PlainIssue
>>>
,
issues
:
Arc
<
Vec
<
ReadRef
<
PlainIssue
>>>
,
diagnostics
:
Arc
<
Vec
<
ReadRef
<
PlainDiagnostic
>>>
,
diagnostics
:
Arc
<
Vec
<
ReadRef
<
PlainDiagnostic
>>>
,
...
@@ -844,12 +840,15 @@ async fn get_entrypoints_with_issues_operation(
...
@@ -844,12 +840,15 @@ async fn get_entrypoints_with_issues_operation(
)
->
Result
<
Vc
<
EntrypointsWithIssues
>>
{
)
->
Result
<
Vc
<
EntrypointsWithIssues
>>
{
let
entrypoints_operation
=
let
entrypoints_operation
=
EntrypointsOperation
::
new
(
project_container_entrypoints_operation
(
container
));
EntrypointsOperation
::
new
(
project_container_entrypoints_operation
(
container
));
let
entrypoints
=
entrypoints_operation
.read_strongly_consistent
()
.await
?
;
let
issues
=
get_issues
(
entrypoints_operation
)
.await
?
;
let
(
entrypoints
,
issues
,
diagnostics
,
effects
)
=
let
diagnostics
=
get_diagnostic
s
(
entrypoints_operation
)
.await
?
;
strongly_consistent_catch_collectable
s
(
entrypoints_operation
)
.await
?
;
let
effects
=
Arc
::
new
(
get_effects
(
entrypoints_operation
)
.await
?
);
Ok
(
EntrypointsWithIssues
{
Ok
(
EntrypointsWithIssues
{
entrypoints
,
entrypoints
:
match
entrypoints
{
Some
(
ep
)
=>
ep
,
None
=>
EntrypointsOperation
::
empty
()
.await
?
,
},
issues
,
issues
,
diagnostics
,
diagnostics
,
effects
,
effects
,
...
@@ -917,7 +916,7 @@ pub async fn project_write_all_entrypoints_to_disk(
...
@@ -917,7 +916,7 @@ pub async fn project_write_all_entrypoints_to_disk(
.await
?
;
.await
?
;
Ok
(
TurbopackResult
{
Ok
(
TurbopackResult
{
result
:
NapiEntrypoints
::
from_entrypoints_op
(
&
entrypoints
,
&
project
.turbopack_ctx
)
?
,
result
:
NapiEntrypoints
::
from_entrypoints_op
(
&
entrypoints
,
&
project
.turbopack_ctx
),
issues
:
issues
.iter
()
.map
(|
i
|
NapiIssue
::
from
(
&**
i
))
.collect
(),
issues
:
issues
.iter
()
.map
(|
i
|
NapiIssue
::
from
(
&**
i
))
.collect
(),
diagnostics
:
diags
.iter
()
.map
(|
d
|
NapiDiagnostic
::
from
(
d
))
.collect
(),
diagnostics
:
diags
.iter
()
.map
(|
d
|
NapiDiagnostic
::
from
(
d
))
.collect
(),
})
})
...
@@ -932,12 +931,14 @@ async fn get_all_written_entrypoints_with_issues_operation(
...
@@ -932,12 +931,14 @@ async fn get_all_written_entrypoints_with_issues_operation(
container
,
container
,
app_dir_only
,
app_dir_only
,
));
));
let
entrypoints
=
entrypoints_operation
.read_strongly_consistent
()
.await
?
;
let
(
entrypoints
,
issues
,
diagnostics
,
effects
)
=
let
issues
=
get_issues
(
entrypoints_operation
)
.await
?
;
strongly_consistent_catch_collectables
(
entrypoints_operation
)
.await
?
;
let
diagnostics
=
get_diagnostics
(
entrypoints_operation
)
.await
?
;
let
effects
=
Arc
::
new
(
get_effects
(
entrypoints_operation
)
.await
?
);
Ok
(
EntrypointsWithIssues
{
Ok
(
EntrypointsWithIssues
{
entrypoints
,
entrypoints
:
match
entrypoints
{
Some
(
ep
)
=>
ep
,
None
=>
EntrypointsOperation
::
empty
()
.await
?
,
},
issues
,
issues
,
diagnostics
,
diagnostics
,
effects
,
effects
,
...
@@ -1018,7 +1019,7 @@ pub fn project_entrypoints_subscribe(
...
@@ -1018,7 +1019,7 @@ pub fn project_entrypoints_subscribe(
let
(
entrypoints
,
issues
,
diags
)
=
ctx
.value
;
let
(
entrypoints
,
issues
,
diags
)
=
ctx
.value
;
Ok
(
vec!
[
TurbopackResult
{
Ok
(
vec!
[
TurbopackResult
{
result
:
NapiEntrypoints
::
from_entrypoints_op
(
&
entrypoints
,
&
turbopack_ctx
)
?
,
result
:
NapiEntrypoints
::
from_entrypoints_op
(
&
entrypoints
,
&
turbopack_ctx
),
issues
:
issues
issues
:
issues
.iter
()
.iter
()
.map
(|
issue
|
NapiIssue
::
from
(
&**
issue
))
.map
(|
issue
|
NapiIssue
::
from
(
&**
issue
))
...
...
crates/napi/src/next_api/utils.rs
View file @
fe523042
...
@@ -290,6 +290,10 @@ impl NapiDiagnostic {
...
@@ -290,6 +290,10 @@ impl NapiDiagnostic {
}
}
}
}
/// A result from a turbo-tasks computation that can be passed back and forth to JS across the
/// [`napi`][mod@napi] boundary via [`External`].
///
/// The `result` field is flattened into the object when passing across the boundary.
pub
struct
TurbopackResult
<
T
:
ToNapiValue
>
{
pub
struct
TurbopackResult
<
T
:
ToNapiValue
>
{
pub
result
:
T
,
pub
result
:
T
,
pub
issues
:
Vec
<
NapiIssue
>
,
pub
issues
:
Vec
<
NapiIssue
>
,
...
...
crates/next-api/src/operation.rs
View file @
fe523042
...
@@ -45,6 +45,19 @@ async fn entrypoints_without_collectibles_operation(
...
@@ -45,6 +45,19 @@ async fn entrypoints_without_collectibles_operation(
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
impl
EntrypointsOperation
{
impl
EntrypointsOperation
{
/// an empty set of entrypoints for when there are critical errors
#[turbo_tasks
::
function]
pub
fn
empty
()
->
Vc
<
Self
>
{
Self
{
routes
:
FxIndexMap
::
default
(),
middleware
:
None
,
instrumentation
:
None
,
pages_document_endpoint
:
none_endpoint_operation
(),
pages_app_endpoint
:
none_endpoint_operation
(),
pages_error_endpoint
:
none_endpoint_operation
(),
}
.cell
()
}
#[turbo_tasks
::
function(operation)]
#[turbo_tasks
::
function(operation)]
pub
async
fn
new
(
entrypoints
:
OperationVc
<
Entrypoints
>
)
->
Result
<
Vc
<
Self
>>
{
pub
async
fn
new
(
entrypoints
:
OperationVc
<
Entrypoints
>
)
->
Result
<
Vc
<
Self
>>
{
let
e
=
entrypoints
.connect
()
.await
?
;
let
e
=
entrypoints
.connect
()
.await
?
;
...
@@ -139,6 +152,11 @@ enum EndpointSelector {
...
@@ -139,6 +152,11 @@ enum EndpointSelector {
#[turbo_tasks
::
value(transparent)]
#[turbo_tasks
::
value(transparent)]
pub
struct
OptionEndpoint
(
Option
<
ResolvedVc
<
Box
<
dyn
Endpoint
>>>
);
pub
struct
OptionEndpoint
(
Option
<
ResolvedVc
<
Box
<
dyn
Endpoint
>>>
);
#[turbo_tasks
::
function(operation)]
pub
fn
none_endpoint_operation
()
->
Vc
<
OptionEndpoint
>
{
OptionEndpoint
(
None
)
.cell
()
}
/// Given a selector and the `Entrypoints` operation that it comes from, connect the operation and
/// Given a selector and the `Entrypoints` operation that it comes from, connect the operation and
/// return an `OperationVc` containing the selected value. The returned operation will keep the
/// return an `OperationVc` containing the selected value. The returned operation will keep the
/// entire `Entrypoints` operation alive.
/// entire `Entrypoints` operation alive.
...
...
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