Closed dino3616 closed 1 year ago
Hi @dino3616 thank you for your feedback and for providing a reproduction case.
Based on the reproduction, it seems that this issue is not related to the tailwind-variants
. Instead, it might be due to the importing from @tv-bug/tailwind/src/index.ts
which led to bundling the @tv-bug/tailwind/src/config.ts
file into the client side and we should try to avoid this whenever possible.
packages/tailwind/src/index.ts
- export * from './config';
export * from './util';
apps/website/tailwind.config.ts
- import { createConfig } from '@tv-bug/tailwind';
+ import { createConfig } from '@tv-bug/tailwind/src/config';
Rename config.ts
and util.ts
in the packages/tailwind/src
directory to create-config.ts
and cn.ts
, and then fix the exports in the barrel file whitch is index.ts
.
// add modularizeImports config in next.config.mjs
const config = {
...rest,
modularizeImports:{
'@tv-bug/tailwind': {
transform: '@tv-bug/tailwind/src/{{ kebabCase member }}',
preventFullImport: true,
skipDefaultConversion: true,
},
}
};
// imports will be the same as in the repro, no changes needed
import { createConfig } from '@tv-bug/tailwind';
import { cn } from '@tv-bug/tailwind';
// and you are good to go 🚀
Closing as stale, @tianenpang's suggestion should resolve the issue, but if it does not, we can re-open this issue.
Describe the bug
In monorepo using Turborepo, when
withTV()
was called in a child package to hide settings related to tailwind,writeFileSync()
was called on the client side and compilation failed.To Reproduce
Steps to reproduce the behavior:
pnpm install
commandpnpm website dev
commandExpected behavior
Can compile even if
withTV()
is called in a child package.Screenshots
Below is a screenshot of the error output to the browser:
and terminal:
Desktop (please complete the following information):
Additional context
This problem is only specific to monorepo and does not occur with polyrepo. In fact, a modification like this PR completely eliminates the problem.