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
2dade5df
Unverified
Commit
2dade5df
authored
May 16, 2023
by
Alex Kirszenberg
Committed by
GitHub
May 16, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor pages structure (#49802)
parent
e5ad96ed
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
521 additions
and
302 deletions
+521
-302
error.tsx
packages/next-swc/crates/next-core/js/src/entry/error.tsx
+1
-1
_app.tsx
...ges/next-swc/crates/next-core/js/src/entry/pages/_app.tsx
+2
-0
_document.tsx
...ext-swc/crates/next-core/js/src/entry/pages/_document.tsx
+2
-0
_error.tsx
...s/next-swc/crates/next-core/js/src/entry/pages/_error.tsx
+2
-0
tsconfig.json
packages/next-swc/crates/next-core/js/tsconfig.json
+1
-0
next_import_map.rs
packages/next-swc/crates/next-core/src/next_import_map.rs
+2
-2
page_source.rs
packages/next-swc/crates/next-core/src/page_source.rs
+195
-145
pages_structure.rs
packages/next-swc/crates/next-core/src/pages_structure.rs
+279
-115
util.rs
packages/next-swc/crates/next-core/src/util.rs
+15
-17
Error during SSR Rendering-bd7c95.txt
...xt/error/ssr/issues/Error during SSR Rendering-bd7c95.txt
+1
-1
Error resolving commonjs request-d9f9d2.txt
...in-esm/issues/Error resolving commonjs request-d9f9d2.txt
+1
-1
Error resolving commonjs request-ffa54f.txt
...in-esm/issues/Error resolving commonjs request-ffa54f.txt
+1
-1
Processing image failed-303117.txt
...ext/image/basic/issues/Processing image failed-303117.txt
+1
-1
Processing image failed-b11d72.txt
...ext/image/basic/issues/Processing image failed-b11d72.txt
+1
-1
Processing image failed-eed147.txt
...ext/image/basic/issues/Processing image failed-eed147.txt
+1
-1
Processing image failed-ff12d7.txt
...ext/image/basic/issues/Processing image failed-ff12d7.txt
+1
-1
Error during SSR Rendering-d9114a.txt
...emotepattern/issues/Error during SSR Rendering-d9114a.txt
+1
-1
lint TP1004 fs.existsSync(__q____q____q____star__0-55e40b.txt
... TP1004 fs.existsSync(__q____q____q____star__0-55e40b.txt
+1
-1
lint TP1004 fs.existsSync(__q____q____q____star__0-bbe67b.txt
... TP1004 fs.existsSync(__q____q____q____star__0-bbe67b.txt
+1
-1
lint TP1004 fs.readFileSync(__q____q____q____star_-50ea93.txt
... TP1004 fs.readFileSync(__q____q____q____star_-50ea93.txt
+1
-1
lint TP1004 fs.readFileSync(__q____q____q____star_-a3cd71.txt
... TP1004 fs.readFileSync(__q____q____q____star_-a3cd71.txt
+1
-1
lint TP1006 path.resolve(__q____q____q____star__0_-820338.txt
... TP1006 path.resolve(__q____q____q____star__0_-820338.txt
+1
-1
lint TP1006 path.resolve(__q____q____q____star__0_-c23a56.txt
... TP1006 path.resolve(__q____q____q____star__0_-c23a56.txt
+1
-1
Issue while running loader-014f3c.txt
...itted-errors/issues/Issue while running loader-014f3c.txt
+1
-1
Issue while running loader-2ea486.txt
...itted-errors/issues/Issue while running loader-2ea486.txt
+1
-1
Issue while running loader-30bad6.txt
...itted-errors/issues/Issue while running loader-30bad6.txt
+1
-1
Issue while running loader-8d8b58.txt
...itted-errors/issues/Issue while running loader-8d8b58.txt
+1
-1
Issue while running loader-9b6240.txt
...itted-errors/issues/Issue while running loader-9b6240.txt
+1
-1
Issue while running loader-d6914f.txt
...itted-errors/issues/Issue while running loader-d6914f.txt
+1
-1
Issue while running loader-d779f3.txt
...itted-errors/issues/Issue while running loader-d779f3.txt
+1
-1
Issue while running loader-fa8e05.txt
...itted-errors/issues/Issue while running loader-fa8e05.txt
+1
-1
No files found.
packages/next-swc/crates/next-core/js/src/entry/error.tsx
View file @
2dade5df
...
...
@@ -7,4 +7,4 @@ export {
__N_SSG
,
// @ts-expect-error
__N_SSP
,
}
from
'@vercel/turbopack-next/
internal
/_error'
}
from
'@vercel/turbopack-next/
pages
/_error'
packages/next-swc/crates/next-core/js/src/entry/pages/_app.tsx
0 → 100644
View file @
2dade5df
export
*
from
'@vercel/turbopack-next/pages/_app'
export
{
default
}
from
'@vercel/turbopack-next/pages/_app'
packages/next-swc/crates/next-core/js/src/entry/pages/_document.tsx
0 → 100644
View file @
2dade5df
export
*
from
'@vercel/turbopack-next/pages/_document'
export
{
default
}
from
'@vercel/turbopack-next/pages/_document'
packages/next-swc/crates/next-core/js/src/entry/pages/_error.tsx
0 → 100644
View file @
2dade5df
export
*
from
'@vercel/turbopack-next/pages/_error'
export
{
default
}
from
'@vercel/turbopack-next/pages/_error'
packages/next-swc/crates/next-core/js/tsconfig.json
View file @
2dade5df
...
...
@@ -26,6 +26,7 @@
"@vercel/turbopack-next/*"
:
[
"src/*"
],
"@vercel/turbopack-next/pages/_app"
:
[
"node_modules/next/app"
],
"@vercel/turbopack-next/pages/_document"
:
[
"node_modules/next/document"
],
"@vercel/turbopack-next/pages/_error"
:
[
"node_modules/next/error"
],
"@vercel/turbopack-next/internal/_error"
:
[
"node_modules/next/error"
],
"next/*"
:
[
"node_modules/next/*"
]
},
...
...
packages/next-swc/crates/next-core/src/next_import_map.rs
View file @
2dade5df
...
...
@@ -79,7 +79,7 @@ pub async fn get_next_client_import_map(
);
insert_alias_to_alternatives
(
&
mut
import_map
,
format!
(
"{VIRTUAL_PACKAGE_NAME}/
internal
/_error"
),
format!
(
"{VIRTUAL_PACKAGE_NAME}/
pages
/_error"
),
vec!
[
request_to_import_mapping
(
pages_dir
,
"./_error"
),
request_to_import_mapping
(
pages_dir
,
"next/error"
),
...
...
@@ -375,7 +375,7 @@ pub async fn insert_next_server_special_aliases(
);
insert_alias_to_alternatives
(
import_map
,
format!
(
"{VIRTUAL_PACKAGE_NAME}/
internal
/_error"
),
format!
(
"{VIRTUAL_PACKAGE_NAME}/
pages
/_error"
),
vec!
[
request_to_import_mapping
(
pages_dir
,
"./_error"
),
external_request_to_import_mapping
(
"next/error"
),
...
...
packages/next-swc/crates/next-core/src/page_source.rs
View file @
2dade5df
...
...
@@ -76,9 +76,10 @@ use crate::{
},
page_loader
::
create_page_loader
,
pages_structure
::{
OptionPagesStructureVc
,
PagesStructure
,
PagesStructureItem
,
PagesStructureVc
,
OptionPagesStructureVc
,
PagesDirectoryStructure
,
PagesDirectoryStructureVc
,
PagesStructure
,
PagesStructureItem
,
PagesStructureVc
,
},
util
::{
parse_config_from_source
,
pathname_for_path
,
render_data
,
NextRuntime
},
util
::{
parse_config_from_source
,
pathname_for_path
,
render_data
,
NextRuntime
,
PathType
},
};
/// Create a content source serving the `pages` or `src/pages` directory as
...
...
@@ -86,10 +87,10 @@ use crate::{
#[turbo_tasks
::
function]
pub
async
fn
create_page_source
(
pages_structure
:
OptionPagesStructureVc
,
project_
path
:
FileSystemPathVc
,
project_
root
:
FileSystemPathVc
,
execution_context
:
ExecutionContextVc
,
output_path
:
FileSystemPathVc
,
server
_root
:
FileSystemPathVc
,
node_root
:
FileSystemPathVc
,
client
_root
:
FileSystemPathVc
,
env
:
ProcessEnvVc
,
browserslist_query
:
&
str
,
next_config
:
NextConfigVc
,
...
...
@@ -97,11 +98,11 @@ pub async fn create_page_source(
)
->
Result
<
ContentSourceVc
>
{
let
(
pages_dir
,
pages_structure
)
=
if
let
Some
(
pages_structure
)
=
*
pages_structure
.await
?
{
(
pages_structure
.
directory
()
.resolve
()
.await
?
,
pages_structure
.
project_path
()
.resolve
()
.await
?
,
Some
(
pages_structure
),
)
}
else
{
(
project_
path
.join
(
"pages"
),
None
)
(
project_
root
.join
(
"pages"
),
None
)
};
let
client_ty
=
Value
::
new
(
ClientContextType
::
Pages
{
pages_dir
});
...
...
@@ -110,24 +111,24 @@ pub async fn create_page_source(
let
client_compile_time_info
=
get_client_compile_time_info
(
browserslist_query
);
let
client_module_options_context
=
get_client_module_options_context
(
project_
path
,
project_
root
,
execution_context
,
client_compile_time_info
.environment
(),
client_ty
,
next_config
,
);
let
client_resolve_options_context
=
get_client_resolve_options_context
(
project_
path
,
client_ty
,
next_config
,
execution_context
);
get_client_resolve_options_context
(
project_
root
,
client_ty
,
next_config
,
execution_context
);
let
client_chunking_context
=
get_client_chunking_context
(
project_
path
,
server
_root
,
project_
root
,
client
_root
,
client_compile_time_info
.environment
(),
client_ty
,
);
let
client_runtime_entries
=
get_client_runtime_entries
(
project_
path
,
env
,
client_ty
,
next_config
,
execution_context
);
get_client_runtime_entries
(
project_
root
,
env
,
client_ty
,
next_config
,
execution_context
);
let
next_client_transition
=
NextClientTransition
{
is_app
:
false
,
...
...
@@ -141,17 +142,17 @@ pub async fn create_page_source(
.into
();
let
edge_compile_time_info
=
get_edge_compile_time_info
(
project_
path
,
project_
root
,
server_addr
,
Value
::
new
(
EnvironmentIntention
::
Api
),
);
let
edge_chunking_context
=
DevChunkingContextVc
::
builder
(
project_
path
,
output_path
.join
(
"edge"
),
output_path
.join
(
"edge/chunks"
),
project_
root
,
node_root
.join
(
"edge"
),
node_root
.join
(
"edge/chunks"
),
get_client_assets_path
(
server
_root
,
client
_root
,
Value
::
new
(
ClientContextType
::
Pages
{
pages_dir
}),
),
edge_compile_time_info
.environment
(),
...
...
@@ -159,15 +160,15 @@ pub async fn create_page_source(
.reference_chunk_source_maps
(
false
)
.build
();
let
edge_resolve_options_context
=
get_edge_resolve_options_context
(
project_
path
,
server_ty
,
next_config
,
execution_context
);
get_edge_resolve_options_context
(
project_
root
,
server_ty
,
next_config
,
execution_context
);
let
next_edge_transition
=
NextEdgeTransition
{
edge_compile_time_info
,
edge_chunking_context
,
edge_module_options_context
:
None
,
edge_resolve_options_context
,
output_path
,
base_path
:
project_
path
,
output_path
:
node_root
,
base_path
:
project_
root
,
bootstrap_asset
:
next_asset
(
"entry/edge-bootstrap.ts"
),
entry_name
:
"edge"
.to_string
(),
}
...
...
@@ -176,13 +177,13 @@ pub async fn create_page_source(
let
server_compile_time_info
=
get_server_compile_time_info
(
server_ty
,
env
,
server_addr
);
let
server_resolve_options_context
=
get_server_resolve_options_context
(
project_
path
,
server_ty
,
next_config
,
execution_context
);
get_server_resolve_options_context
(
project_
root
,
server_ty
,
next_config
,
execution_context
);
let
server_module_options_context
=
get_server_module_options_context
(
project_
path
,
execution_context
,
server_ty
,
next_config
);
get_server_module_options_context
(
project_
root
,
execution_context
,
server_ty
,
next_config
);
let
server_data_module_options_context
=
get_server_module_options_context
(
project_
path
,
project_
root
,
execution_context
,
server_data_ty
,
next_config
,
...
...
@@ -195,10 +196,10 @@ pub async fn create_page_source(
(
"next-client-chunks"
.to_string
(),
NextClientChunksTransitionVc
::
new
(
project_
path
,
project_
root
,
execution_context
,
client_ty
,
server
_root
,
client
_root
,
client_compile_time_info
,
next_config
,
)
...
...
@@ -236,14 +237,14 @@ pub async fn create_page_source(
let
server_runtime_entries
=
AssetsVc
::
cell
(
vec!
[
ProcessEnvAssetVc
::
new
(
project_
path
,
injected_env
)
.into
()
ProcessEnvAssetVc
::
new
(
project_
root
,
injected_env
)
.into
()
]);
let
fallback_runtime_entries
=
AssetsVc
::
cell
(
vec!
[]);
let
fallback_page
=
get_fallback_page
(
project_
path
,
project_
root
,
execution_context
,
server
_root
,
client
_root
,
env
,
client_compile_time_info
,
next_config
,
...
...
@@ -257,7 +258,7 @@ pub async fn create_page_source(
// Match _next/404 first to ensure rewrites work properly.
sources
.push
(
create_not_found_page_source
(
project_
path
,
project_
root
,
env
,
server_context
,
client_context
,
...
...
@@ -265,8 +266,8 @@ pub async fn create_page_source(
page_extensions
,
fallback_runtime_entries
,
fallback_page
,
server
_root
,
output_path
.join
(
"force_not_found"
),
client
_root
,
node_root
.join
(
"force_not_found"
),
SpecificityVc
::
exact
(),
NextExactMatcherVc
::
new
(
StringVc
::
cell
(
"_next/404"
.to_string
()))
.into
(),
render_data
,
...
...
@@ -275,9 +276,9 @@ pub async fn create_page_source(
);
if
let
Some
(
pages_structure
)
=
pages_structure
{
sources
.push
(
create_page_source_for_directory
(
sources
.push
(
create_page_source_for_
root_
directory
(
pages_structure
,
project_
path
,
project_
root
,
env
,
server_context
,
server_data_context
,
...
...
@@ -285,21 +286,21 @@ pub async fn create_page_source(
pages_dir
,
server_runtime_entries
,
fallback_page
,
server
_root
,
output_path
,
client
_root
,
node_root
,
render_data
,
));
}
sources
.push
(
AssetGraphContentSourceVc
::
new_eager
(
server
_root
,
fallback_page
.as_asset
())
AssetGraphContentSourceVc
::
new_eager
(
client
_root
,
fallback_page
.as_asset
())
.as_content_source
()
.issue_context
(
pages_dir
,
"Next.js pages directory fallback"
),
);
sources
.push
(
create_not_found_page_source
(
project_
path
,
project_
root
,
env
,
server_context
,
client_context
,
...
...
@@ -307,8 +308,8 @@ pub async fn create_page_source(
page_extensions
,
fallback_runtime_entries
,
fallback_page
,
server
_root
,
output_path
.join
(
"fallback_not_found"
),
client
_root
,
node_root
.join
(
"fallback_not_found"
),
SpecificityVc
::
not_found
(),
NextFallbackMatcherVc
::
new
()
.into
(),
render_data
,
...
...
@@ -333,19 +334,19 @@ async fn create_page_source_for_file(
page_asset
:
AssetVc
,
runtime_entries
:
AssetsVc
,
fallback_page
:
DevHtmlAssetVc
,
server
_root
:
FileSystemPathVc
,
server
_path
:
FileSystemPathVc
,
client
_root
:
FileSystemPathVc
,
client
_path
:
FileSystemPathVc
,
is_api_path
:
bool
,
intermediate_output
_path
:
FileSystemPathVc
,
output
_root
:
FileSystemPathVc
,
node
_path
:
FileSystemPathVc
,
node
_root
:
FileSystemPathVc
,
render_data
:
JsonValueVc
,
)
->
Result
<
ContentSourceVc
>
{
let
server_chunking_context
=
DevChunkingContextVc
::
builder
(
project_path
,
intermediate_output
_path
,
intermediate_output
_path
.join
(
"chunks"
),
node
_path
,
node
_path
.join
(
"chunks"
),
get_client_assets_path
(
server
_root
,
client
_root
,
Value
::
new
(
ClientContextType
::
Pages
{
pages_dir
}),
),
server_context
.compile_time_info
()
.environment
(),
...
...
@@ -353,14 +354,14 @@ async fn create_page_source_for_file(
.reference_chunk_source_maps
(
false
)
.build
();
let
data_
intermediate_output_path
=
intermediate_output
_path
.join
(
"data"
);
let
data_
node_path
=
node
_path
.join
(
"data"
);
let
server_data_chunking_context
=
DevChunkingContextVc
::
builder
(
project_path
,
data_
intermediate_output
_path
,
data_
intermediate_output
_path
.join
(
"chunks"
),
data_
node
_path
,
data_
node
_path
.join
(
"chunks"
),
get_client_assets_path
(
server
_root
,
client
_root
,
Value
::
new
(
ClientContextType
::
Pages
{
pages_dir
}),
),
server_context
.compile_time_info
()
.environment
(),
...
...
@@ -370,12 +371,12 @@ async fn create_page_source_for_file(
let
client_chunking_context
=
get_client_chunking_context
(
project_path
,
server
_root
,
client
_root
,
client_context
.compile_time_info
()
.environment
(),
Value
::
new
(
ClientContextType
::
Pages
{
pages_dir
}),
);
let
pathname
=
pathname_for_path
(
server_root
,
server_path
,
true
,
fals
e
);
let
pathname
=
pathname_for_path
(
client_root
,
client_path
,
PathType
::
Pag
e
);
let
route_matcher
=
NextParamsMatcherVc
::
new
(
pathname
);
Ok
(
if
is_api_path
{
...
...
@@ -383,7 +384,7 @@ async fn create_page_source_for_file(
project_path
,
env
,
specificity
,
server
_root
,
client
_root
,
route_matcher
.into
(),
pathname
,
SsrEntry
{
...
...
@@ -392,8 +393,8 @@ async fn create_page_source_for_file(
entry_asset
:
page_asset
,
ty
:
SsrType
::
AutoApi
,
chunking_context
:
server_chunking_context
,
intermediate_output
_path
,
output
_root
,
node
_path
,
node
_root
,
project_path
,
}
.cell
()
...
...
@@ -401,7 +402,7 @@ async fn create_page_source_for_file(
render_data
,
)
}
else
{
let
data_pathname
=
pathname_for_path
(
server_root
,
server_path
,
true
,
true
);
let
data_pathname
=
pathname_for_path
(
client_root
,
client_path
,
PathType
::
Data
);
let
data_route_matcher
=
NextPrefixSuffixParamsMatcherVc
::
new
(
data_pathname
,
"_next/data/development/"
,
".json"
);
...
...
@@ -411,8 +412,8 @@ async fn create_page_source_for_file(
entry_asset
:
page_asset
,
ty
:
SsrType
::
Html
,
chunking_context
:
server_chunking_context
,
intermediate_output
_path
,
output
_root
,
node
_path
,
node
_root
,
project_path
,
}
.cell
()
...
...
@@ -424,8 +425,8 @@ async fn create_page_source_for_file(
entry_asset
:
page_asset
,
ty
:
SsrType
::
Data
,
chunking_context
:
server_data_chunking_context
,
intermediate_output_path
:
data_intermediate_output
_path
,
output
_root
,
node_path
:
data_node
_path
,
node
_root
,
project_path
,
}
.cell
()
...
...
@@ -436,7 +437,7 @@ async fn create_page_source_for_file(
project_path
,
env
,
specificity
,
server
_root
,
client
_root
,
route_matcher
.into
(),
pathname
,
ssr_entry
,
...
...
@@ -447,7 +448,7 @@ async fn create_page_source_for_file(
project_path
,
env
,
specificity
,
server
_root
,
client
_root
,
data_route_matcher
.into
(),
pathname
,
ssr_data_entry
,
...
...
@@ -455,7 +456,7 @@ async fn create_page_source_for_file(
render_data
,
),
create_page_loader
(
server
_root
,
client
_root
,
client_context
,
client_chunking_context
,
page_asset
,
...
...
@@ -491,18 +492,18 @@ async fn create_not_found_page_source(
page_extensions
:
StringsVc
,
runtime_entries
:
AssetsVc
,
fallback_page
:
DevHtmlAssetVc
,
server
_root
:
FileSystemPathVc
,
intermediate_output
_path
:
FileSystemPathVc
,
client
_root
:
FileSystemPathVc
,
node
_path
:
FileSystemPathVc
,
specificity
:
SpecificityVc
,
route_matcher
:
RouteMatcherVc
,
render_data
:
JsonValueVc
,
)
->
Result
<
ContentSourceVc
>
{
let
server_chunking_context
=
DevChunkingContextVc
::
builder
(
project_path
,
intermediate_output
_path
,
intermediate_output
_path
.join
(
"chunks"
),
node
_path
,
node
_path
.join
(
"chunks"
),
get_client_assets_path
(
server
_root
,
client
_root
,
Value
::
new
(
ClientContextType
::
Pages
{
pages_dir
}),
),
server_context
.compile_time_info
()
.environment
(),
...
...
@@ -512,7 +513,7 @@ async fn create_not_found_page_source(
let
client_chunking_context
=
get_client_chunking_context
(
project_path
,
server
_root
,
client
_root
,
client_context
.compile_time_info
()
.environment
(),
Value
::
new
(
ClientContextType
::
Pages
{
pages_dir
}),
);
...
...
@@ -542,15 +543,15 @@ async fn create_not_found_page_source(
entry_asset
,
ty
:
SsrType
::
Html
,
chunking_context
:
server_chunking_context
,
intermediate_output
_path
,
output_root
:
intermediate_output
_path
,
node
_path
,
node_root
:
node
_path
,
project_path
,
}
.cell
()
.into
();
let
page_loader
=
create_page_loader
(
server
_root
,
client
_root
,
client_context
,
client_chunking_context
,
entry_asset
,
...
...
@@ -562,7 +563,7 @@ async fn create_not_found_page_source(
project_path
,
env
,
specificity
,
server
_root
,
client
_root
,
route_matcher
,
pathname
,
ssr_entry
,
...
...
@@ -578,9 +579,9 @@ async fn create_not_found_page_source(
/// Calls itself recursively for sub directories or the
/// [create_page_source_for_file] method for files.
#[turbo_tasks
::
function]
async
fn
create_page_source_for_directory
(
async
fn
create_page_source_for_
root_
directory
(
pages_structure
:
PagesStructureVc
,
project_
path
:
FileSystemPathVc
,
project_
root
:
FileSystemPathVc
,
env
:
ProcessEnvVc
,
server_context
:
AssetContextVc
,
server_data_context
:
AssetContextVc
,
...
...
@@ -588,11 +589,76 @@ async fn create_page_source_for_directory(
pages_dir
:
FileSystemPathVc
,
runtime_entries
:
AssetsVc
,
fallback_page
:
DevHtmlAssetVc
,
server
_root
:
FileSystemPathVc
,
output
_root
:
FileSystemPathVc
,
client
_root
:
FileSystemPathVc
,
node
_root
:
FileSystemPathVc
,
render_data
:
JsonValueVc
,
)
->
Result
<
ContentSourceVc
>
{
let
PagesStructure
{
app
:
_
,
document
:
_
,
error
:
_
,
ref
api
,
ref
pages
,
}
=
*
pages_structure
.await
?
;
let
mut
sources
=
vec!
[];
sources
.push
(
create_page_source_for_directory
(
*
pages
,
project_root
,
env
,
server_context
,
server_data_context
,
client_context
,
pages_dir
,
runtime_entries
,
fallback_page
,
client_root
,
false
,
node_root
,
render_data
,
));
if
let
Some
(
api
)
=
api
{
sources
.push
(
create_page_source_for_directory
(
*
api
,
project_root
,
env
,
server_context
,
server_data_context
,
client_context
,
pages_dir
,
runtime_entries
,
fallback_page
,
client_root
,
true
,
node_root
,
render_data
,
));
}
Ok
(
CombinedContentSource
{
sources
}
.cell
()
.into
())
}
/// Handles a directory in the pages directory (or the pages directory itself).
/// Calls itself recursively for sub directories or the
/// [create_page_source_for_file] method for files.
#[turbo_tasks
::
function]
async
fn
create_page_source_for_directory
(
pages_structure
:
PagesDirectoryStructureVc
,
project_root
:
FileSystemPathVc
,
env
:
ProcessEnvVc
,
server_context
:
AssetContextVc
,
server_data_context
:
AssetContextVc
,
client_context
:
AssetContextVc
,
pages_dir
:
FileSystemPathVc
,
runtime_entries
:
AssetsVc
,
fallback_page
:
DevHtmlAssetVc
,
client_root
:
FileSystemPathVc
,
is_api_path
:
bool
,
node_root
:
FileSystemPathVc
,
render_data
:
JsonValueVc
,
)
->
Result
<
ContentSourceVc
>
{
let
PagesDirectoryStructure
{
ref
items
,
ref
children
,
..
...
...
@@ -600,61 +666,44 @@ async fn create_page_source_for_directory(
let
mut
sources
=
vec!
[];
for
item
in
items
.iter
()
{
let
source
=
match
*
item
.await
?
{
PagesStructureItem
::
Page
{
page
,
specificity
,
url
,
}
=>
create_page_source_for_file
(
project_path
,
env
,
server_context
,
server_data_context
,
client_context
,
pages_dir
,
specificity
,
SourceAssetVc
::
new
(
page
)
.into
(),
runtime_entries
,
fallback_page
,
server_root
,
url
,
false
,
output_root
,
output_root
,
render_data
,
)
.issue_context
(
page
,
"Next.js pages directory"
),
PagesStructureItem
::
Api
{
api
,
specificity
,
url
,
}
=>
create_page_source_for_file
(
project_path
,
env
,
server_context
,
server_data_context
,
client_context
,
pages_dir
,
specificity
,
SourceAssetVc
::
new
(
api
)
.into
(),
runtime_entries
,
fallback_page
,
server_root
,
url
,
true
,
output_root
,
output_root
,
render_data
,
)
.issue_context
(
api
,
"Next.js pages api directory"
),
};
let
PagesStructureItem
{
project_path
,
specificity
,
next_router_path
,
}
=
*
item
.await
?
;
let
source
=
create_page_source_for_file
(
project_root
,
env
,
server_context
,
server_data_context
,
client_context
,
pages_dir
,
specificity
,
SourceAssetVc
::
new
(
project_path
)
.into
(),
runtime_entries
,
fallback_page
,
client_root
,
next_router_path
,
is_api_path
,
node_root
,
node_root
,
render_data
,
)
.issue_context
(
project_path
,
if
is_api_path
{
"Next.js page API file"
}
else
{
"Next.js page file"
},
);
sources
.push
(
source
);
}
for
child
in
children
.iter
()
{
sources
.push
(
create_page_source_for_directory
(
*
child
,
project_
path
,
project_
root
,
env
,
server_context
,
server_data_context
,
...
...
@@ -662,8 +711,9 @@ async fn create_page_source_for_directory(
pages_dir
,
runtime_entries
,
fallback_page
,
server_root
,
output_root
,
client_root
,
is_api_path
,
node_root
,
render_data
,
))
}
...
...
@@ -671,34 +721,34 @@ async fn create_page_source_for_directory(
Ok
(
CombinedContentSource
{
sources
}
.cell
()
.into
())
}
#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
Hash,
Serialize,
Deserialize,
PartialOrd,
Ord,
TraceRawVcs,
)]
enum
SsrType
{
Api
,
EdgeApi
,
AutoApi
,
Html
,
Data
,
}
/// The node.js renderer for SSR of pages.
#[turbo_tasks
::
value]
struct
SsrEntry
{
pub
struct
SsrEntry
{
runtime_entries
:
AssetsVc
,
context
:
AssetContextVc
,
entry_asset
:
AssetVc
,
ty
:
SsrType
,
chunking_context
:
ChunkingContextVc
,
intermediate_output
_path
:
FileSystemPathVc
,
output
_root
:
FileSystemPathVc
,
node
_path
:
FileSystemPathVc
,
node
_root
:
FileSystemPathVc
,
project_path
:
FileSystemPathVc
,
}
#[derive(
Clone,
Copy,
Debug,
Eq,
PartialEq,
Hash,
Serialize,
Deserialize,
PartialOrd,
Ord,
TraceRawVcs,
)]
pub
enum
SsrType
{
Api
,
EdgeApi
,
AutoApi
,
Html
,
Data
,
}
#[turbo_tasks
::
value_impl]
impl
SsrEntryVc
{
#[turbo_tasks
::
function]
async
fn
entry
(
self
)
->
Result
<
NodeRenderingEntryVc
>
{
pub
async
fn
entry
(
self
)
->
Result
<
NodeRenderingEntryVc
>
{
let
this
=
self
.await
?
;
let
entry_asset_page
=
this
.context
.process
(
this
.entry_asset
,
...
...
@@ -784,8 +834,8 @@ impl SsrEntryVc {
InnerAssetsVc
::
cell
(
inner_assets
),
),
chunking_context
:
this
.chunking_context
,
intermediate_output_path
:
this
.
intermediate_output
_path
,
output_root
:
this
.
output
_root
,
intermediate_output_path
:
this
.
node
_path
,
output_root
:
this
.
node
_root
,
project_dir
:
this
.project_path
,
}
.cell
())
...
...
packages/next-swc/crates/next-core/src/pages_structure.rs
View file @
2dade5df
use
anyhow
::
Result
;
use
turbo_tasks
::{
primitives
::{
BoolVc
,
StringsVc
},
CompletionVc
,
};
use
turbo_tasks
::{
primitives
::
StringsVc
,
CompletionVc
};
use
turbopack_binding
::{
turbo
::
tasks_fs
::{
DirectoryContent
,
DirectoryEntry
,
FileSystemEntryType
,
FileSystemPathVc
},
turbopack
::
dev_server
::
source
::
specificity
::
SpecificityVc
,
};
use
crate
::
next_config
::
NextConfigVc
;
use
crate
::
{
embed_js
::
next_js_file_path
,
next_config
::
NextConfigVc
}
;
/// A final route in the pages directory.
#[turbo_tasks
::
value]
pub
enum
PagesStructureItem
{
Page
{
url
:
FileSystemPathVc
,
specificity
:
SpecificityVc
,
page
:
FileSystemPathVc
,
},
Api
{
url
:
FileSystemPathVc
,
specificity
:
SpecificityVc
,
api
:
FileSystemPathVc
,
},
pub
struct
PagesStructureItem
{
pub
project_path
:
FileSystemPathVc
,
pub
next_router_path
:
FileSystemPathVc
,
pub
specificity
:
SpecificityVc
,
}
#[turbo_tasks
::
value_impl]
impl
PagesStructureItemVc
{
#[turbo_tasks
::
function]
async
fn
new
(
url
:
FileSystemPathVc
,
project_path
:
FileSystemPathVc
,
next_router_path
:
FileSystemPathVc
,
specificity
:
SpecificityVc
,
file
:
FileSystemPathVc
,
is_api
:
BoolVc
,
)
->
Result
<
Self
>
{
if
*
is_api
.await
?
{
Ok
(
PagesStructureItem
::
Api
{
url
,
specificity
,
api
:
file
,
}
.cell
())
}
else
{
Ok
(
PagesStructureItem
::
Page
{
url
,
specificity
,
page
:
file
,
}
.cell
())
Ok
(
PagesStructureItem
{
project_path
,
next_router_path
,
specificity
,
}
.cell
())
}
/// Returns a completion that changes when any route in the whole tree
/// changes.
#[turbo_tasks
::
function]
pub
async
fn
routes_changed
(
self
)
->
Result
<
CompletionVc
>
{
match
*
self
.await
?
{
PagesStructureItem
::
Page
{
url
,
..
}
=>
url
.await
?
,
PagesStructureItem
::
Api
{
url
,
..
}
=>
url
.await
?
,
};
let
this
=
self
.await
?
;
this
.next_router_path.await
?
;
Ok
(
CompletionVc
::
new
())
}
}
...
...
@@ -67,29 +45,40 @@ impl PagesStructureItemVc {
/// folders.
#[turbo_tasks
::
value]
pub
struct
PagesStructure
{
pub
directory
:
FileSystemPathVc
,
pub
items
:
Vec
<
PagesStructureItemVc
>
,
pub
children
:
Vec
<
PagesStructureVc
>
,
pub
app
:
PagesStructureItemVc
,
pub
document
:
PagesStructureItemVc
,
pub
error
:
PagesStructureItemVc
,
pub
api
:
Option
<
PagesDirectoryStructureVc
>
,
pub
pages
:
PagesDirectoryStructureVc
,
}
#[turbo_tasks
::
value_impl]
impl
PagesStructureVc
{
/// Returns the directory of this structure.
/// Returns the path to the directory of this structure in the project file
/// system.
#[turbo_tasks
::
function]
pub
async
fn
directory
(
self
)
->
Result
<
FileSystemPathVc
>
{
Ok
(
self
.await
?
.
directory
)
pub
async
fn
project_path
(
self
)
->
Result
<
FileSystemPathVc
>
{
Ok
(
self
.await
?
.
pages
.project_path
()
)
}
/// Returns a completion that changes when any route in the whole tree
/// changes.
#[turbo_tasks
::
function]
pub
async
fn
routes_changed
(
self
)
->
Result
<
CompletionVc
>
{
for
item
in
self
.await
?
.items
.iter
()
{
item
.routes_changed
()
.await
?
;
}
for
child
in
self
.await
?
.children
.iter
()
{
child
.routes_changed
()
.await
?
;
let
PagesStructure
{
ref
app
,
ref
document
,
ref
error
,
ref
api
,
ref
pages
,
}
=
&*
self
.await
?
;
app
.routes_changed
()
.await
?
;
document
.routes_changed
()
.await
?
;
error
.routes_changed
()
.await
?
;
if
let
Some
(
api
)
=
api
{
api
.routes_changed
()
.await
?
;
}
pages
.routes_changed
()
.await
?
;
Ok
(
CompletionVc
::
new
())
}
}
...
...
@@ -108,47 +97,205 @@ impl OptionPagesStructureVc {
}
}
#[turbo_tasks
::
value]
pub
struct
PagesDirectoryStructure
{
pub
project_path
:
FileSystemPathVc
,
pub
next_router_path
:
FileSystemPathVc
,
pub
items
:
Vec
<
PagesStructureItemVc
>
,
pub
children
:
Vec
<
PagesDirectoryStructureVc
>
,
}
#[turbo_tasks
::
value_impl]
impl
PagesDirectoryStructureVc
{
/// Returns the path to the directory of this structure in the project file
/// system.
#[turbo_tasks
::
function]
pub
async
fn
project_path
(
self
)
->
Result
<
FileSystemPathVc
>
{
Ok
(
self
.await
?
.project_path
)
}
/// Returns a completion that changes when any route in the whole tree
/// changes.
#[turbo_tasks
::
function]
pub
async
fn
routes_changed
(
self
)
->
Result
<
CompletionVc
>
{
for
item
in
self
.await
?
.items
.iter
()
{
item
.routes_changed
()
.await
?
;
}
for
child
in
self
.await
?
.children
.iter
()
{
child
.routes_changed
()
.await
?
;
}
Ok
(
CompletionVc
::
new
())
}
}
/// Finds and returns the [PagesStructure] of the pages directory if existing.
#[turbo_tasks
::
function]
pub
async
fn
find_pages_structure
(
project_
path
:
FileSystemPathVc
,
serv
er_root
:
FileSystemPathVc
,
project_
root
:
FileSystemPathVc
,
next_rout
er_root
:
FileSystemPathVc
,
next_config
:
NextConfigVc
,
)
->
Result
<
OptionPagesStructureVc
>
{
let
pages
=
project_path
.join
(
"pages"
);
let
src_pages
=
project_path
.join
(
"src/pages"
);
let
pages_dir
=
if
*
pages
.get_type
()
.await
?
==
FileSystemEntryType
::
Directory
{
pages
}
else
if
*
src_pages
.get_type
()
.await
?
==
FileSystemEntryType
::
Directory
{
src_pages
let
pages_root
=
project_root
.join
(
"pages"
);
let
pages_root
=
if
*
pages_root
.get_type
()
.await
?
==
FileSystemEntryType
::
Directory
{
pages_root
}
else
{
return
Ok
(
OptionPagesStructureVc
::
cell
(
None
));
let
src_pages_root
=
project_root
.join
(
"src/pages"
);
if
*
src_pages_root
.get_type
()
.await
?
==
FileSystemEntryType
::
Directory
{
src_pages_root
}
else
{
return
Ok
(
OptionPagesStructureVc
::
cell
(
None
));
}
}
.resolve
()
.await
?
;
Ok
(
OptionPagesStructureVc
::
cell
(
Some
(
get_pages_structure
(
pages_dir
,
server_root
,
next_config
.page_extensions
(),
))))
Ok
(
OptionPagesStructureVc
::
cell
(
Some
(
get_pages_structure_for_root_directory
(
pages_root
,
next_router_root
,
next_config
.page_extensions
(),
),
)))
}
///
Parses a directory as pages directory and returns the [PagesStructure]
.
///
Handles the root pages directory
.
#[turbo_tasks
::
function]
pub
fn
get_pages_structure
(
p
ages_dir
:
FileSystemPathVc
,
server_root
:
FileSystemPathVc
,
async
fn
get_pages_structure_for_root_directory
(
p
roject_path
:
FileSystemPathVc
,
next_router_path
:
FileSystemPathVc
,
page_extensions
:
StringsVc
,
)
->
PagesStructureVc
{
get_pages_structure_for_directory
(
pages_dir
,
SpecificityVc
::
exact
(),
0
,
server_root
,
server_root
.join
(
"api"
),
page_extensions
,
)
)
->
Result
<
PagesStructureVc
>
{
let
page_extensions_raw
=
&*
page_extensions
.await
?
;
let
mut
children
=
vec!
[];
let
mut
items
=
vec!
[];
let
mut
app_item
=
None
;
let
mut
document_item
=
None
;
let
mut
error_item
=
None
;
let
mut
api_directory
=
None
;
let
specificity
=
SpecificityVc
::
exact
();
let
dir_content
=
project_path
.read_dir
()
.await
?
;
if
let
DirectoryContent
::
Entries
(
entries
)
=
&*
dir_content
{
for
(
name
,
entry
)
in
entries
.iter
()
{
match
entry
{
DirectoryEntry
::
File
(
file_project_path
)
=>
{
let
Some
(
basename
)
=
page_basename
(
name
,
page_extensions_raw
)
else
{
continue
;
};
match
basename
{
"_app"
=>
{
let
_
=
app_item
.insert
(
PagesStructureItemVc
::
new
(
*
file_project_path
,
next_router_path
.join
(
"_app"
),
specificity
,
));
}
"_document"
=>
{
let
_
=
document_item
.insert
(
PagesStructureItemVc
::
new
(
*
file_project_path
,
next_router_path
.join
(
"_document"
),
specificity
,
));
}
"_error"
=>
{
let
_
=
error_item
.insert
(
PagesStructureItemVc
::
new
(
*
file_project_path
,
next_router_path
.join
(
"_error"
),
specificity
,
));
}
basename
=>
{
let
specificity
=
entry_specificity
(
specificity
,
name
,
0
);
let
next_router_path
=
next_router_path_for_basename
(
next_router_path
,
basename
);
items
.push
((
basename
,
PagesStructureItemVc
::
new
(
*
file_project_path
,
next_router_path
,
specificity
,
),
));
}
}
}
DirectoryEntry
::
Directory
(
dir_project_path
)
=>
match
name
.as_ref
()
{
"api"
=>
{
let
_
=
api_directory
.insert
(
get_pages_structure_for_directory
(
*
dir_project_path
,
next_router_path
.join
(
name
),
specificity
,
1
,
page_extensions
,
));
}
_
=>
{
let
specificity
=
entry_specificity
(
SpecificityVc
::
exact
(),
name
,
0
);
children
.push
((
name
,
get_pages_structure_for_directory
(
*
dir_project_path
,
next_router_path
.join
(
name
),
specificity
,
1
,
page_extensions
,
),
));
}
},
_
=>
{}
}
}
}
// Ensure deterministic order since read_dir is not deterministic
items
.sort_by_key
(|(
k
,
_
)|
*
k
);
children
.sort_by_key
(|(
k
,
_
)|
*
k
);
let
app_item
=
if
let
Some
(
app_item
)
=
app_item
{
app_item
}
else
{
PagesStructureItemVc
::
new
(
next_js_file_path
(
"entry/pages/_app.tsx"
),
next_router_path
.join
(
"_app"
),
specificity
,
)
};
let
document_item
=
if
let
Some
(
document_item
)
=
document_item
{
document_item
}
else
{
PagesStructureItemVc
::
new
(
next_js_file_path
(
"entry/pages/_document.tsx"
),
next_router_path
.join
(
"_document"
),
specificity
,
)
};
let
error_item
=
if
let
Some
(
error_item
)
=
error_item
{
error_item
}
else
{
PagesStructureItemVc
::
new
(
next_js_file_path
(
"entry/pages/_error.tsx"
),
next_router_path
.join
(
"_error"
),
specificity
,
)
};
Ok
(
PagesStructure
{
app
:
app_item
,
document
:
document_item
,
error
:
error_item
,
api
:
api_directory
,
pages
:
PagesDirectoryStructure
{
project_path
,
next_router_path
,
items
:
items
.into_iter
()
.map
(|(
_
,
v
)|
v
)
.collect
(),
children
:
children
.into_iter
()
.map
(|(
_
,
v
)|
v
)
.collect
(),
}
.cell
(),
}
.cell
())
}
/// Handles a directory in the pages directory (or the pages directory itself).
...
...
@@ -156,60 +303,46 @@ pub fn get_pages_structure(
/// [create_page_source_for_file] method for files.
#[turbo_tasks
::
function]
async
fn
get_pages_structure_for_directory
(
input_dir
:
FileSystemPathVc
,
project_path
:
FileSystemPathVc
,
next_router_path
:
FileSystemPathVc
,
specificity
:
SpecificityVc
,
position
:
u32
,
url
:
FileSystemPathVc
,
server_api_path
:
FileSystemPathVc
,
page_extensions
:
StringsVc
,
)
->
Result
<
PagesStructureVc
>
{
)
->
Result
<
Pages
Directory
StructureVc
>
{
let
page_extensions_raw
=
&*
page_extensions
.await
?
;
let
mut
children
=
vec!
[];
let
mut
items
=
vec!
[];
let
dir_content
=
input_dir
.read_dir
()
.await
?
;
let
dir_content
=
project_path
.read_dir
()
.await
?
;
if
let
DirectoryContent
::
Entries
(
entries
)
=
&*
dir_content
{
for
(
name
,
entry
)
in
entries
.iter
()
{
let
specificity
=
if
name
.starts_with
(
"[["
)
||
name
.starts_with
(
"[..."
)
{
specificity
.with_catch_all
(
position
)
}
else
if
name
.starts_with
(
'['
)
{
specificity
.with_dynamic_segment
(
position
)
}
else
{
specificity
};
let
specificity
=
entry_specificity
(
specificity
,
name
,
position
);
match
entry
{
DirectoryEntry
::
File
(
file
)
=>
{
if
let
Some
((
basename
,
extension
))
=
name
.rsplit_once
(
'.'
)
{
if
page_extensions_raw
.iter
()
.any
(|
allowed
|
allowed
==
extension
)
{
let
url
=
if
basename
==
"index"
{
url
.join
(
"index.html"
)
}
else
{
url
.join
(
basename
)
.join
(
"index.html"
)
};
items
.push
((
name
,
PagesStructureItemVc
::
new
(
url
,
specificity
,
*
file
,
url
.is_inside
(
server_api_path
),
),
))
}
}
DirectoryEntry
::
File
(
file_project_path
)
=>
{
let
Some
(
basename
)
=
page_basename
(
name
,
page_extensions_raw
)
else
{
continue
;
};
let
next_router_path
=
match
basename
{
"index"
=>
next_router_path
,
_
=>
next_router_path
.join
(
basename
),
};
items
.push
((
basename
,
PagesStructureItemVc
::
new
(
*
file_project_path
,
next_router_path
,
specificity
,
),
));
}
DirectoryEntry
::
Directory
(
dir
)
=>
{
DirectoryEntry
::
Directory
(
dir
_project_path
)
=>
{
children
.push
((
name
,
get_pages_structure_for_directory
(
*
dir
,
*
dir_project_path
,
next_router_path
.join
(
name
),
specificity
,
position
+
1
,
url
.join
(
name
),
server_api_path
,
page_extensions
,
),
));
...
...
@@ -225,10 +358,41 @@ async fn get_pages_structure_for_directory(
// Ensure deterministic order since read_dir is not deterministic
children
.sort_by_key
(|(
k
,
_
)|
*
k
);
Ok
(
PagesStructure
{
directory
:
input_dir
,
Ok
(
PagesDirectoryStructure
{
project_path
,
next_router_path
,
items
:
items
.into_iter
()
.map
(|(
_
,
v
)|
v
)
.collect
(),
children
:
children
.into_iter
()
.map
(|(
_
,
v
)|
v
)
.collect
(),
}
.cell
())
}
fn
entry_specificity
(
specificity
:
SpecificityVc
,
name
:
&
str
,
position
:
u32
)
->
SpecificityVc
{
if
name
.starts_with
(
"[["
)
||
name
.starts_with
(
"[..."
)
{
specificity
.with_catch_all
(
position
)
}
else
if
name
.starts_with
(
'['
)
{
specificity
.with_dynamic_segment
(
position
)
}
else
{
specificity
}
}
fn
page_basename
<
'a
>
(
name
:
&
'a
str
,
page_extensions
:
&
'a
[
String
])
->
Option
<&
'a
str
>
{
if
let
Some
((
basename
,
extension
))
=
name
.rsplit_once
(
'.'
)
{
if
page_extensions
.iter
()
.any
(|
allowed
|
allowed
==
extension
)
{
return
Some
(
basename
);
}
}
None
}
fn
next_router_path_for_basename
(
next_router_path
:
FileSystemPathVc
,
basename
:
&
str
,
)
->
FileSystemPathVc
{
if
basename
==
"index"
{
next_router_path
}
else
{
next_router_path
.join
(
basename
)
}
}
packages/next-swc/crates/next-core/src/util.rs
View file @
2dade5df
use
anyhow
::{
anyhow
,
bail
,
Context
,
Result
};
use
anyhow
::{
bail
,
Context
,
Result
};
use
serde
::{
de
::
DeserializeOwned
,
Deserialize
,
Serialize
};
use
swc_core
::
ecma
::
ast
::
Program
;
use
turbo_tasks
::{
primitives
::{
JsonValue
,
JsonValueVc
,
StringVc
},
trace
::
TraceRawVcs
,
Value
,
ValueToString
,
TaskInput
,
Value
,
ValueToString
,
};
use
turbopack_binding
::{
turbo
::
tasks_fs
::{
json
::
parse_json_rope_with_source_context
,
FileContent
,
FileSystemPathVc
},
...
...
@@ -30,13 +30,18 @@ use turbopack_binding::{
use
crate
::
next_config
::{
NextConfigVc
,
OutputType
};
#[derive(Debug,
Clone,
Copy,
PartialEq,
Eq,
TaskInput)]
pub
enum
PathType
{
Page
,
Data
,
}
/// Converts a filename within the server root into a next pathname.
#[turbo_tasks
::
function]
pub
async
fn
pathname_for_path
(
server_root
:
FileSystemPathVc
,
server_path
:
FileSystemPathVc
,
has_extension
:
bool
,
data
:
bool
,
path_ty
:
PathType
,
)
->
Result
<
StringVc
>
{
let
server_path_value
=
&*
server_path
.await
?
;
let
path
=
if
let
Some
(
path
)
=
server_root
.await
?
.get_path_to
(
server_path_value
)
{
...
...
@@ -48,19 +53,12 @@ pub async fn pathname_for_path(
server_root
.to_string
()
.await
?
)
};
let
path
=
if
has_extension
{
path
.rsplit_once
(
'.'
)
.ok_or_else
(||
anyhow!
(
"path ({}) has no extension"
,
path
))
?
.
0
}
else
{
path
};
// `get_path_to` always strips the leading `/` from the path, so we need to add
// it back here.
let
path
=
if
path
==
"index"
&&
!
data
{
"/"
.to_string
()
}
else
{
format!
(
"/{}"
,
path
.strip_suffix
(
"/index"
)
.unwrap_or
(
path
))
let
path
=
match
(
path_ty
,
path
)
{
// "/" is special-cased to "/index" for data routes.
(
PathType
::
Data
,
""
)
=>
"/index"
.to_string
(),
// `get_path_to` always strips the leading `/` from the path, so we need to add
// it back here.
(
_
,
path
)
=>
format!
(
"/{}"
,
path
),
};
Ok
(
StringVc
::
cell
(
path
))
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/error/ssr/issues/Error during SSR Rendering-
d2fc42
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/error/ssr/issues/Error during SSR Rendering-
bd7c95
.txt
View file @
2dade5df
...
...
@@ -14,7 +14,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/error/ssr/input/pages/broken.tsx",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
PlainIssueProcessingPathItem {
context: Some(
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/externals/cjs-in-esm/issues/Error resolving commonjs request-
fd542c
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/externals/cjs-in-esm/issues/Error resolving commonjs request-
d9f9d2
.txt
View file @
2dade5df
...
...
@@ -28,7 +28,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/externals/cjs-in-esm/input/pages/index.js",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
PlainIssueProcessingPathItem {
context: Some(
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/externals/cjs-in-esm/issues/Error resolving commonjs request-
cbe6d3
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/externals/cjs-in-esm/issues/Error resolving commonjs request-
ffa54f
.txt
View file @
2dade5df
...
...
@@ -28,7 +28,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/externals/cjs-in-esm/input/pages/index.js",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
],
),
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/issues/Processing image failed-
b830ce
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/issues/Processing image failed-
303117
.txt
View file @
2dade5df
...
...
@@ -14,7 +14,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/image/basic/input/pages/index.js",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
PlainIssueProcessingPathItem {
context: Some(
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/issues/Processing image failed-
a6d637
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/issues/Processing image failed-
b11d72
.txt
View file @
2dade5df
...
...
@@ -14,7 +14,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/image/basic/input/pages/index.js",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
PlainIssueProcessingPathItem {
context: Some(
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/issues/Processing image failed-
0d0c2f
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/issues/Processing image failed-
eed147
.txt
View file @
2dade5df
...
...
@@ -14,7 +14,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/image/basic/input/pages/index.js",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
],
),
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/issues/Processing image failed-
61980
7.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/image/basic/issues/Processing image failed-
ff12d
7.txt
View file @
2dade5df
...
...
@@ -14,7 +14,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/image/basic/input/pages/index.js",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
],
),
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/image/remotepattern/issues/Error during SSR Rendering-
722379
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/image/remotepattern/issues/Error during SSR Rendering-
d9114a
.txt
View file @
2dade5df
...
...
@@ -14,7 +14,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/image/remotepattern/input/pages/invalid.js",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
PlainIssueProcessingPathItem {
context: Some(
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1004 fs.existsSync(__q____q____q____star__0-
b67339
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1004 fs.existsSync(__q____q____q____star__0-
55e40b
.txt
View file @
2dade5df
...
...
@@ -28,7 +28,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/tailwind/basic/input/pages/index.jsx",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
PlainIssueProcessingPathItem {
context: Some(
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1004 fs.existsSync(__q____q____q____star__0-
959d9c
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1004 fs.existsSync(__q____q____q____star__0-
bbe67b
.txt
View file @
2dade5df
...
...
@@ -28,7 +28,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/tailwind/basic/input/pages/index.jsx",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
PlainIssueProcessingPathItem {
context: Some(
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-
a586a8
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-
50ea93
.txt
View file @
2dade5df
...
...
@@ -28,7 +28,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/tailwind/basic/input/pages/index.jsx",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
PlainIssueProcessingPathItem {
context: Some(
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-
4e191f
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1004 fs.readFileSync(__q____q____q____star_-
a3cd71
.txt
View file @
2dade5df
...
...
@@ -28,7 +28,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/tailwind/basic/input/pages/index.jsx",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
PlainIssueProcessingPathItem {
context: Some(
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1006 path.resolve(__q____q____q____star__0_-
3436e6
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1006 path.resolve(__q____q____q____star__0_-
820338
.txt
View file @
2dade5df
...
...
@@ -28,7 +28,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/tailwind/basic/input/pages/index.jsx",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
PlainIssueProcessingPathItem {
context: Some(
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1006 path.resolve(__q____q____q____star__0_-
4327d0
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/tailwind/basic/issues/lint TP1006 path.resolve(__q____q____q____star__0_-
c23a56
.txt
View file @
2dade5df
...
...
@@ -28,7 +28,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/tailwind/basic/input/pages/index.jsx",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
PlainIssueProcessingPathItem {
context: Some(
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-
d52110
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-
014f3c
.txt
View file @
2dade5df
...
...
@@ -14,7 +14,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/webpack-loaders/emitted-errors/input/pages/index.js",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
PlainIssueProcessingPathItem {
context: Some(
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-
91e4b0
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-
2ea486
.txt
View file @
2dade5df
...
...
@@ -14,7 +14,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/webpack-loaders/emitted-errors/input/pages/index.js",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
PlainIssueProcessingPathItem {
context: Some(
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-
b0b175
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-
30bad6
.txt
View file @
2dade5df
...
...
@@ -14,7 +14,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/webpack-loaders/emitted-errors/input/pages/index.js",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
],
),
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-
49d9f1
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-
8d8b58
.txt
View file @
2dade5df
...
...
@@ -14,7 +14,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/webpack-loaders/emitted-errors/input/pages/index.js",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
PlainIssueProcessingPathItem {
context: Some(
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-9
0abbe
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-9
b6240
.txt
View file @
2dade5df
...
...
@@ -14,7 +14,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/webpack-loaders/emitted-errors/input/pages/index.js",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
],
),
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-
61e11d
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-
d6914f
.txt
View file @
2dade5df
...
...
@@ -14,7 +14,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/webpack-loaders/emitted-errors/input/pages/index.js",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
PlainIssueProcessingPathItem {
context: Some(
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-
c8b8c0
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-
d779f3
.txt
View file @
2dade5df
...
...
@@ -14,7 +14,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/webpack-loaders/emitted-errors/input/pages/index.js",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
],
),
...
...
packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-f
ce34e
.txt
→
packages/next-swc/crates/next-dev-tests/tests/integration/next/webpack-loaders/emitted-errors/issues/Issue while running loader-f
a8e05
.txt
View file @
2dade5df
...
...
@@ -14,7 +14,7 @@ PlainIssue {
context: Some(
"[project]/packages/next-swc/crates/next-dev-tests/tests/temp/next/webpack-loaders/emitted-errors/input/pages/index.js",
),
description: "Next.js page
s directory
",
description: "Next.js page
file
",
},
],
),
...
...
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