Skip to content

Commit 6108ae7

Browse files
committed
instanceOf: workaround bundler issue with process.env
Fixes: #3919 #3920 #3921 Context: #3887 changed code and introced optinal chaining. `globalThis.process?.env.NODE_ENV` is transpiled into ``` (_globalThis$process = globalThis.process) === null || _globalThis$process === void 0 ? void 0 : _globalThis$process.env.NODE_ENV; ``` Bundlers incorrectly replace (probably RegExp) `process.env.NODE_ENV` with `"development"` resulting in: ``` (_globalThis$process = globalThis.process) === null || _globalThis$process === void 0 ? void 0 : _globalThis$"development"; ``` Technically it's not a graphql issue but an issue with bundler but since it caused so much pain in comutinity this is an attempt to fix it within our codebase.
1 parent 1519fda commit 6108ae7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/jsutils/instanceOf.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { inspect } from './inspect';
99
export const instanceOf: (value: unknown, constructor: Constructor) => boolean =
1010
/* c8 ignore next 6 */
1111
// FIXME: https://github.com/graphql/graphql-js/issues/2317
12-
globalThis.process?.env.NODE_ENV === 'production'
12+
globalThis.process && globalThis.process.env.NODE_ENV === 'production'
1313
? function instanceOf(value: unknown, constructor: Constructor): boolean {
1414
return value instanceof constructor;
1515
}

0 commit comments

Comments
 (0)