Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client-side JS fails to execute when using pnpm and importing react-dom on a page #20884

Closed
elliottsj opened this issue Jan 8, 2021 · 6 comments · Fixed by #21048
Closed
Labels
good first issue Easy to fix issues, good for newcomers
Milestone

Comments

@elliottsj
Copy link
Contributor

elliottsj commented Jan 8, 2021

What version of Next.js are you using?

10.0.6-canary.0

What version of Node.js are you using?

14.15.3

What browser are you using?

Edge (Chromium)

What operating system are you using?

macOS

How are you deploying your application?

next start

Describe the Bug

Client-side JS fails to execute in a specific scenario:

  • pnpm is used to install dependencies. (using version 5.15.1 as of this writing)
  • react-dom is imported in one page (about.js) but not in another page (index.js).

Expected Behavior

Client-side JS should execute when visiting the index page.

To Reproduce

Full repro: https://github.com/elliottsj/nextjs-pnpm-issue-2021-01-07

@elliottsj elliottsj added the bug Issue was opened via the bug report template. label Jan 8, 2021
@timneutkens timneutkens added good first issue Easy to fix issues, good for newcomers kind: bug and removed bug Issue was opened via the bug report template. labels Jan 11, 2021
@timneutkens timneutkens added this to the backlog milestone Jan 11, 2021
@Timer Timer removed this from the backlog milestone Jan 11, 2021
elliottsj added a commit to elliottsj/elliott.dev that referenced this issue Jan 16, 2021
elliottsj added a commit to elliottsj/elliott.dev that referenced this issue Jan 16, 2021
@elliottsj elliottsj changed the title Client-side JS fails to execute in a specific scenario using pnpm and react-modal Client-side JS fails to execute in a specific scenario using pnpm and react-dom Jan 17, 2021
@elliottsj
Copy link
Contributor Author

I've discovered that the problem isn't specifically with react-modal, but with react-dom in general. The problem manifests when importing react-modal since the react-modal package imports react-dom.

I've simplified the repro at nextjs-pnpm-issue-2021-01-07 accordingly.

@elliottsj elliottsj changed the title Client-side JS fails to execute in a specific scenario using pnpm and react-dom Client-side JS fails to execute when using pnpm and importing react-dom on a page Jan 17, 2021
@elliottsj
Copy link
Contributor Author

I'm working on a fix over at #21048. In the meantime, this is a workaround:

// next.config.js

module.exports = {
  webpack: (config) => {
    // Workaround for https://github.com/vercel/next.js/issues/20884
    config.optimization.splitChunks = false;

    return config;
  },
};

@timneutkens
Copy link
Member

To be clear disabling splitChunks is not an option if you are planning to deploy to production.

@Timer Timer added this to the backlog milestone Jan 19, 2021
@PabloSzx
Copy link
Contributor

Adding
import "react-dom";
in the _app seems to be a workaround that fixed it for my situation

@elliottsj
Copy link
Contributor Author

This issue is still a problem for pnpm users. I would appreciate if a maintainer could comment on #21048 when you have time.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Easy to fix issues, good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants