nuxt-modules / tailwindcss

Tailwind CSS module for Nuxt
https://tailwindcss.nuxtjs.org
MIT License
1.67k stars 182 forks source link

Build error after upgrade to `6.12.2` from `6.12.1` #909

Open HADB opened 5 days ago

HADB commented 5 days ago

Environment


Reproduction

No response

Describe the bug

Build error after upgrade to 6.12.2 from 6.12.1

hadb.me git:(renovate/all-minor-patch) pnpm i
Lockfile is up to date, resolution step is skipped
Already up to date

> @ prepare /Users/bean/Projects/GitHub/HADB/hadb.me
> nuxt prepare

ℹ Using Tailwind CSS from ~/assets/css/tailwind.css                                                      nuxt:tailwindcss 11:15:26

[11:15:27]  WARN  Duplicated imports "useTrackEvent", the one from "/Users/bean/Projects/GitHub/HADB/hadb.me/node_modules/.pnpm/@nuxtjs+plausible@1.0.3_magicast@0.3.5_rollup@4.21.0_webpack-sources@3.2.3/node_modules/@nuxtjs/plausible/dist/runtime/composables/useTrackEvent" has been ignored and "/Users/bean/Projects/GitHub/HADB/hadb.me/node_modules/.pnpm/nuxt-gtag@3.0.1_magicast@0.3.5_rollup@4.21.0_webpack-sources@3.2.3/node_modules/nuxt-gtag/dist/runtime/composables/useTrackEvent" is used

 ERROR  Cannot destructure property 'theme' of 'undefined' as it is undefined.                                             11:15:27

  at typography (tailwind.config.ts:32:22)
  at node_modules/.pnpm/@nuxtjs+tailwindcss@6.12.2_magicast@0.3.5_rollup@4.21.0_webpack-sources@3.2.3/node_modules/@nuxtjs/tailwindcss/dist/module.mjs:135:18
  at _defu (node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs:31:19)
  at _defu (node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs:37:21)
  at _defu (node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs:37:21)
  at node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs:52:33
  at Array.reduce (<anonymous>)
  at node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs:52:16
  at configMerger (node_modules/.pnpm/@nuxtjs+tailwindcss@6.12.2_magicast@0.3.5_rollup@4.21.0_webpack-sources@3.2.3/node_modules/@nuxtjs/tailwindcss/dist/module.mjs:138:5)
  at configs.reduce.configMerger.content.files (node_modules/.pnpm/@nuxtjs+tailwindcss@6.12.2_magicast@0.3.5_rollup@4.21.0_webpack-sources@3.2.3/node_modules/@nuxtjs/tailwindcss/dist/module.mjs:249:23) 

 ERROR  Cannot destructure property 'theme' of 'undefined' as it is undefined.                                             11:15:27

 ELIFECYCLE  Command failed with exit code 1.

Additional context

No response

Logs

No response

HADB commented 5 days ago

My nuxt.config.ts:

...
  tailwindcss: {
    cssPath: ['~/assets/css/tailwind.css', { injectPosition: 'last' }],
    configPath: 'tailwind.config.ts',
  },
...

I found that everything goes well if I remove configPath: 'tailwind.config.ts', from nuxt.config.ts.

Maybe there are some breaking changes for this redundant config.

ineshbose commented 5 days ago

Thanks for raising this. I see the repository on your profile, and I'll try to investigate further.

You don't need to provide configPath if it is already tailwind.config (and maybe the path resolution behaves odd without path specifier eg relative or project dir root). Still, it shouldn't cause issues between versions.

From the traceback, I'm thinking if it's this line - https://github.com/nuxt-modules/tailwindcss/blob/main/src/runtime/merger.js#L34

Again, this wasn't changed between 6.12.1 and 6.12.2 but I notice that the if condition rather belongs in the earlier block (how did we miss that 😄). Let me continue investigating