-
Notifications
You must be signed in to change notification settings - Fork 27k
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
The build assumes that all js files under /pages is a page #3183
Comments
I think you can move non-page components to another top-level folder and only keep page file under |
Yes, but I think having components (and other js files) under their respective |
@emattias This is the limitation that next.js currently has. but I think we can alway work around it. what about the following structure?
also I think Convention Over Configuration is the one of the goals of next.js |
#1914 is related. It's marked closed but it's still active. |
Yup, this issue prevents us from using a folders-by-feature organization, which would be more scalable than the folders-by-type organization that is being imposed on us |
@zenflow I think a page is not always a feature, I mean a single page could have more than one feature of your app at the same time.
So pages aren't features. You could use something like:
|
@sergiodxa I agree they aren't always but when you have components that are only used in that page it made it clearer with the structure I described initially. What about making the glob overridable? |
@emattias Configurable Make all The idea of @arunoda Could we get your thoughts? |
For clarification This is the folder structure we want to avoid, especially if it is to scale to have more than 3 pages in a hierarchy more than 1 deep:
This would be more maintainable at scale, since we don't duplicate the (root->(chat, timeline)) structure for each file type:
(edit: components/ and helpers/ can and should have their own __tests__/) |
@emattias Would my proposal fit your use case? |
@zenflow I dont want to have to structure pages folders differently than other domains in our project. There there is no need for a lib/ sub folder for example. What if instead of excluding everything that is not a page, we have a convention where you can help the build script identify pages. For example with a filename suffix of .page.js |
Files inside of Also consider that What is the harm in structuring the pages folders differently than other domains? Perhaps you could bring this convention to those other domains? E.g. if you have a Do you think my proposal could satisfy your use case? |
@liweinan0423 Would love to hear your thoughts on this! |
This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread. |
We have structured our files so that page specific code is in the pages folder. Here is an example:
The index.js file has the ManageUsersPage.js components as its default export. That is a regular next.js page component
This structure has worked fine for us except when we build. This hardcoded glob assumes that all js files under pages is a page: https://github.com/zeit/next.js/blob/canary/server/build/webpack.js#L50
Does it make sense to make this glob overridable or do we have to not use file based routing?
The text was updated successfully, but these errors were encountered: