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

Import @apollo/client/core unnecessarily require react #8809

Closed
ianhe8x opened this issue Sep 18, 2021 · 10 comments · Fixed by #8817
Closed

Import @apollo/client/core unnecessarily require react #8809

ianhe8x opened this issue Sep 18, 2021 · 10 comments · Fixed by #8817

Comments

@ianhe8x
Copy link

ianhe8x commented Sep 18, 2021

Intended outcome:
Doesn't need to have react installed when only @apollo/client/core is used. It was fine at v3.4.9.

Actual outcome:
panic because I don't have react.

How to reproduce the issue:
use latest version 3.4.12 and use ApolloClient without react in package.json

Versions
System:
OS: macOS 11.5.2
Binaries:
Node: 14.15.2 - ~/.nvm/versions/node/v14.15.2/bin/node
Yarn: 1.22.5 - ~/.yarn/bin/yarn
npm: 7.6.3 - /usr/local/bin/npm
Browsers:
Chrome: 93.0.4577.63
Edge: 93.0.961.44
Firefox: 91.1.0
Safari: 14.1.2

** clues **
in @apollo/client/utilities/utilities.cjs.js, in v3.4.12 there's var __ = require('..'); which not exists in v3.4.9

** error stack **

internal/modules/cjs/loader.js:883
  throw err;
  ^

Error: Cannot find module 'react'
Require stack:
- /usr/local/lib/node_modules/---/node_modules/@apollo/client/react/context/context.cjs.js
- /usr/local/lib/node_modules/---/node_modules/@apollo/client/react/react.cjs.js
- /usr/local/lib/node_modules/---/node_modules/@apollo/client/main.cjs.js
- /usr/local/lib/node_modules/---/node_modules/@apollo/client/utilities/utilities.cjs.js
- /usr/local/lib/node_modules/---/node_modules/@apollo/client/link/core/core.cjs.js
- /usr/local/lib/node_modules/---/node_modules/@apollo/client/core/core.cjs.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/---/node_modules/@apollo/client/react/context/context.cjs.js:6:13)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)

@junya100
Copy link

Same here.

@luudv
Copy link

luudv commented Sep 19, 2021

I get the same problem.

@jcslynn
Copy link

jcslynn commented Sep 19, 2021

I have this same issue too. Didn't have a problem 2 days ago before the new release.
Tried v3.4.11 just to double check and it seems like this was introduced with v3.4.12

@korbav
Copy link

korbav commented Sep 19, 2021

Same from my side, I do confirm the regression's been introduced in the latest release.
v3.4.11 works flawlessly.

@Yohandah
Copy link

Got the same issue; no issue in v3.4.11 but error in v3.4.12 .....

Waiting for React to be removed with v4 #7318

@benjamn benjamn self-assigned this Sep 20, 2021
@benjamn benjamn added this to the v3.4.x patch releases milestone Sep 20, 2021
benjamn added a commit that referenced this issue Sep 20, 2021
May fix #8809, since this line could explain the appearance of
`require('..')` in `@apollo/client@3.4.12`, as noticed by @ianhe8x.

Both styles of import _should_ work, but we can be more explicit/precise
when the import does not cross entry points.
schw4rzlicht added a commit to LOUD-GmbH/diggithy-sdk that referenced this issue Sep 20, 2021
@benjamn benjamn reopened this Sep 20, 2021
@benjamn
Copy link
Member

benjamn commented Sep 20, 2021

Sorry for the auto-close. We'll close this after confirming the next @apollo/client version works for everyone.

@korbav
Copy link

korbav commented Sep 20, 2021

Sorry for the auto-close. We'll close this after confirming the next @apollo/client version works for everyone.

Successfully tested for me. Thanks for the reactivity!

@benjamn
Copy link
Member

benjamn commented Sep 20, 2021

Thanks for the update @korbav!

@ianhe8x and others, please give @apollo/client@3.4.13 (which includes #8817) a try when you have a chance. 🙏

@schw4rzlicht
Copy link

@benjamn 3.4.13 fixes the issue for me, thanks! 🎉

@benjamn
Copy link
Member

benjamn commented Sep 21, 2021

Closing based on multiple confirmations, but of course we're happy to reopen if @ianhe8x is still having problems. Thanks everyone!

@benjamn benjamn closed this as completed Sep 21, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.