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

[v4] 4.0.8 Vite plugin breaks if there are virtual imports like unfonts.css #16732

Closed
octoper opened this issue Feb 22, 2025 · 1 comment · Fixed by #16780
Closed

[v4] 4.0.8 Vite plugin breaks if there are virtual imports like unfonts.css #16732

octoper opened this issue Feb 22, 2025 · 1 comment · Fixed by #16780

Comments

@octoper
Copy link

octoper commented Feb 22, 2025

What version of Tailwind CSS are you using?

For example: v4.0.8

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

For example: Vite v6.1.1

What version of Node.js are you using?

For example: v20.13.1

What browser are you using?

For example: Chrome

What operating system are you using?

For example: macOS

Reproduction URL

https://github.com/octoper/vitejs-tailwind408-repro

Describe your issue

When upgraded to @tailwindcss/vite to 4.0.8 I started seeing the error below, this seem to occur when I'm importing a virtual module unfonts.css coming from the https://github.com/cssninjaStudio/unplugin-fonts Vite plugin. Downgrading to 4.0.7 fixes the issue

node:internal/fs/promises:1028
  path = getValidatedPath(path);
         ^

TypeError [ERR_INVALID_ARG_VALUE]: The argument 'path' must be a string, Uint8Array, or URL without null bytes. Received '/Users/octoper/projects/vitejs-tailwind408-repro/\x00unfonts.css'
    at Object.stat (node:internal/fs/promises:1028:10)
    at C.addBuildDependency (file:///Users/octoper/projects/vitejs-tailwind408-repro/node_modules/@tailwindcss/vite/dist/index.mjs:1:5234)
    at C.generate (file:///Users/octoper/projects/vitejs-tailwind408-repro/node_modules/@tailwindcss/vite/dist/index.mjs:1:3810)
    at TransformPluginContext.transform (file:///Users/octoper/projects/vitejs-tailwind408-repro/node_modules/@tailwindcss/vite/dist/index.mjs:1:1967)
    at EnvironmentPluginContainer.transform (file:///Users/octoper/projects/vitejs-tailwind408-repro/node_modules/vite/dist/node/chunks/dep-Cg8OuIew.js:48466:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async loadAndTransform (file:///Users/octoper/projects/vitejs-tailwind408-repro/node_modules/vite/dist/node/chunks/dep-Cg8OuIew.js:42166:27) {
  code: 'ERR_INVALID_ARG_VALUE'
}
@octoper octoper changed the title [v4] 4.0.8 Vite plugin version breaks if there are virtual imports like unfonts.css [v4] 4.0.8 Vite plugin breaks if there are virtual imports like unfonts.css Feb 22, 2025
sodenn added a commit to sodenn/2do-txt that referenced this issue Feb 22, 2025
sodenn added a commit to sodenn/2do-txt that referenced this issue Feb 22, 2025
* chore(deps): update devdependencies (non-major)

* downgrade @tailwindcss/vite to 4.0.7
See tailwindlabs/tailwindcss#16732

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: sodenn <[email protected]>
philipp-spiess added a commit that referenced this issue Feb 25, 2025
Fixes #16732

If we can not get the mtime from a file, chances are that the resource
is a virtual module. This is perfectly legit and we can fall back to
what we did before the changes in `4.0.8` (which is to rebuild the root
every time a change contains a dependency like that).

## Test plan

Added a test to mimic the setup from the repor in #16732. Also ensured
the repro now passes:

<img width="1278" alt="Screenshot 2025-02-24 at 17 29 38"
src="https://github.com/user-attachments/assets/d111273d-579f-44c2-82f5-aa32d6a1879a"
/>

Note that importing virtual modules directly in CSS does not work as the
resolver we use does not resolve against the Vite runtime it seems. This
is unrelated to the regression added in `4.0.8` though and something to
look into in the future.
@philipp-spiess
Copy link
Member

Hey! This is fixed now as of the latest patch release. Thanks for your report!

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.

2 participants