-
Notifications
You must be signed in to change notification settings - Fork 2k
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
process.env.NODE_ENV reference causes error "require is not defined" when bundling with webpack (for GraphiQL) #1536
Comments
I think you can solve that just adding more extensions to your webpack rules:
|
@jgcmarins to what rule? |
on your |
I understand that you mean my webpack config. But there are many rules defined in there (for loaders), and none of them seem related to providing |
same error here is my yarn.lock and package.json gist |
@xialvjun You use |
Should be fixed in |
When bundling graphql-js with webpack, e.g. as dependency of graphiql, you get this error at runtime:
This is because
instanceOf.js
contains a reference toprocess.env
: https://github.com/graphql/graphql-js/blob/dec24f9/src/jsutils/instanceOf.js#L19-L36In the ESM build, which is used by webpack by following the
module
field in package.json, the file gets compiled to a.mjs
file, which does not get applied the webpackProvidePlugin
, see webpack/webpack#7032.This makes it impossible to bundle
graphiql
with webpack.The text was updated successfully, but these errors were encountered: