Skip to content

fix(table-core): guard process.env checks for non-bundled environments#6185

Open
isaackaara wants to merge 2 commits intoTanStack:mainfrom
isaackaara:fix/process-not-defined-vanilla-js
Open

fix(table-core): guard process.env checks for non-bundled environments#6185
isaackaara wants to merge 2 commits intoTanStack:mainfrom
isaackaara:fix/process-not-defined-vanilla-js

Conversation

@isaackaara
Copy link

Problem

When using @tanstack/table-core in vanilla JS without a bundler (e.g., via ES module importmaps in Rails), a ReferenceError: process is not defined is thrown because the source code contains raw process.env.NODE_ENV references.

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_ENV for 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 of process before accessing process.env.NODE_ENV:

export function isDev(): boolean {
  return (
    typeof process !== 'undefined' &&
    process.env?.NODE_ENV !== 'production'
  )
}

Replaced all direct process.env.NODE_ENV checks across table-core with calls to isDev().

Files changed:

  • packages/table-core/src/utils.ts — Added isDev() utility
  • packages/table-core/src/core/column.ts — 2 occurrences
  • packages/table-core/src/core/table.ts — 3 occurrences
  • packages/table-core/src/utils/getFilteredRowModel.ts — 1 occurrence

Closes #6078

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
@changeset-bot
Copy link

changeset-bot bot commented Mar 4, 2026

🦋 Changeset detected

Latest commit: b170475

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@tanstack/table-core Patch
@tanstack/angular-table Patch
@tanstack/lit-table Patch
@tanstack/qwik-table Patch
@tanstack/react-table Patch
@tanstack/solid-table Patch
@tanstack/svelte-table Patch
@tanstack/vue-table Patch
@tanstack/react-table-devtools Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

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

Run ID: f0ac146f-7629-4dbe-beeb-2df3c1ff0228

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
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

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