Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: experimental support for splitting code by tags / route segments #134

Merged
merged 16 commits into from
Mar 3, 2024

Conversation

mnahkies
Copy link
Owner

@mnahkies mnahkies commented Mar 2, 2024

introduces a new experimental option --grouping-strategy used by the typescript-koa
template to split the routes into separate files, based on either their first tag or route segment.

includes a lot of refactoring to support this:

  • ImportBuilder now supports relative paths in different directories
  • TypeBuilder / SchemaBuilder now gets an ImportBuilder scoped to the collection of routes being built for a given output file
  • Logic around generating the raw file content for output is now consolidated, and supports merging separate units together prior
  • Improved the unit tests for JoiSchemaBuilder and fixed a few bugs in the process
  • Fixed the lint-staged command for eslint
  • Replaced the jest reporter with one that's a bit quieter (still not perfect)

there's still quite a bit of impedance mismatch that makes outputting in different ways like this more
challenging than it would ideally be, mainly that we go straight from IRModel -> string and quickly
loose context of that string (eg: what imports it depends on, where it is used)

eventually we'll probably need to introduce some wrapping object, similar to the CompilationUnit
introduced in this change that can track interesting things and allow us to be smarter about how
we organize the resulting files.

@mnahkies mnahkies changed the title feat: support splitting generation result by tags / route segments feat: experimental support for splitting code by tags / route segments Mar 3, 2024
@mnahkies mnahkies marked this pull request as ready for review March 3, 2024 13:15
@mnahkies mnahkies merged commit 9a23e4f into main Mar 3, 2024
1 check passed
@mnahkies mnahkies deleted the mn/feat/split-generation-result branch March 3, 2024 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant