seperate components and convert to monorepo #17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Monorepo setup.
This makes no functional or pattern changes, it just separates the code into 2 sub-modules. @srcl/ui is a presentational react component library, optimized for modern code splitting. www-sacred is an "as-untouched-as-possible" implementation of the demo site.
www-sacred
still runs nextjs, and consumes reusable components from @srcl/ui
Here's what moved:
/components > @srcl/ui
/hooks > @srcl/ui/hooks
/common/modules > @srcl/ui/modules
/common/utilities > @srcl/ui/utilites
/common/position was consolidated into @srcl/ui/utilites
moved ModalProvider to @srcl/ui/context
What stayed:
constants, queries.ts, server.ts stayed in /common
/app, /examples, /page, /pages, /public, /svg
@srcl/ui Overview
A big bucket of beautiful components. overall pretty simple. The folder structure is setup in this way to take advantage of tsdown's auto-generated exports in a clean way. This matches pretty well with the previous style of all the files in the folder side by side, now it just have nested folders with index.ts files. This is how we get the clean @srcl/ui/Accordion, @srcl/ui/hooks, etc. without manually updating the package.json.
No barrel files = no user footguns
I have found that people very often don't understand why their bundle's dependencies are so large. And it can often be due to npm pulling in every last component attached to a barrel file. The bit of extra boilerplate this causes is minor to me.
tsdown
Pros:
Cons:
Alternative to monorepo
This would definitely make this PR less colossal.
Just make 2 repos, and do local development using npm link. This is mostly fine. Except that react this has this frustrating issue with hooks and link that requires you to link the consuming library to the site's node_modules/react, adding some complexity. Could be worth considering not exporting hooks at all if seperate repos are preferred.