Directly export all components in next.js code as Component.tsx files #1554
Labels
area: front-end
area: nextjs
Nextjs related issues
developer experience
Helping the Developer Experience
type: enhancement
New feature or request
Milestone
Our current Gastby code uses a component file layout like this:
I want to move toward this:
Some history and thoughts on the various approaches to this:
.js
for a file that isn't standard JavaScript (or.ts
for TypeScript).import Foo from './foo'
without any extension, and let the module system figure it out at build- vs. run-time.I think that another reason we used the
index.js
approach to do the final export was that we also wanted to put CSS files in the same scope:Later, we moved to Material UI, and with it, CSS-in-JS. Next.js doesn't really like global CSS anyway (they either want you to use CSS Modules or CSS-in-JS).
In summary, I think we can ditch the
index.js
export files completely. If we follow the patterns in the next.js TypeScript example, in this PR I would suggest we do this:src/frontend/next/src/components/BackToTopButton/BackToTopButton.tsx
becomessrc/frontend/next/src/components/BackToTopButton.tsx
(i.e., drop the directory and usetsx
).Let's do this for all of our next.js code once it's in. If you're reviewing new code, you can ask the author to do it now, or leave it and we'll do it all at once later.
The text was updated successfully, but these errors were encountered: