graphql-js icon indicating copy to clipboard operation
graphql-js copied to clipboard

Error after upgrading from 16.6 to 16.8.1 with globalThis.process.env.NODE_ENV

Open DontRepeatYourself opened this issue 2 years ago • 12 comments

Running a project with Vue3 / Quasar2 / Vite in development mode fails after update.

// node_modules/graphql/jsutils/instanceOf.mjs
globalThis.process && globalThis.process.env.NODE_ENV === 'production'

is compiled to

var instanceOf = globalThis.process && globalThis."development" === "production" ? function instanceOf2(value, constructor) { ... }

Changing

globalThis.process && globalThis.process.env.NODE_ENV === 'production'

to

globalThis.process && globalThis.process.env['NODE_ENV'] === 'production'

solves the problem for me.

DontRepeatYourself avatar Oct 12 '23 06:10 DontRepeatYourself

Experiencing the same issue and this bug does not allow us to upgrade to the latest version and there's a security advisory for versions before 16.8.1: https://github.com/advisories/GHSA-9pv7-vfvm-6vr7

vdineva avatar Oct 12 '23 13:10 vdineva

Having the same bug. It resolves to globalThis."development" === 'production' or production and it breaks the app.

rafaelsorto avatar Oct 19 '23 18:10 rafaelsorto

Got the same issue when using the ReactJS framework, keeping graphql on 16.6.0 seems to be the solution for us for now.

MaLiN2223 avatar Oct 28 '23 07:10 MaLiN2223

Same issue here, with a Uncaught SyntaxError: missing name after . operator at runtime. React project compiled with Vite.

Any plans for a fix?

Thanks

TdyP avatar Dec 04 '23 09:12 TdyP

Just checking on the status of this issue. Is there a plan to address it and publish a new version? It's been open for a while now

vdineva avatar Jan 04 '24 17:01 vdineva

For anyone experiencing issues with v16.8.1, a workaround is to define globalThis.process.env.NODE_ENV in your bundler. For Webpack it's:

new DefinePlugin({
   "globalThis.process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV)
})

vdineva avatar Feb 12 '24 15:02 vdineva

see PR, this fixes the vue3, quasar, vite problem with graphql-js > 16.6

mobsean avatar Feb 13 '24 15:02 mobsean

Hey,

Would anyone mind posting a reproduction to this issue leveraging vite/webpack/.... Does upgrading resolve the issue?

JoviDeCroock avatar Feb 14 '24 14:02 JoviDeCroock

Hey,

Would anyone mind posting a reproduction to this issue leveraging vite/webpack/.... Does upgrading resolve the issue?

I checked your PR and fine with it. The problem in this issue is solved by this.

mobsean avatar Feb 15 '24 13:02 mobsean

Hey,

Would anyone mind posting a reproduction to this issue leveraging vite/webpack/.... Does upgrading resolve the issue?

Tested with vite and it works fine.

n05la3 avatar Feb 15 '24 13:02 n05la3

What did you test @n05la3 the PR or whether the issue is present 😅 we need versions/... actual reproductions or at the very least version numbers of where this issue shows itself

JoviDeCroock avatar Feb 15 '24 13:02 JoviDeCroock

I misread the comment. I experienced this issue in a Quasar 2.14.3 project with Vite 5.0.0 when upgrading from 16.6.0 to 16.8.1. I had used a patch to bypass this issue. Earlier today, I tested the changes in the PR in my project and it works fine.

n05la3 avatar Feb 15 '24 14:02 n05la3

Fixed with 16.8.2

DontRepeatYourself avatar Jun 13 '24 09:06 DontRepeatYourself