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

Can't read file preflight.css after upgrade to v0.5.2 #203

Closed
YannicEl opened this issue Aug 12, 2023 · 6 comments · Fixed by #204
Closed

Can't read file preflight.css after upgrade to v0.5.2 #203

YannicEl opened this issue Aug 12, 2023 · 6 comments · Fixed by #204

Comments

@YannicEl
Copy link
Contributor

What version of prettier-plugin-tailwindcss are you using?

v0.5.2

What version of Tailwind CSS are you using?

Don't have tailwind installed

What version of Node.js are you using?

v20.4.0 also tried 18.13.0

What package manager are you using?

pnpm

What operating system are you using?

Windows 11 64

Reproduction URL

https://stackblitz.com/edit/stackblitz-starters-grpqqn?file=package.json

Describe your issue

Problem occurred once i upgraded to v0.5.2, v0.4.1 worked fine.

When running prettier --write . in the reproduction project I get the following error for every file prettier wants to format:

Error: ENOENT: no such file or directory, open '\C:\Users\user\git\vue-useForm\node_modules\.pnpm\prettier-plugin-tailwindcss@0.5.2_prettier-plugin-organize-imports@3.2.3_prettier@3.0.1\node_modules\prettier-plugin-tailwindcss\dist\css\preflight.css'

image

When following the path, the file preflight.css does indeed exist so I am guessing it has something to do with how pnpm symlinks node_modules. Furthermore, it seems that the problem only occurred on windows. Running prettier --write . in the stackblitz example works and I have a similar setup running on an ubuntu github action which also works correctly. In order to reproduce the issue one would have to download the stackblitz example and run it on a windows machine.

I'm happy to help debug this issue on my windows machine.

@YannicEl
Copy link
Contributor Author

YannicEl commented Aug 12, 2023

I get the same error when installing dependencies with npm so I'm confident pnpm is not the problem here.

After some investigation I found the code that throws the error:

image
This is a screenshot from node_modules/prettier-plugin-tailwindcss/dist/index.mjs.

I think the problem has something to do with the CJS interop fixes for __filename and __dirname introduced in this commit not working as intended on windows.

When logging __dirname on the top of the file where it is defined it has the value: /C:/Users/user/Downloads/stackblitz-starters-grpqqn/node_modules/.pnpm/prettier-plugin-tailwindcss@0.5.2_patch_hash=n3l5kyiyfcqmtalv43jou5txgu_prettier@3.0.1/node_modules/prettier-plugin-tailwindcss/dist

When logging __dirname in line 25745 from the screenshot it has the value: test/test.css/C:/Users/bamio/Downloads/stackblitz-starters-grpqqn/node_modules/.pnpm/prettier-plugin-tailwindcss@0.5.2_patch_hash=d33hsm7udv6cddqwwjfqsxcbpm_prettier@3.0.1/node_modules/prettier-plugin-tailwindcss/dist.

The test/test.css at the beginning is the path to the file that is being formated and the rest is the absolut path to the libaries dist foder in node_modules.

I'm not sure what happens here.

@YannicEl
Copy link
Contributor Author

Managed to fix it with the solution outlined here: https://stackoverflow.com/a/55944697/14543877
Will make a PR

@YannicEl
Copy link
Contributor Author

PR #204

@thecrypticace
Copy link
Contributor

PR's been merged and it'll be available via our insiders build shortly:

npm install prettier-plugin-tailwindcss@insiders

I'm planning on getting a tagged release out later today.

@YannicEl
Copy link
Contributor Author

insiders release works for me. thank you

@petercpwong
Copy link

Regression is back in v0.5.8

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 a pull request may close this issue.

3 participants