tailwindcss icon indicating copy to clipboard operation
tailwindcss copied to clipboard

@source directive not working with pnpm

Open adityaa72 opened this issue 1 year ago • 6 comments

What version of Tailwind CSS are you using?

v4.0.1

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

Next.js v15.1.6

What version of Node.js are you using?

v20.0.0

What browser are you using?

Firefox

What operating system are you using?

macOS

Reproduction URL

Tailwind 4 with pnpm Tailwind 4 with yarn

Describe your issue

@source directive not working for node_modules packages with pnpm and nextjs. The same code is working with nextjs and yarn, and nextjs and npm, also same package works with pnpm with vite with @tailwindcss/vite

@import "tailwindcss";
@import "@jamsr-ui/theme/styles.css";

/* This is not working */
@source "../node_modules/@jamsr-ui";

/* These are working */
/* @source "../node_modules/@jamsr-ui/text"; */
/* @source "../node_modules/@jamsr-ui/button"; */
/* @source "../node_modules/@jamsr-ui/utils"; */
/* @source "../node_modules"; */

Here @source "../node_modules/@jamsr-ui"; is not working but nested @source are working as like @source "../node_modules/@jamsr-ui/text";. Even @source "../node_modules" is working

adityaa72 avatar Jan 30 '25 06:01 adityaa72

Yaa, how to fix??

vishalx07 avatar Jan 30 '25 12:01 vishalx07

This also affects npm as well as discussed here in the discord: https://discord.com/channels/486935104384532500/1341775942846255145

this makes it work;

@import 'tailwindcss';
@source '../../node_modules/tablewind/dist';

but this one doesn't.

@import 'tailwindcss';
@source '../../node_modules/tablewind';

adambirds avatar Feb 19 '25 15:02 adambirds

@adambirds Thanks for looking into this and for explaining the issue and potential ways to fix this in #16669. Going to merge this issue into #16669 so we only track this at one place 👍

philipp-spiess avatar Feb 21 '25 10:02 philipp-spiess

@philipp-spiess Thanks, but this is not a duplicate of #16669. I don't have dist in .gitignore and this code is working with yarn and npm. This issue is related to pnpm because pnpm create node_modules with symlinks . Setting node-linker=hoisted in .npmrc file solve the issue.

adityaa72 avatar Feb 21 '25 11:02 adityaa72

@adityaa72 Thanks for the additional context, I've reopened so we can investigate 👍

philipp-spiess avatar Feb 21 '25 14:02 philipp-spiess

Hey!

Alright we figured it out and it should be solved by #17391 and will be available in the next release.

RobinMalfait avatar Mar 26 '25 12:03 RobinMalfait