-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[3.0-beta] Uncaught ReferenceError: require is not defined #6035
Comments
ashubham
changed the title
Uncaught ReferenceError: require is not defined
[3.0-beta] Uncaught ReferenceError: require is not defined
Mar 9, 2020
hwillson
added a commit
that referenced
this issue
May 29, 2020
to help prevent modern bundlers from requiring React when used with `@apollo/client/core` (in other words, without any of Apollo Client's React components). While this approach works well for applications that aren't using React, it introduces problems for bundlers and applications that are using React (as outlined in #6035 and #6352). There are several different ways we can address this, and we might do something more substantial in the future, but for now this commit manipulates Apollo Client's core CJS bundle at build time, to make the React require optional. Fixes #6035. Fixes #6352.
hwillson
added a commit
that referenced
this issue
May 29, 2020
PR #5577 introduced a new way of lazily loading React to help prevent modern bundlers from requiring React when used with `@apollo/client/core` (in other words, without any of Apollo Client's React components). While this approach works well for applications that aren't using React, it introduces problems for bundlers and applications that are using React (as outlined in #6035 and #6352). There are several different ways we can address this, and we might do something more substantial in the future, but for now this commit manipulates Apollo Client's core CJS bundle at build time, to make the React require optional. Fixes #6035. Fixes #6352.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Trying to use
apollo-client
with react using rollup.Intended outcome:
Apollo client should bundle and load.
Actual outcome:
The loading fails at runtime with
Uncaught ReferenceError: require is not defined
.This is due to
apollo-client/src/react/react.ts
Line 8 in 23b17fa
It might be better to use
import
instead ofrequire
.How to reproduce the issue:
Use rollup for building the app (using apollo-client/react).
PS: Set the output format to
es
. (Fails with 'cjs' too)Versions
Apollo-client: 3.0-beta.38 (React)
The text was updated successfully, but these errors were encountered: