RFC - New src
folder structure "module oriented"
#183
-
There had been a few feedbacks regarding the folder structure of the The goal is to regroup code that is related to each other into modules, represented as an unified folder. Currently, the code is cluttered between "components", "utils" and "types" folders Current structure:New structure - Proposal 1:
Store everything that is common across pages or too wide to belong into a dedicated module into a
New structure - Proposal 2:
Similar to "Proposal 1", but this time everything is under Similarly, we could have "modules", "common" and "pages" under
New structure - Proposal 3:
Similar to "Proposal 2", but this time "modules", "common" and "pages" under
What are your thoughts on this? My personal preference goes for "Proposal 3". |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 61 replies
-
@jajourda @sovattha @samuelcastro @Demmonius Do you have any preference about this? |
Beta Was this translation helpful? Give feedback.
-
Definitely Proposal 3, this is what I'm using, although I put everything under I proposed something similar before: #44 |
Beta Was this translation helpful? Give feedback.
-
Work has started on #264 @sovattha @samuelcastro Could you review and give your feedback? Does it look like what you expected? I'm also considering using https://nextjs.org/docs/advanced-features/module-path-aliases It would be more resilient to moving files around, by not creating conflicts within the file itself. And it'd avoid breaking paths when moving files around (as it happened to me a lot today, had to fix those manually afterwards) I've never used module path aliasing, do you think it's a good idea to integrate it now? Would it make the upgrade smoother for you? |
Beta Was this translation helpful? Give feedback.
-
I'm thinking about splitting the block (layout, pageContainer, footer, nav, head) components as some kind of "front-office" module. My reasoning is that it'd be easier to add a "back-office" module with its own layout, footer, etc. components. So far, I've considered all those files to be "default" (DefaultLayout, DefaultPageContainer, etc.) but maybe it'd make more sense to modularize them too. Also, it'd make simpler adding another "admin" or "backOffice" module that'd hide behind some kind of authentication, in the future. I've done something similar with the "NRN examples" (renamed "demo") moved to a "demo" module, with its own components, and "demoSSG/demoSSR" used by "pages/[locale]/demo". I'm wondering what you think of that, and also what'd be a good default naming. I'd like a name that means "publicly visible part of the site", unlike the "admin" which would be behind auth. I'm thinking of stuff like:
|
Beta Was this translation helpful? Give feedback.
-
@samuelcastro I migrated the Everything looks good to me. I found a few things I had missed, which were fixed directly in the above PR for |
Beta Was this translation helpful? Give feedback.
-
Okay, so I managed to merge all those changes into our private NRN fork. We got about 100-150 conflicts, lots of things can be easily solved because they're about /demo. (about half of the conflicts)
Had about 500 modified files in total. Good luck 😄 |
Beta Was this translation helpful? Give feedback.
Work has started on #264
@sovattha @samuelcastro Could you review and give your feedback? Does it look like what you expected?
I'm also considering using
@
when loading paths. E.g:import Button from '@/components/button'
https://nextjs.org/docs/advanced-features/module-path-aliases
It would be more resilient to moving files around, by not creating conflicts within the file itself. And it'd avoid breaking paths when moving files around (as it happened to me a lot today, had to fix those manually afterwards)
I've never used module path aliasing, do you think it's a good idea to integrate it now? Would it make the upgrade smoother for you?