Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Treat non page file as non route under app dir (#39976)
## Bug Adding a components folder inside a catch-all page triggers the error: "Catch-all must be the last part of the URL", having the component outside works, for example `app/[...slug]/components/*.tsx` fails but `app/components/*.tsx` works as expected. ### Fix The reason it errors because they're treated as route and inserted into the url node tree where they shouldn't be treated in this way. Adding a helper to skip collecting and normailizing every file as route for app dir, but only do it for page files Co-authored-by: JJ Kasper <jj@jjsweb.site>
- Loading branch information
Showing
6 changed files
with
46 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
test/e2e/app-dir/app/app/catch-all/[...slug]/components/widget.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// components under catch-all should not throw errors | ||
export default () => <p id="widget">widget</p> |
11 changes: 8 additions & 3 deletions
11
test/e2e/app-dir/app/app/catch-all/[...slug]/page.server.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
import Widget from './components/widget' | ||
|
||
export function getServerSideProps({ params }) { | ||
return { props: { params } } | ||
} | ||
|
||
export default function Page({ params }) { | ||
return ( | ||
<h1 id="text" data-params={params.slug.join('/') ?? ''}> | ||
hello from /catch-all/{params.slug.join('/')} | ||
</h1> | ||
<> | ||
<h1 id="text" data-params={params.slug.join('/') ?? ''}> | ||
hello from /catch-all/{params.slug.join('/')} | ||
</h1> | ||
<Widget /> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters