Skip to content
Source
Sign inSign up
TanStack/table

perf: compute NODE_ENV up-front & flip opt-in #6445

Closed43081j(GitHub profile, opens in a new tab)wants to merge 1 commit intobeta fromrefs/pull/6445/headopened

Showing 13 changed files with 10 additions and 4 deletions (loading 10).

x
0 of 13 viewed, 13 left
4 additions and 2 deletionspackages/table-core/src/core/columns/constructColumn.tsModified
View file
@@ -10,6 +10,8 @@
import type { Column } from '../../types/Column'
import type { Column_CoreProperties } from './coreColumnsFeature.types'
​
+const IS_DEV = process.env.NODE_ENV !== 'production'
+​
/**
* Creates or retrieves the column prototype for a table.
* The prototype is cached on the table and shared by all column instances.
@@ -75,7 +77,7 @@
for (let i = 0; i < keys.length; i++) {
const key = keys[i]!
result = result?.[key]
- if (process.env.NODE_ENV === 'development' && result === undefined) {
+ if (IS_DEV && result === undefined) {
console.warn(
`"${key}" in deeply nested key "${accessorKey}" returned undefined.`,
@@ -91,7 +93,7 @@
​
if (!id) {
- if (process.env.NODE_ENV === 'development') {
+ if (IS_DEV) {
throw new Error(
resolvedColumnDef.accessorFn
? `coreColumnsFeature require an id when using an accessorFn`