-
Notifications
You must be signed in to change notification settings - Fork 134
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 require()
plugin after upgrading to v0.5.x
#207
Comments
Can you provide a reproduction? That seems like something is trying to compile the prettier plugin to CJS which isn't possible rather than just run it (which shouldn't be happening). |
I have the same error. What version of prettier-plugin-tailwindcss are you using? What version of Tailwind CSS are you using? What version of Node.js are you using? What package manager are you using? What operating system are you using?
|
Facing the same problem: What version of prettier-plugin-tailwindcss are you using? What version of Tailwind CSS are you using? What version of Node.js are you using? What package manager are you using? What operating system are you using? My framework is nextJs Here is the error message :
|
@Jobbies @com-pote Could either of you provide a reproduction? Or at the very least your tailwind config files? @com-pote Are you calling |
I also have been having this issue when upgrading to prettier v3.0 and this plug in to 0.5.3. Apparently this is has been noticed over at Prettier too: My prettierrc.json:
my tailwind config:
|
Not sure if it's related, but I see the following error:
Here's the /** @type {import("prettier").Config} */
module.exports = {
plugins: [require("prettier-plugin-tailwindcss")],
tailwindConfig: "./tailwind.config.cjs",
}; I'd expect |
Well this is embarrassing. I was requiring |
After a few checks I realized that in my prettier file I write .js whereas my tailwind configuration file is a .ts file. So I renamed my file to tailwind.config.js and now I can run |
My fix is remove |
the same error for me |
don't require neither in tailwind.config.js |
This plugin now requires Prettier v3+ i had 2.8.8, so updating to v3 fixed the issue |
What version of prettier-plugin-tailwindcss are you using? What version of Tailwind CSS are you using? What version of Prettier are you using? What version of Node are you using? I'm also getting this error:
I've also tried making this file a cjs-file without luck.
|
@buhlerfanny You should use just the plugin name without // prettier.config.js
module.exports = {
plugins: ["prettier-plugin-tailwindcss"],
}; |
require()
plugin after upgrading to v0.5.x
Hey everyone! In general what I'm seeing here can be explained by users either calling This plugin, as of v0.5, requires Prettier v3+ and is now ESM-only. Let's discuss the upgrade path from v0.4 to v0.5+, some scenarios that you might've run into, and the reasons behind the change: Upgarding to v0.5+OverviewFirst, This means that:
Second, This means that:
How to upgradeIf you have not done so — first upgrade to Prettier v3. Then proceed with the rest of this guide. I do not have a prettier configIn Prettier v2 plugins could be autoloaded. This worked by following a naming convention for a package — any package name starting with // prettier.config.js
module.exports = {
plugins: ['prettier-plugin-tailwindcss'],
} My prettier config is in
|
Hello @thecrypticace, this may be a pointless discussion since at some point most users will be using prettier 3.x, but I still have one question. I understand that the reason this plugin guarantees compatibility with some third-party plugins is because prettier does not support formatting for multiple plugins that implement the same parser. If this and third-party plugins can be formatted independently, is there any chance that dual CJS/ESM builds will be supported again? |
Yeah basically we implement 3rd party support ourselves because it would not otherwise be possible with Prettier today. I even worked on a prototype API for prettier that would enable this but in the end discovered that someone came up with a similar idea that was shot down by the Prettier team. So I'm not sure what that'd look like.
In theory, sure but it would still be Prettier v3 only because any change would require updates to Prettier itself and it's doubtful that you'd get updates in v2 and v3 now that v3 is out. |
All right. In my case, I solved prettier's multiple plugin formatting limitations by creating another plugin, but I think it's too late to suggest a dual build with this. |
Yeah that can work in some scenarios as long as none of the required plugins are ESM and you know that the plugin is always going to be used. |
cool worked for me |
i added a prettier.config.js file in the root directory and i added this code below and still not work what to do |
have you installed prettier? for me prettier version 3.0.3 works with the config file |
@thecrypticace Thanks for the Upgrade Guide but please bump the major version to satisfy SemVer: tailwindlabs/tailwindcss#12307 |
@designorant The version bump from 0.4.x to 0.5.x does satisfy Semantic Versioning requirements. If we were already at 1.y.z then we would've needed to bump to v2.0 but we were not. |
It does, and it doesn't. SemVer clearly says:
Bump to I appreciate you may consider There seems to be an industry convention is to keep the major versions low for some reason but major version zero is all about rapid development. Given this package has 1m+ downloads every week and 200+ dependents bumping it to
|
This works for me My // prettier.config.js
plugins: ["prettier-plugin-tailwindcss"], |
Using a .prettierrc configuration file was the issue for me, once I converted the config to prettier.config.js it worked properly |
hi, How can I customize the plugin path "prettier-plugin-tailwindcss", it doesn't work as I have written. It only works with Tailwind config path. |
Doesn't work for me. Note: When I run
weird |
I must using
in file 'package.json' to use both
and
I try to use it on file 'prettier.config.js' but not work |
Please check that you're actually using version >3.0 with You may be running an old Prettier version, even though you locally installed the correct version. |
Having a similar issue, here's my /** @type {import("prettier").Config} */
module.exports = {
"plugins": ["prettier-plugin-svelte", 'prettier-plugin-tailwindcss', "@trivago/prettier-plugin-sort-imports"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }],
"printWidth": 160,
"useTabs": true,
"trailingComma": "all",
"singleQuote": true,
"semi": true,
"importOrder": ["<THIRD_PARTY_MODULES>", "^@/(.*)$", "^$env/(.*)$", "^[./]"],
"importOrderSeparation": true,
"importOrderSortSpecifiers": true
}; I'm using the prettier plugin from VSCode, here's the error:
@thecrypticace I don't believe the issue is resolved. I'm also running Prettier v3.2.4 |
Same, cannot run from VSCode. |
Ran into a similar issue while working in a monorepo. I was getting this error:
It looks like the way you import/export config really matters. This is what my config looked like: // apps/foo/tailwind.config.ts
export * from "@repo/ui/tailwind.config"; // My package.json for the ui package has an "exports" property: "exports": { "./tailwind.config": "./tailwind.config.ts" }. If yours doesn't, this import may need the extension But it should actually be this: import config from "@repo/ui/tailwind.config";
export default config; Silly, but it bit me. Just in case (as others have said), make sure your tailwind config doesn't include edit: typo |
@voinik |
Try changing it to .mjs with an export default. |
Major version zero (0.y.z) is for initial development. Anything MAY change at any time. The public API SHOULD NOT be considered stable - source |
This fixed it for me. |
What version of
prettier-plugin-tailwindcss
are you using?v0.5.3
What version of Tailwind CSS are you using?
v3.3.3
What version of Node.js are you using?
19.5.0
What package manager are you using?
npm
What operating system are you using?
Windows 11
Describe your issue
I have just updated from v0.4.0 to 0.5.3 and this issue came when we do try to run the site
`
./app/global.css.webpack[javascript/auto]!=!../../node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[13].use[2]!../../node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[13].use[3]!./app/global.css
D:\Development\EmploHub\Emplohub\node_modules\prettier-plugin-tailwindcss\dist\index.mjs:4
const require=_module2.createRequire.call(void 0, import.meta.url)
^
SyntaxError: Identifier 'require' has already been declared
`
We are using NextJs 13.4.19
The text was updated successfully, but these errors were encountered: