Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turbopack build: Exclude .d.ts files as routes #67744

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/next-swc/crates/next-core/src/app_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,10 @@ async fn get_directory_tree_internal(
match *entry {
DirectoryEntry::File(file) => {
let file = file.resolve().await?;
// Do not process .d.ts files as routes
if basename.ends_with(".d.ts") {
continue;
}
if let Some((stem, ext)) = basename.split_once('.') {
if page_extensions_value.iter().any(|e| e == ext) {
match stem {
Expand Down
4 changes: 4 additions & 0 deletions packages/next-swc/crates/next-core/src/pages_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ async fn get_pages_structure_for_root_directory(
for (name, entry) in entries.iter() {
match entry {
DirectoryEntry::File(file_project_path) => {
// Do not process .d.ts files as routes
if name.ends_with(".d.ts") {
continue;
}
let Some(basename) = page_basename(name, page_extensions_raw) else {
continue;
};
Expand Down
5 changes: 2 additions & 3 deletions test/turbopack-build-tests-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6251,9 +6251,7 @@
"404 Page Support development mode 2 does not show error with getStaticProps in pages/404 dev",
"404 Page Support development mode 2 falls back to _error correctly without pages/404",
"404 Page Support development mode 2 shows error with getInitialProps in pages/404 dev",
"404 Page Support development mode 2 shows error with getServerSideProps in pages/404 dev"
],
"failed": [
"404 Page Support development mode 2 shows error with getServerSideProps in pages/404 dev",
"404 Page Support production mode does not show error with getStaticProps in pages/404 build",
"404 Page Support production mode should add /404 to pages-manifest correctly",
"404 Page Support production mode should not cache for custom 404 page with gssp and revalidate disabled",
Expand All @@ -6268,6 +6266,7 @@
"404 Page Support production mode shows error with getInitialProps in pages/404 build",
"404 Page Support production mode shows error with getServerSideProps in pages/404 build"
],
"failed": [],
"pending": [
"404 Page Support development mode should not error when visited directly",
"404 Page Support development mode should render _error for a 500 error still",
Expand Down
Loading