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
7c67b121
Unverified
Commit
7c67b121
authored
Jul 27, 2023
by
Tobias Koppers
Committed by
GitHub
Jul 27, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix route groups in app_structure (#53247)
### What? the key shouldn't include route groups
parent
37bb09d3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
218 additions
and
65 deletions
+218
-65
app_structure.rs
packages/next-swc/crates/napi/src/app_structure.rs
+4
-4
app.rs
packages/next-swc/crates/next-api/src/app.rs
+17
-4
app_entries.rs
...es/next-swc/crates/next-build/src/next_app/app_entries.rs
+10
-2
app_source.rs
packages/next-swc/crates/next-core/src/app_source.rs
+14
-4
app_structure.rs
packages/next-swc/crates/next-core/src/app_structure.rs
+166
-47
app_favicon_entry.rs
...xt-swc/crates/next-core/src/next_app/app_favicon_entry.rs
+1
-0
app_page_entry.rs
.../next-swc/crates/next-core/src/next_app/app_page_entry.rs
+4
-3
app_route_entry.rs
...next-swc/crates/next-core/src/next_app/app_route_entry.rs
+2
-1
No files found.
packages/next-swc/crates/napi/src/app_structure.rs
View file @
7c67b121
...
@@ -241,14 +241,14 @@ async fn prepare_entrypoints_for_js(
...
@@ -241,14 +241,14 @@ async fn prepare_entrypoints_for_js(
let
entrypoints
=
entrypoints
let
entrypoints
=
entrypoints
.await
?
.await
?
.iter
()
.iter
()
.map
(|(
key
,
&
value
)|
{
.map
(|(
key
,
value
)|
{
let
key
=
key
.to_string
();
let
key
=
key
.to_string
();
async
move
{
async
move
{
let
value
=
match
value
{
let
value
=
match
*
value
{
Entrypoint
::
AppPage
{
loader_tree
}
=>
EntrypointForJs
::
AppPage
{
Entrypoint
::
AppPage
{
loader_tree
,
..
}
=>
EntrypointForJs
::
AppPage
{
loader_tree
:
prepare_loader_tree_for_js
(
project_path
,
loader_tree
)
.await
?
,
loader_tree
:
prepare_loader_tree_for_js
(
project_path
,
loader_tree
)
.await
?
,
},
},
Entrypoint
::
AppRoute
{
path
}
=>
EntrypointForJs
::
AppRoute
{
Entrypoint
::
AppRoute
{
path
,
..
}
=>
EntrypointForJs
::
AppRoute
{
path
:
fs_path_to_path
(
project_path
,
path
)
.await
?
,
path
:
fs_path_to_path
(
project_path
,
path
)
.await
?
,
},
},
};
};
...
...
packages/next-swc/crates/next-api/src/app.rs
View file @
7c67b121
...
@@ -342,7 +342,8 @@ impl AppProject {
...
@@ -342,7 +342,8 @@ impl AppProject {
.map
(|(
pathname
,
app_entrypoint
)|
async
{
.map
(|(
pathname
,
app_entrypoint
)|
async
{
Ok
((
Ok
((
pathname
.clone
(),
pathname
.clone
(),
*
app_entry_point_to_route
(
self
,
*
app_entrypoint
,
pathname
.clone
())
.await
?
,
*
app_entry_point_to_route
(
self
,
app_entrypoint
.clone
(),
pathname
.clone
())
.await
?
,
))
))
})
})
.try_join
()
.try_join
()
...
@@ -360,7 +361,10 @@ pub async fn app_entry_point_to_route(
...
@@ -360,7 +361,10 @@ pub async fn app_entry_point_to_route(
pathname
:
String
,
pathname
:
String
,
)
->
Vc
<
Route
>
{
)
->
Vc
<
Route
>
{
match
entrypoint
{
match
entrypoint
{
AppEntrypoint
::
AppPage
{
loader_tree
}
=>
Route
::
AppPage
{
AppEntrypoint
::
AppPage
{
original_name
,
loader_tree
,
}
=>
Route
::
AppPage
{
html_endpoint
:
Vc
::
upcast
(
html_endpoint
:
Vc
::
upcast
(
AppEndpoint
{
AppEndpoint
{
ty
:
AppEndpointType
::
Page
{
ty
:
AppEndpointType
::
Page
{
...
@@ -369,6 +373,7 @@ pub async fn app_entry_point_to_route(
...
@@ -369,6 +373,7 @@ pub async fn app_entry_point_to_route(
},
},
app_project
,
app_project
,
pathname
:
pathname
.clone
(),
pathname
:
pathname
.clone
(),
original_name
:
original_name
.clone
(),
}
}
.cell
(),
.cell
(),
),
),
...
@@ -380,16 +385,21 @@ pub async fn app_entry_point_to_route(
...
@@ -380,16 +385,21 @@ pub async fn app_entry_point_to_route(
},
},
app_project
,
app_project
,
pathname
,
pathname
,
original_name
,
}
}
.cell
(),
.cell
(),
),
),
},
},
AppEntrypoint
::
AppRoute
{
path
}
=>
Route
::
AppRoute
{
AppEntrypoint
::
AppRoute
{
original_name
,
path
,
}
=>
Route
::
AppRoute
{
endpoint
:
Vc
::
upcast
(
endpoint
:
Vc
::
upcast
(
AppEndpoint
{
AppEndpoint
{
ty
:
AppEndpointType
::
Route
{
path
},
ty
:
AppEndpointType
::
Route
{
path
},
app_project
,
app_project
,
pathname
:
pathname
.clone
(),
pathname
,
original_name
,
}
}
.cell
(),
.cell
(),
),
),
...
@@ -420,6 +430,7 @@ struct AppEndpoint {
...
@@ -420,6 +430,7 @@ struct AppEndpoint {
ty
:
AppEndpointType
,
ty
:
AppEndpointType
,
app_project
:
Vc
<
AppProject
>
,
app_project
:
Vc
<
AppProject
>
,
pathname
:
String
,
pathname
:
String
,
original_name
:
String
,
}
}
#[turbo_tasks
::
value_impl]
#[turbo_tasks
::
value_impl]
...
@@ -440,6 +451,7 @@ impl AppEndpoint {
...
@@ -440,6 +451,7 @@ impl AppEndpoint {
loader_tree
,
loader_tree
,
self
.app_project
.app_dir
(),
self
.app_project
.app_dir
(),
self
.pathname
.clone
(),
self
.pathname
.clone
(),
self
.original_name
.clone
(),
self
.app_project
.project
()
.project_path
(),
self
.app_project
.project
()
.project_path
(),
)
)
}
}
...
@@ -451,6 +463,7 @@ impl AppEndpoint {
...
@@ -451,6 +463,7 @@ impl AppEndpoint {
self
.app_project
.edge_rsc_module_context
(),
self
.app_project
.edge_rsc_module_context
(),
Vc
::
upcast
(
FileSource
::
new
(
path
)),
Vc
::
upcast
(
FileSource
::
new
(
path
)),
self
.pathname
.clone
(),
self
.pathname
.clone
(),
self
.original_name
.clone
(),
self
.app_project
.project
()
.project_path
(),
self
.app_project
.project
()
.project_path
(),
)
)
}
}
...
...
packages/next-swc/crates/next-build/src/next_app/app_entries.rs
View file @
7c67b121
...
@@ -189,21 +189,29 @@ pub async fn get_app_entries(
...
@@ -189,21 +189,29 @@ pub async fn get_app_entries(
.iter
()
.iter
()
.map
(|(
pathname
,
entrypoint
)|
async
move
{
.map
(|(
pathname
,
entrypoint
)|
async
move
{
Ok
(
match
entrypoint
{
Ok
(
match
entrypoint
{
Entrypoint
::
AppPage
{
loader_tree
}
=>
get_app_page_entry
(
Entrypoint
::
AppPage
{
original_name
,
loader_tree
,
}
=>
get_app_page_entry
(
rsc_context
,
rsc_context
,
// TODO add edge support
// TODO add edge support
rsc_context
,
rsc_context
,
*
loader_tree
,
*
loader_tree
,
app_dir
,
app_dir
,
pathname
.clone
(),
pathname
.clone
(),
original_name
.clone
(),
project_root
,
project_root
,
),
),
Entrypoint
::
AppRoute
{
path
}
=>
get_app_route_entry
(
Entrypoint
::
AppRoute
{
original_name
,
path
,
}
=>
get_app_route_entry
(
rsc_context
,
rsc_context
,
// TODO add edge support
// TODO add edge support
rsc_context
,
rsc_context
,
Vc
::
upcast
(
FileSource
::
new
(
*
path
)),
Vc
::
upcast
(
FileSource
::
new
(
*
path
)),
pathname
.clone
(),
pathname
.clone
(),
original_name
.clone
(),
project_root
,
project_root
,
),
),
})
})
...
...
packages/next-swc/crates/next-core/src/app_source.rs
View file @
7c67b121
...
@@ -611,8 +611,11 @@ pub async fn create_app_source(
...
@@ -611,8 +611,11 @@ pub async fn create_app_source(
let
entrypoints
=
entrypoints
.await
?
;
let
entrypoints
=
entrypoints
.await
?
;
let
mut
sources
:
Vec
<
_
>
=
entrypoints
let
mut
sources
:
Vec
<
_
>
=
entrypoints
.iter
()
.iter
()
.map
(|(
pathname
,
&
loader_tree
)|
match
loader_tree
{
.map
(|(
pathname
,
entrypoint
)|
match
*
entrypoint
{
Entrypoint
::
AppPage
{
loader_tree
}
=>
create_app_page_source_for_route
(
Entrypoint
::
AppPage
{
original_name
:
_
,
loader_tree
,
}
=>
create_app_page_source_for_route
(
pathname
.clone
(),
pathname
.clone
(),
loader_tree
,
loader_tree
,
context_ssr
,
context_ssr
,
...
@@ -626,7 +629,10 @@ pub async fn create_app_source(
...
@@ -626,7 +629,10 @@ pub async fn create_app_source(
output_path
,
output_path
,
render_data
,
render_data
,
),
),
Entrypoint
::
AppRoute
{
path
}
=>
create_app_route_source_for_route
(
Entrypoint
::
AppRoute
{
original_name
:
_
,
path
,
}
=>
create_app_route_source_for_route
(
pathname
.clone
(),
pathname
.clone
(),
path
,
path
,
context_ssr
,
context_ssr
,
...
@@ -646,7 +652,11 @@ pub async fn create_app_source(
...
@@ -646,7 +652,11 @@ pub async fn create_app_source(
)))
)))
.collect
();
.collect
();
if
let
Some
(
&
Entrypoint
::
AppPage
{
loader_tree
})
=
entrypoints
.get
(
"/_not-found"
)
{
if
let
Some
(
&
Entrypoint
::
AppPage
{
original_name
:
_
,
loader_tree
,
})
=
entrypoints
.get
(
"/_not-found"
)
{
if
loader_tree
.await
?
.components.await
?
.not_found
.is_some
()
{
if
loader_tree
.await
?
.components.await
?
.not_found
.is_some
()
{
// Only add a source for the app 404 page if a top-level not-found page is
// Only add a source for the app 404 page if a top-level not-found page is
// defined. Otherwise, the 404 page is handled by the pages logic.
// defined. Otherwise, the 404 page is handled by the pages logic.
...
...
packages/next-swc/crates/next-core/src/app_structure.rs
View file @
7c67b121
This diff is collapsed.
Click to expand it.
packages/next-swc/crates/next-core/src/next_app/app_favicon_entry.rs
View file @
7c67b121
...
@@ -85,6 +85,7 @@ pub async fn get_app_route_favicon_entry(
...
@@ -85,6 +85,7 @@ pub async fn get_app_route_favicon_entry(
Vc
::
upcast
(
source
),
Vc
::
upcast
(
source
),
// TODO(alexkirsz) Get this from the metadata?
// TODO(alexkirsz) Get this from the metadata?
"/favicon.ico"
.to_string
(),
"/favicon.ico"
.to_string
(),
"/favicon.ico"
.to_string
(),
project_root
,
project_root
,
))
))
}
}
packages/next-swc/crates/next-core/src/next_app/app_page_entry.rs
View file @
7c67b121
...
@@ -34,6 +34,7 @@ pub async fn get_app_page_entry(
...
@@ -34,6 +34,7 @@ pub async fn get_app_page_entry(
loader_tree
:
Vc
<
LoaderTree
>
,
loader_tree
:
Vc
<
LoaderTree
>
,
app_dir
:
Vc
<
FileSystemPath
>
,
app_dir
:
Vc
<
FileSystemPath
>
,
pathname
:
String
,
pathname
:
String
,
original_name
:
String
,
project_root
:
Vc
<
FileSystemPath
>
,
project_root
:
Vc
<
FileSystemPath
>
,
)
->
Result
<
Vc
<
AppEntry
>>
{
)
->
Result
<
Vc
<
AppEntry
>>
{
let
config
=
parse_segment_config_from_loader_tree
(
loader_tree
,
Vc
::
upcast
(
nodejs_context
));
let
config
=
parse_segment_config_from_loader_tree
(
loader_tree
,
Vc
::
upcast
(
nodejs_context
));
...
@@ -81,7 +82,7 @@ pub async fn get_app_page_entry(
...
@@ -81,7 +82,7 @@ pub async fn get_app_page_entry(
// NOTE(alexkirsz) Keep in sync with
// NOTE(alexkirsz) Keep in sync with
// next.js/packages/next/src/build/webpack/loaders/next-app-loader.ts
// next.js/packages/next/src/build/webpack/loaders/next-app-loader.ts
// TODO(alexkirsz) Support custom global error.
// TODO(alexkirsz) Support custom global error.
let
original_name
=
get_original_page_name
(
&
path
name
);
let
original_name
=
get_original_page_name
(
&
original_
name
);
writedoc!
(
writedoc!
(
result
,
result
,
...
@@ -89,7 +90,7 @@ pub async fn get_app_page_entry(
...
@@ -89,7 +90,7 @@ pub async fn get_app_page_entry(
export const tree = {loader_tree_code}
export const tree = {loader_tree_code}
export const pages = {pages}
export const pages = {pages}
export {{ default as GlobalError }} from 'next/dist/client/components/error-boundary'
export {{ default as GlobalError }} from 'next/dist/client/components/error-boundary'
export const originalPathname = {
path
name}
export const originalPathname = {
original_
name}
export const __next_app__ = {{
export const __next_app__ = {{
require: __turbopack_require__,
require: __turbopack_require__,
loadChunk: __turbopack_load__,
loadChunk: __turbopack_load__,
...
@@ -98,7 +99,7 @@ pub async fn get_app_page_entry(
...
@@ -98,7 +99,7 @@ pub async fn get_app_page_entry(
export * from 'next/dist/server/app-render/entry-base'
export * from 'next/dist/server/app-render/entry-base'
"
#
,
"
#
,
pages
=
StringifyJs
(
&
pages
),
pages
=
StringifyJs
(
&
pages
),
path
name
=
StringifyJs
(
&
original_name
),
original_
name
=
StringifyJs
(
&
original_name
),
)
?
;
)
?
;
let
file
=
File
::
from
(
result
.build
());
let
file
=
File
::
from
(
result
.build
());
...
...
packages/next-swc/crates/next-core/src/next_app/app_route_entry.rs
View file @
7c67b121
...
@@ -31,6 +31,7 @@ pub async fn get_app_route_entry(
...
@@ -31,6 +31,7 @@ pub async fn get_app_route_entry(
edge_context
:
Vc
<
ModuleAssetContext
>
,
edge_context
:
Vc
<
ModuleAssetContext
>
,
source
:
Vc
<
Box
<
dyn
Source
>>
,
source
:
Vc
<
Box
<
dyn
Source
>>
,
pathname
:
String
,
pathname
:
String
,
original_name
:
String
,
project_root
:
Vc
<
FileSystemPath
>
,
project_root
:
Vc
<
FileSystemPath
>
,
)
->
Result
<
Vc
<
AppEntry
>>
{
)
->
Result
<
Vc
<
AppEntry
>>
{
let
config
=
parse_segment_config_from_source
(
let
config
=
parse_segment_config_from_source
(
...
@@ -49,7 +50,7 @@ pub async fn get_app_route_entry(
...
@@ -49,7 +50,7 @@ pub async fn get_app_route_entry(
let
mut
result
=
RopeBuilder
::
default
();
let
mut
result
=
RopeBuilder
::
default
();
let
kind
=
"app-route"
;
let
kind
=
"app-route"
;
let
original_name
=
get_original_route_name
(
&
path
name
);
let
original_name
=
get_original_route_name
(
&
original_
name
);
let
path
=
source
.ident
()
.path
();
let
path
=
source
.ident
()
.path
();
let
options
=
AppRouteRouteModuleOptions
{
let
options
=
AppRouteRouteModuleOptions
{
...
...
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