Skip to content

use enableDevMode() or development condition instead of NODE_ENV #4464

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

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

yaacovCR
Copy link
Contributor

@yaacovCR yaacovCR commented Jul 29, 2025

extracted from / based on:

Motivation:

This makes our build product cross-platform by dropping all Node.js specific code.

Differences:

  • the old PR drops esm support, this PR does not
  • the old PR uses import 'graphql/dev' to enable development mode on platforms that do not support setting custom conditions, while this PR uses: import { enableDevMode } from 'graphql'; enableDevMode()

From the docs included in this PR:

In development mode, GraphQL.JS can provides additional runtime check appropriate for development-time errors, including primarily the erroneous inclusion of multiple GraphQL.JS modules.

Unlike earlier versions of GraphQL.JS, by default, development mode is disabled. This is to best ensure that production builds do not incur the performance and bundle size penalties associated with the additional checks.

Also, unlike earlier versions, development mode is not configured by use of environment variables, which are accessed in disparate ways on the various platforms. In particular, the NODE_ENV environment variable now has no effect on triggering development mode. Rather, development mode is either enabled:

  1. explicitly, by calling enableDevMode() or
  2. implicitly, by setting the 'development' condition, which is possible only on platforms that support package.json conditional exports and custom conditions.

Conditional exports are supported by: Node.js, Deno (canary), Bun, Webpack 5, Rspack, Rollup (via the node-resolve plugin), esbuild, Vite, and Rsbuild. create-react-app and Next.js support conditional exports when using Webpack 5 as their bundler.

Conditional exports are not supported by Deno (current), Webpack 4, Rollup (without the node-resolve plugin), or swc. create-react-app and Next.js do not support conditional exports when using Webpack 4 as their bundler, nor does Next.js yet
support conditional exports when using Turbopack (see vercel/next.js#78912).

We encourage enabling development mode in a development environment, either explicitly or implicitly. This allows for an additional check to ensure that only a single GraphQL.JS module is used. Additional development-time checks may also be added in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant