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

[cleanup] remove legacy path condition in jest preprocessor #31361

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ldirer
Copy link

@ldirer ldirer commented Oct 26, 2024

Summary

This PR removes a condition that looks legacy inside Jest preprocessor script.

How I happened upon this:

Running yarn test on a fresh clone of the repository, I ran into Jest errors suggesting files were not transformed properly by babel.

I tracked it down to a condition in scripts/jest/preprocessor.js:

if (!filePath.match(/\/third_party\//)) {
    ...
}

I had cloned the repo on my machine inside a third_party/react directory, causing this condition to always be false 🥲 .

How did you test this change?

Research done:

  • I only found one third_party directory, and it was inside node_modules (hence already ignored by babel transforms).
  • I looked at the git history with git log --diff-filter=ACDR -- '*third_party*'.
  • This confirmed the third_party folder existed at some point in the codebase and was removed in commit 8b4ec79.

Running yarn test before/after the change produces the same output in the general case.
If running yarn test with a path like third_party/react, the command fails before this change and passes after.

This seemed like a tiny fix so I did not open an issue.

Copy link

vercel bot commented Oct 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 26, 2024 1:25am

@ldirer
Copy link
Author

ldirer commented Nov 4, 2024

This really should be a minor change, I think the diff is a bit misleading.
This would be a "minus 3 lines" diff if the condition on main had been inverted to look as follows:

if (filePath.match(/\/third_party\//)) {
    return {code: src}
}

Anyway, here's a Dockerfile that reproduces the issue when placed at the root of the repository.
It runs tests twice as part of the build: the first set of tests passes, the second does not (due to the name of the containing folder).

Expected reproduction before this PR: docker build -t react-tests ./ fails on the second RUN yarn test command.

FROM node:18.20.1

WORKDIR /app

COPY . .

RUN yarn install

# Run tests - these should pass
RUN yarn test

RUN mv /app /third_party

WORKDIR /third_party
# these will fail
RUN yarn test

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.

2 participants