{{ message }}
fix(table-core): guard process.env checks for non-bundled environments#6185
Open
isaackaara wants to merge 2 commits intoTanStack:mainfrom
Open
fix(table-core): guard process.env checks for non-bundled environments#6185isaackaara wants to merge 2 commits intoTanStack:mainfrom
isaackaara wants to merge 2 commits intoTanStack:mainfrom
Conversation
Replaces direct `process.env.NODE_ENV` references with a safe `isDev()` utility that checks for the existence of `process` before accessing it. This prevents `ReferenceError: process is not defined` when using @tanstack/table-core in vanilla JS environments loaded via importmaps (e.g. Rails) without a bundler. The built ESM output preserved raw `process.env.NODE_ENV` references which would throw in environments where `process` is not globally defined. Closes TanStack#6078
Contributor
2 tasks
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.

Problem
When using
@tanstack/table-corein vanilla JS without a bundler (e.g., via ES module importmaps in Rails), aReferenceError: process is not definedis thrown because the source code contains rawprocess.env.NODE_ENVreferences.As reported in #6078, the ESM build output preserves these references without any transformation, and environments without Node.js globals (browser ESM via importmaps, Deno, etc.) crash on them.
Root Cause
The source code directly accesses
process.env.NODE_ENVfor development-only warnings and debug logging. While bundlers like Vite/Webpack replace these at build time, the published ESM output retains them as-is, causing errors in unbundled environments.Fix
Introduced a
isDev()utility function that safely checks for the existence ofprocessbefore accessingprocess.env.NODE_ENV:Replaced all direct
process.env.NODE_ENVchecks acrosstable-corewith calls toisDev().Files changed:
packages/table-core/src/utils.ts— AddedisDev()utilitypackages/table-core/src/core/column.ts— 2 occurrencespackages/table-core/src/core/table.ts— 3 occurrencespackages/table-core/src/utils/getFilteredRowModel.ts— 1 occurrenceCloses #6078