windicss / nuxt-windicss

🍃 Windi CSS for Nuxt ⚡
331 stars 24 forks source link

Nuxt 3.0.0 failed when buildModules is not defined #190

Closed BrandonlinU closed 2 years ago

BrandonlinU commented 2 years ago

Describe the bug After updating Nuxt 3 RC 13 to Nuxt 3.0.0, it does not allow define buildModules in the nuxt.config.ts, because it was deprecated. Because of that, when nuxt-windicss unpacks the array in the line 109, it throw an exception because buildModules is now undefined.

To Reproduce Steps to reproduce the behavior:

  1. Init a new Nuxt 3 proyect
  2. Install nuxt-windicss
  3. Add nuxt-windicss to the modules section.
  4. See the error

Expected behavior It should not require buildModules in the nuxt.config.ts.

Trace

 ERROR  nuxt.options.buildModules is not iterable                                                                                                                                                                       12:28:17

  at setup (node_modules/.pnpm/nuxt-windicss@2.5.4/node_modules/nuxt-windicss/dist/module.mjs:94:23)
  at normalizedModule (node_modules/.pnpm/@nuxt+kit@3.0.0-rc.13/node_modules/@nuxt/kit/dist/index.mjs:614:29)
  at async installModule (node_modules/.pnpm/@nuxt+kit@3.0.0/node_modules/@nuxt/kit/dist/index.mjs:416:3)
  at async initNuxt (node_modules/.pnpm/nuxt@3.0.0_gm5c2zoibozvhuo7w6sksyhknu/node_modules/nuxt/dist/index.mjs:1825:7)
  at async loadNuxt (node_modules/.pnpm/nuxt@3.0.0_gm5c2zoibozvhuo7w6sksyhknu/node_modules/nuxt/dist/index.mjs:1857:5)
  at async loadNuxt (node_modules/.pnpm/@nuxt+kit@3.0.0/node_modules/@nuxt/kit/dist/index.mjs:493:19)
  at async Object.invoke (node_modules/.pnpm/nuxi@3.0.0/node_modules/nuxi/dist/chunks/prepare.mjs:30:18)
  at async _main (node_modules/.pnpm/nuxi@3.0.0/node_modules/nuxi/dist/cli.mjs:50:20)

Additional context It should be easy to fix this error, so I make a pull request and linked in to this issue.

BrandonlinU commented 2 years ago

Well, it seems that after update the code from the repository, it seems that it release a more sinister bug, and after spend hours figure it out the problem in the Nuxt 3 playground I don't find any solution. Here is the trace:

[Vue warn]: inject() can only be used inside setup() or functional components.                                                                                                                                      16:11:27
[Vue warn]: Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.                                                                                        16:11:27
[Vue warn]: Unhandled error during execution of setup function                                                                                                                                                      16:11:27
  at <NuxtRoot>
[nuxt] [request error] [unhandled] [500] Cannot read properties of undefined (reading 'modules')                                                                                                                    16:11:27
  at _sfc_main.setup (./node_modules/.pnpm/nuxt@3.0.0_7ywvn3gtwfitf7f3hfntqq4vki/node_modules/nuxt/dist/app/components/nuxt-root.vue:67:16)  
  at callWithErrorHandling (./node_modules/.pnpm/@vue+runtime-core@3.2.45/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:157:22)  
  at setupStatefulComponent (./node_modules/.pnpm/@vue+runtime-core@3.2.45/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7176:29)  
  at setupComponent (./node_modules/.pnpm/@vue+runtime-core@3.2.45/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7131:11)  
  at renderComponentVNode (./node_modules/.pnpm/@vue+server-renderer@3.2.45_vue@3.2.45/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:172:17)  
  at renderToString (./node_modules/.pnpm/@vue+server-renderer@3.2.45_vue@3.2.45/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:450:26)  
  at Object.renderToString$1 [as renderToString] (./.nuxt/dev/index.mjs:3491:24)  
  at Object.renderToString (./node_modules/.pnpm/vue-bundle-renderer@1.0.0/node_modules/vue-bundle-renderer/dist/runtime.mjs:173:40)  
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)  
  at async ./.nuxt/dev/index.mjs:3551:21
[Vue warn]: inject() can only be used inside setup() or functional components.                                                                                                                                      16:11:27
[Vue warn]: Server rendering context not provided. Make sure to only call useSSRContext() conditionally in the server build.                                                                                        16:11:27
[Vue warn]: Unhandled error during execution of setup function                                                                                                                                                      16:11:27
  at <NuxtRoot>
[nuxt] [request error] [unhandled] [500] Cannot read properties of undefined (reading 'modules')                                                                                                                    16:11:27
  at _sfc_main.setup (./node_modules/.pnpm/nuxt@3.0.0_7ywvn3gtwfitf7f3hfntqq4vki/node_modules/nuxt/dist/app/components/nuxt-root.vue:67:16)  
  at callWithErrorHandling (./node_modules/.pnpm/@vue+runtime-core@3.2.45/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:157:22)  
  at setupStatefulComponent (./node_modules/.pnpm/@vue+runtime-core@3.2.45/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7176:29)  
  at setupComponent (./node_modules/.pnpm/@vue+runtime-core@3.2.45/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:7131:11)  
  at renderComponentVNode (./node_modules/.pnpm/@vue+server-renderer@3.2.45_vue@3.2.45/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:172:17)  
  at renderToString (./node_modules/.pnpm/@vue+server-renderer@3.2.45_vue@3.2.45/node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:450:26)  
  at Object.renderToString$1 [as renderToString] (./.nuxt/dev/index.mjs:3491:24)  
  at Object.renderToString (./node_modules/.pnpm/vue-bundle-renderer@1.0.0/node_modules/vue-bundle-renderer/dist/runtime.mjs:173:40)  
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)  
  at async ./.nuxt/dev/index.mjs:3551:21

Any idea?

acidjazz commented 2 years ago

I have added a temporary workaround until this gets fixed

    "nuxt-windicss-monorepo": "fumeapp/nuxt-windicss-dist#dist",
    "@windicss/plugin-utils": "^1.8.8",
    "vite-plugin-windicss": "^1.8.8",
    "windicss-analysis": "^0.3.5"
modules: [
...
'nuxt-windicss-monorepo/packages/nuxt-windicss',
...
],

Be sure to remove these extra deps when nuxt-windicss is fixed for v3 as they are already included

TuguldurJ commented 2 years ago

I have added a temporary workaround until this gets fixed

  • Add the following to your devDependencies
    "nuxt-windicss-monorepo": "fumeapp/nuxt-windicss-dist#dist",
    "@windicss/plugin-utils": "^1.8.8",
    "vite-plugin-windicss": "^1.8.8",
    "windicss-analysis": "^0.3.5"
  • Specify your module as this instead:
modules: [
...
'nuxt-windicss-monorepo/packages/nuxt-windicss',
...
],

Be sure to remove these extra deps when nuxt-windicss is fixed for v3 as they are already included

No changes, Cannot start nuxt: nuxt.options.buildModules is not iterable

harlan-zw commented 2 years ago

Fixed in 2.5.5, thanks @acidjazz

TuguldurJ commented 2 years ago

Thanks @acidjazz