Skip to content

Utility/Includes patterns #40

@kaisermann

Description

@kaisermann

Is your feature request related to a problem? Please describe.

We should have a recommended way of organizing includes/utilities in our projects. I've seen some variations of:

  • A utils directory with a single index.ts file (doesn't make sense to me at all)
  • A modules/includes/utils directory with separate files with default exports

Describe the solution you'd like

I'd like to have a recommended way of adding utilities to a project. Personally I dislike creating a lot of folder structure with complex names, so I usually prefer a includes/modules directory with a file for each utility context or for each method. I also dislike having them exported as default since the name can be easily changed wherever they're imported.

Example:

src/runtime/
├── includes/
│   ├── flatObj.ts
│   ├── formatters.ts
│   ├── getClientLocale.ts
│   ├── loaderQueue.ts
│   ├── lookup.ts
│   └── memoize.ts

Or

src/runtime/
├── modules/
│   ├── flatObj.ts
│   ├── formatters.ts
│   ├── getClientLocale.ts
│   ├── loaderQueue.ts
│   ├── lookup.ts
│   └── memoize.ts

Describe alternatives you've considered

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions