Skip to content

fix(table-core): guard process.env.NODE_ENV checks for bundler-less environments - #6567

Open
koreahghg wants to merge 1 commit into
TanStack:betafrom
koreahghg:feat-guard-process-env-checks
Open

fix(table-core): guard process.env.NODE_ENV checks for bundler-less environments#6567
koreahghg wants to merge 1 commit into
TanStack:betafrom
koreahghg:feat-guard-process-env-checks

Conversation

@koreahghg

Copy link
Copy Markdown
Contributor

🎯 Changes

Fixes #6078.

table-core's ~14 dev-only debug/validation checks read process.env.NODE_ENV directly. That raw read survives unguarded into the published ESM build (unbundle: true, no define in tsdown.config.ts), so any environment with no process global — vanilla JS loaded via an import map, or any other bundler-less/non-Node setup — throws ReferenceError: process is not defined the moment one of these checks runs (e.g. simply constructing a table with debugTable: true).

Added a single isDevelopmentEnv() helper in utils.ts that checks typeof process !== 'undefined' before reading process.env.NODE_ENV, and routed all 14 call sites through it. Behavior is otherwise unchanged — still === 'development', not flipped to !== 'production' (that was the debated part of the related draft PR #6445, which is why it's stuck; this PR intentionally only fixes the crash and leaves that semantic question alone).

Verified the fix actually reaches the published artifact: after building, the only process.env reference left in dist/utils.js is the guarded one inside isDevelopmentEnv().

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr (ran the equivalent steps directly: vitest run for @tanstack/table-core — 1275/1275 passing, including new regression tests — plus tsc --noEmit, eslint, and a tsdown build; the full nx affected pipeline timed out locally on an unrelated test:sherif/test:knip pass over the whole workspace).

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

…nvironments

Raw process.env.NODE_ENV reads in ~14 dev-only debug/validation checks
survive unguarded into the published ESM build. Any environment with no
process global (e.g. vanilla JS loaded via an import map, no bundler or
Node.js runtime) throws ReferenceError: process is not defined the first
time one of these checks runs (GH TanStack#6078).

Add a shared isDevelopmentEnv() helper that checks typeof process first,
and route every call site through it. Behavior/semantics are unchanged
(still === 'development', not flipped to !== 'production').

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: bf13db6e-552a-4a36-996a-dc754fec8a66

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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