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

chore: replace dynamic tsconfig path generation with static imports #11984

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

Conversation

GermanJablo
Copy link
Contributor

@GermanJablo GermanJablo commented Apr 4, 2025

What?

Currently, every time pnpm test [suite] is run, there is an automatic script that modifies the @payload-config path in tsconfig.base.json so that files within test/app resolve to the correct payload configuration.

In addition, there is a git hook that reverts tsconfig.base.json to its original state.

This PR removes the tsconfig.base.json codegen and git hook and instead uses a static list of imports, which is resolved using an environment variable so that the @payload-config path remains the same in all cases.

Why?

  • Having codegen in a file that is not .gitignored is not ideal. It can interfere with workflow in several ways. For example, when switching branches, git can throw an error after several seconds if the file is not stashed.
  • Since this is something that was enforced only by git hooks, they are often circumvented with --no-verify, and end up causing noise in the PRs.
  • Overall simplicity of the workflow. While this PR has more lines added than removed, most are static lines from the config map. A fair amount of logic within the scripts has been removed.

How?

  • Created a centralized config-imports.ts with a static map of all test suite configurations. The reason you can't use the environment variable directly within the import is that webpack doesn't allow variables within an import.
  • Updated error messages to provide clear guidance when a test suite folder exists but hasn't been added to the static imports.
  • I noticed that the test/app/(app) folder wasn't being used, so I deleted it. It had a test page that imported the old getPayload and threw an error when trying to access it.

@GermanJablo GermanJablo requested a review from denolfe April 4, 2025 13:09
@GermanJablo GermanJablo marked this pull request as draft April 4, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant