vercel / next.js

The React Framework
https://nextjs.org
MIT License
126.68k stars 26.93k forks source link

Issues with hooks from a symlinked directory, integrated via workspaces (npm) #49097

Open dominikzogg opened 1 year ago

dominikzogg commented 1 year ago

Verify canary release

Provide environment information

Operating System:
      Platform: linux
      Arch: x64
      Version: #1 SMP PREEMPT_DYNAMIC Mon May  1 00:55:28 UTC 2023
    Binaries:
      Node: 18.16.0
      npm: 9.6.5
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.3.1
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

>=13.3.2

Link to the code that reproduces this issue

https://github.com/dominikzogg/reproduction-app

To Reproduce

Use my repo with master branch (next: >=13.3.2) and its broken, use the working-version branch 13.3.1 and it works.

Describe the Bug

When i upgrade next to >=13.3.2 it produces the following error:

../shared/hooks/use-cookie-consent.tsx (10:66) @ undefined
Unhandled Runtime Error
TypeError: dispatcher is null

It seems to work if its not symlinked (no issue on my build pipeline where files where copied to the shared folder within project directory.

I guess its related to: https://github.com/vercel/next.js/pull/48506

Expected Behavior

I expect that the code runs as it did until 13.3.1

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

dominikzogg commented 1 year ago

As an information: 13.4.0 still of this issue

dominikzogg commented 1 year ago

Hello @ijjk

Do you have an idea what is missing there to get any feedback?

Regards Dominik

ebo-bpi commented 1 year ago

We seem to have this issue as well. so if you us a "yarn link" with nextjs you will get this error. no clue on how to solve this.

dominikzogg commented 1 year ago

@ebo-bpi cause i am using docker also on a local setup instead of symlinks i used docker mounts. Works but is a hack and breaks ide support cause your host system doesn't know about this references

ebo-bpi commented 1 year ago

@dominikzogg yep that could be a workaround also. I "fixed" it by importing the package by file path. just point it to the output dir of the remote package. only thing here is that you need to remove this from your package.json before pushing your code. Again also a workaround, but it won't stop me from moving at least. Would be nice if this could be solved anyway.

dominikzogg commented 1 year ago

@ebo-bpi i would already appreciate any response from the developers.