Skip to content

Improve @tailwindcss/upgrade and pnpm workspaces support #18065

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

Merged
merged 6 commits into from
May 19, 2025

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented May 16, 2025

This PR fixes an issue where an error such as:

image

Will be thrown during the upgrade process. This can happen when you are using pnpm and your CSS file includes a @import "tailwindcss";. In this scenario, tailwindcss will be loaded from a shared .pnpm folder outside of the current working directory.

In this case, we are also not interested in migrating that file, but we also don't want the upgrade process to just crash.

I didn't see an option to ignore errors like this, so wrapped it in a try/catch instead.

It also fixes another issue where if you are using a pnpm workspace and run the upgrade tool from the root, then it throws you an error that you cannot add dependencies to the workspace root unless -w or --workspace-root flags are passed.

For this, we disable the check entirely using the --ignore-workspace-root-check flag. If we always used the --workspace-root flag, then the dependencies would always be added to the root, regardless of where you are running the script from which is not what we want.

Test plan

Before:

image

After:

image

Before:

image

After:

image

@RobinMalfait RobinMalfait changed the title Fix path … not in cwd when running upgrade tool Improve @tailwindcss/upgrade and pnpm workspaces support May 16, 2025
@RobinMalfait RobinMalfait marked this pull request as ready for review May 17, 2025 09:53
@RobinMalfait RobinMalfait requested a review from a team as a code owner May 17, 2025 09:53
@thecrypticace
Copy link
Contributor

Should we add tests for these two scenarios so we can make sure things keep working?

When using pnpm with a workspace, if you happen to run the upgrade tool
in the root because some Tailwind CSS dependencies live there, then you
will get an error that you need the `--workspace-root` flag.

However, if we _always_ add it, then the upgrade tool will add
dependencies to the root, regardless of whether you are in a
sub-packages.

With this, the check doesn't happen and no error is thrown. This will
just install/bump the dependencies where necessary.
@RobinMalfait RobinMalfait force-pushed the fix/path-not-in-cwd branch from e07b8f1 to 7aa017a Compare May 19, 2025 10:22
@RobinMalfait
Copy link
Member Author

Should we add tests for these two scenarios so we can make sure things keep working?

Good idea, added some failing tests in between commits and they got fixed by the followup commits

@RobinMalfait RobinMalfait merged commit 71fb9cd into main May 19, 2025
7 checks passed
@RobinMalfait RobinMalfait deleted the fix/path-not-in-cwd branch May 19, 2025 10:47
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.

3 participants