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

Plugins no longer load when using Node 22.12.0 and 23.* #15374

Open
xt0rted opened this issue Dec 11, 2024 · 12 comments · Fixed by #15421
Open

Plugins no longer load when using Node 22.12.0 and 23.* #15374

xt0rted opened this issue Dec 11, 2024 · 12 comments · Fixed by #15421

Comments

@xt0rted
Copy link

xt0rted commented Dec 11, 2024

What version of Tailwind CSS are you using?

v3.4.16

What build tool (or framework if it abstracts the build tool) are you using?

tailwind cli

What version of Node.js are you using?

v22.12.0
v23.*

What browser are you using?

N/A

What operating system are you using?

Windows

Reproduction URL

N/A

Describe your issue

It seems module resolution changed in Node 22.12.0 (as well as v23) and now tailwind no longer loads plugins. The only one I'm using is @tailwindcss/forms and with Node v22.11.0 it's included in the output, but with v22.12.0 or v23.* it's not.

My package.json is set to type": "module" and my config is named tailwind.config.js.

I can resolve this issue two different ways:

  1. Rename my config to use .mjs

  2. Pass the --no-experimental-require-module flag when calling tailwind like so

    NODE_OPTIONS=\"--no-experimental-require-module\" tailwindcss -i ./Styles/base.css --postcss -o ./wwwroot/css/site.css

ref: nodejs/node#55085
ref: nodejs/node#56155

@xt0rted xt0rted changed the title Plugins no longer load when using Node 22.13.0 and 23.* Plugins no longer load when using Node 22.12.0 and 23.* Dec 11, 2024
@RobinMalfait
Copy link
Member

Hey!

Can you share a minimal reproduction repo so we can take a look?

@xt0rted
Copy link
Author

xt0rted commented Dec 12, 2024

Here you go https://github.com/xt0rted-test/tailwind-plugins

While setting that up I found a few more things:

  1. The bug requires the config file to import @tailwindcss/forms and tailwindcss/defaultTheme. In my testing yesterday it seemed to only happen with the forms plugin so it may vary some based on what's in your config.
  2. Adding a file extension to tailwindcss/defaultTheme looks to be a third way to resolve the issue.

@zachczx
Copy link

zachczx commented Dec 14, 2024

I can confirm node 22.12 and node 23.4 broke my use of daisyui plugin. Reverting to node 22.11 solved it.

@xt0rted
Copy link
Author

xt0rted commented Dec 16, 2024

This is where I was pointed to when I commented on the original PR that changed this flag nodejs/node#56155 (comment)

@thecrypticace
Copy link
Contributor

thecrypticace commented Dec 17, 2024

I've tracked this down to an issue potentially with Jiti.

The issue happens when a require(esm) call fails and then Jiti is subsequently used to load that file.

reproduction here: https://github.com/thecrypticace/node-22-jiti-bug

I'm going to file a bug with Jiti and also see if I can track this down within Jiti itself

Notes:

  • Jiti 1 and 2 are both affected. And in Jiti 2 both the sync and asynchronous APIs are affected.
  • If you use an await import(esm) call and it fails the bug does not occur (we can't use await import(…) in v3 unfortunately due to backwards compatibility)

Jiti bug report: unjs/jiti#346

@thecrypticace
Copy link
Contributor

Because using Jiti alone doesn't appear to be broken I'd suggest renaming your config file to tailwind.config.mjs for the time being since we force the use of Jiti in that case.

thecrypticace added a commit that referenced this issue Dec 17, 2024
Fixes #15374

If we always use Jiti the problem should, in theory, go away (I hope).
It does mean that loading configs is slower than it would be if they're
written in CJS but 🤷‍♂️

Wanna get this running with the integration tests to see if anything
breaks.
@thecrypticace
Copy link
Contributor

I published v3.4.17 which always runs Jiti for configs. Hopefully this will work around the Node v22.12+ issues.

@xt0rted @zachczx can y'all see if things are working again for you?

@xt0rted
Copy link
Author

xt0rted commented Dec 17, 2024

@thecrypticace v3.4.17 seems to be working with node 22.12.0 now, but I'll have to do a more in-depth test later to fully confirm.

@onlime
Copy link

onlime commented Dec 17, 2024

Thanks @thecrypticace for v3.4.17, confirm it working as well in my project, renamed tailwind.config.mjs back to tailwind.config.js / v22.12.0

@onlime
Copy link

onlime commented Dec 17, 2024

It should now be hotfixed in jiti:

unjs/jiti#346 (comment)

v1.21.7 + v2.4.2 released with hotfix. (confirmed fix on your reproduction)

@xt0rted
Copy link
Author

xt0rted commented Dec 18, 2024

@thecrypticace after more testing this looks to have fixed my issue

@zachczx
Copy link

zachczx commented Dec 18, 2024

I published v3.4.17 which always runs Jiti for configs. Hopefully this will work around the Node v22.12+ issues.

@xt0rted @zachczx can y'all see if things are working again for you?

All good on my end too, thank you!!

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.

5 participants