Skip to content

graphql-js v16.7.0 breaks the compilation of SvelteKit #3920

Closed
@huth-pesser

Description

@huth-pesser

I use graphql-js in a webapp using SvelteKit. After updating from version 16.6.0 to version 16.7.0 my app does not work anymore.

As far as I analyzed this correctly, the problem seems to be the change in src/jsutils/instanceOf.ts

from

  process.env.NODE_ENV === 'production'

to

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

SvelteKit seems to replace env.NODE_ENV by the string "development" or "production" on compiling the sources and that ends up in the following invalid code

var instanceOf = (
  /* c8 ignore next 6 */
  // FIXME: https://github.com/graphql/graphql-js/issues/2317
  ((_globalThis$process = globalThis.process) === null || _globalThis$process === void 0 ? void 0 : _globalThis$"development") === "production" ? function instanceOf2(value, constructor) {
...

the old version of instanceOf lead to this code

var instanceOf = (
  /* c8 ignore next 6 */
  // FIXME: https://github.com/graphql/graphql-js/issues/2317
  // eslint-disable-next-line no-undef
  false ? function instanceOf2(value, constructor) {
...

I don't know why this change was made so unfortunatly I don't really know how to fix this the best way. In my opionen it would by nice, if this part could be reversed to this old implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions