fix(table-core): guard process.env.NODE_ENV checks for bundler-less environments - #6567
Open
koreahghg wants to merge 1 commit into
Open
fix(table-core): guard process.env.NODE_ENV checks for bundler-less environments#6567koreahghg wants to merge 1 commit into
koreahghg wants to merge 1 commit into
Conversation
…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>
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Changes
Fixes #6078.
table-core's ~14 dev-only debug/validation checks readprocess.env.NODE_ENVdirectly. That raw read survives unguarded into the published ESM build (unbundle: true, nodefineintsdown.config.ts), so any environment with noprocessglobal — vanilla JS loaded via an import map, or any other bundler-less/non-Node setup — throwsReferenceError: process is not definedthe moment one of these checks runs (e.g. simply constructing a table withdebugTable: true).Added a single
isDevelopmentEnv()helper inutils.tsthat checkstypeof process !== 'undefined'before readingprocess.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.envreference left indist/utils.jsis the guarded one insideisDevelopmentEnv().✅ Checklist
pnpm run test:pr(ran the equivalent steps directly:vitest runfor@tanstack/table-core— 1275/1275 passing, including new regression tests — plustsc --noEmit,eslint, and atsdownbuild; the fullnx affectedpipeline timed out locally on an unrelatedtest:sherif/test:knippass over the whole workspace).🚀 Release Impact