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

Move top level modules into utils #2604

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Move top level modules into utils #2604

wants to merge 6 commits into from

Conversation

tjmw
Copy link
Member

@tjmw tjmw commented Dec 18, 2024

What does this change?

All files at the top level of modules have been moved into utils and are now imported as such (e.g. import { getIfDefined } from '@modules/utils/nullAndUndefined'. Supporting files at the top level of the modules dir was a bit of an exception and meant we needed an additional rule in the jest config. It's only one line but it doubled the cognitive load of understanding how the module mappings worked, and it lead to some inconsistency of how modules were imported.

Because of the exception, it also meant top level modules tests weren't getting run in CI.

How to test

How can we measure success?

Have we considered potential risks?

Images

Accessibility

@@ -4,15 +4,5 @@
"require": [
"tsconfig-paths/register"
]
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is not needed? I think the issue without it was that ts-node couldn't resolve the module paths.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure - these all exist in the top level tsconfig. I might be missing something though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in fact needed to run pnpm --filter product-catalog generateTypes. Put back in 8f31213.

Copy link
Member

@rupertbates rupertbates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, arguably errors and stage don't really belong in a utils directory. They might be better off in their own specific directory? Don't mind too much about that though.

As I've commented elsewhere, are you sure we don't need those paths in the ts configs?

tjmw added 3 commits December 18, 2024 15:49
Supporting files at the top level of the modules dir was a bit of an
exception and meant we needed an additional rule in the jest config.
It's only one line but it doubled the cognitive load of understanding
how the module mappings worked, and it lead to some inconsistency of how
modules were imported.

Because of the exception, it also meant top level modules tests weren't
getting run in CI.
For some reason things break with ts-node when this is removed, like it
doesn't properly use the extended tsconfig. This broke:

$ pnpm --filter product-catalog generateTypes
@tjmw tjmw force-pushed the tw/top-level-modules branch from 8f31213 to 854c068 Compare December 18, 2024 15:49
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.

2 participants