sozonome / nextarter-chakra

battery packed template / boilerplate to initialize Next.js app with Chakra UI & Typescript setup ✨
https://nextarter-chakra.sznm.dev/
MIT License
806 stars 98 forks source link

Cannot add new package #138

Closed bwcr closed 8 months ago

bwcr commented 8 months ago

Describe the bug

"Hello there! I have been using this template for a while now and I like it. Recently, I tried to add a new package called 'react-hook-form' but I encountered an error that says 'webpack_imported_module is not a function'. I'm not sure what went wrong so I hope someone can help me with this. Thank you in advance for your assistance!"

Reproduction

https://effective-space-parakeet-7pjg9rvp7j4fpvw.github.dev/

System Info

System:
    OS: Windows 11 10.0.22621
    CPU: (8) x64 AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx
    Memory: 1.34 GB / 9.89 GB
  Binaries:
    Node: 20.11.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
    pnpm: 8.15.4 - ~\AppData\Local\pnpm\pnpm.EXE
  Browsers:
    Edge: Chromium (121.0.2277.128)
    Internet Explorer: 11.0.22621.1

Used Package Manager

pnpm

Validations

sozonome commented 8 months ago

Hi @bwcr , I cannot access the reproduction link, can you provide more information or provide a complete reproduction repo?

Error like this doesn't mainly come from just installing the package, but also how we use or implement it in the project. I might help you to pinpoint the problem if there's any complete reproduction to look at.

bwcr commented 8 months ago

Hi @bwcr , I cannot access the reproduction link, can you provide more information or provide a complete reproduction repo?

Error like this doesn't mainly come from just installing the package, but also how we use or implement it in the project. I might help you to pinpoint the problem if there's any complete reproduction to look at.

You're right. It turns out that the error occurred because I needed to add 'use client' at the top of the file. I have fixed the issue now. However, I am now curious as to why I need to add this line every time I insert a new package, when Chaka UI seems to work without it.

sozonome commented 8 months ago

Hi @bwcr , glad to know the issue is fixed.

  1. This is a new concept / paradigm being opt-in when we pick App Router - RSC. nextarter-chakra has Pages router version here: https://github.com/sozonome/nextarter-chakra-pages-router

    I am now curious as to why I need to add this line every time I insert a new package, when Chaka UI seems to work without it.

  2. Chakra UI have added 'use client' on each of their component exports
  3. We might not need to always insert "use client" every time adding a new package, we only need to insert it on:

This new paradigm / concept of [RSC - server components & client components] might look confusing at first, I also felt so confused with it at first, but I hope this issue being encountered and some references attached above helps you to understand better on RSC and the reasonings. 🙇

Will set this issue as closed 🙇 Feel free to ask or discuss more in this thread if you have any further questions or ideas