Skip to content
Source
Sign inSign up
TanStack/table

fix(table-core): guard dev-only process.env reads #6591

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

Showing 12 changed files with 19 additions and 3 deletions (loading 9).

x
0 of 12 viewed, 12 left
5 additions and 0 deletions.changeset/guard-process-global.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/table-core': patch
+---
+​
+Guard the dev-only `process.env.NODE_ENV` checks with `typeof process !== 'undefined'` so the published ESM build runs in environments without a `process` global, such as browsers loading the package through an import map.
9 additions and 2 deletionspackages/table-core/src/core/columns/constructColumn.tsModified
View file
@@ -74,7 +74,11 @@
for (let i = 0; i < keys.length; i++) {
const key = keys[i]!
result = result?.[key]
- if (process.env.NODE_ENV === 'development' && result === undefined) {
+ if (
+ typeof process !== 'undefined' &&
+ process.env.NODE_ENV === 'development' &&
+ result === undefined
+ ) {
console.warn(
`"${key}" in deeply nested key "${accessorKey}" returned undefined.`,
@@ -90,7 +94,10 @@
​
if (!id) {
- if (process.env.NODE_ENV === 'development') {
+ if (
+ typeof process !== 'undefined' &&
+ process.env.NODE_ENV === 'development'