4 ms·
It’s interesting. I always go back and forth on this pattern. It makes sense to me logically, but where do you put your shared utils and such?
by pixelready 2y ago
It’s interesting. I always go back and forth on this pattern. It makes sense to me logically, but where do you put your shared utils and such?
- langarus 2y agoIn a commons folder?
- moritzwarhier 2y agoWhy not both? Move your pure function utilities to a feature-agnostic folder whenever it makes sense, and import them into your feature. I agree that's where the problems begin though :)
- tracker1 2y agofeature/shared/utils/foo.ts feature/shared/utils/format-date.ts feature/shared/ux/(template|region|etc)/foo.ts Where ux are for components that may be referenced in multiple areas, or generic templates, etc. and shared are for utility methods, functions, etc.
- whalesalad 2y agoI think the op is asking more on if a util is used across many features
- garrettgrimsley 2y agotracker1 is saying that in that case there would be a feature named shared, which other features then reference.
- tracker1 2y agoyes... though, unlike above, I might be inclined to name the directory "!shared" to pump sorting to the top, which may feel weird/awkward.
- diegoholiveira 2y agoIMO, shared utils must be a library, like: features auth login libraries dates strings ... I don't like to have a package / library called `utils`, `commons`, `shared` and other generic words that does not indicate me what's the context of this folder.
- tracker1 2y agoCool, may start using that over shared, but may just use "!lib" I tend to use "!" in the beginning of directories I want elevated... in any case, thanks.