catppuccin / tailwindcss

💨 Soothing pastel theme for Tailwind CSS
https://tailwindcss.catppuccin.com/
MIT License
372 stars 5 forks source link

Issues with Next.js 14 (typescript, eslint) #18

Closed onexbash closed 3 months ago

onexbash commented 6 months ago

As you can see in the screenshot, I get an error when adding prefix & defaultFlavour to the tailwind config: Type error: This expression is not callable. Type 'typeof import("/opt/repos/projects/portfolio/node_modules/.pnpm/@catppuccin+tailwindcss@0.1.6_tailwindcss@3.4.1/node_modules/@catppuccin/tailwindcss/dist/index")' has no call signatures.

CleanShot 2024-02-18 at 16 28 02@2x

When removing the prefix & defaultFlavour, it works.. CleanShot 2024-02-18 at 16 30 14@2x

joulev commented 6 months ago

This is not related to Next.js. You can simply make a foo.js file with this content

// @ts-check
const foo = require("@catppuccin/tailwindcss");

foo({}); // TS error
foo.default({}); // TS is happy

to reproduce the error.

From a quick glance, the cause seems to be that @catppuccin/tailwindcss should've used export = instead of export default.

What you can do right now while waiting for this bug to be patched: use tailwind.config.ts instead where you can use ESM syntax

// tailwind.config.ts
import type { Config } from "tailwindcss";
import tailwindForms from "@tailwindcss/forms";
import catppuccin from "@catppuccin/tailwindcss";

const config: Config = {
  content: ['./app/**/*.{js,ts,jsx,tsx}', './components/**/*.{js,ts,tsx}', '.css/**/*.css'],
  theme: {},
  safelist: [
    // this is for demonstration purposes only, not required for basic usage
    {
      pattern: /bg-.+/,
    },
  ],
  plugins: [
    tailwindForms,
    catppuccin({
      prefix: 'one',
      defaultFlavour: 'mocha',
    }),
  ],
};

export default config;