Skip to content
Source
Sign inSign up
TanStack/table

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

Closedisaackaara(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/6185/headopened

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

    1. changeset-bot[bot](GitHub profile, opens in a new tab)commented

      🦋 Changeset detected

      Latest commit: b170475cdef8189cb52ac741d9de9a5b72c327c5

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

      This PR includes changesets to release 9 packages
      NameType
      @tanstack/table-corePatch
      @tanstack/angular-tablePatch
      @tanstack/lit-tablePatch
      @tanstack/qwik-tablePatch
      @tanstack/react-tablePatch
      @tanstack/solid-tablePatch
      @tanstack/svelte-tablePatch
      @tanstack/vue-tablePatch
      @tanstack/react-table-devtoolsPatch

      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

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      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.
    3. KevinVandy closed this

Sign in to join this conversation.