refinedev / refine

A React Framework for building internal tools, admin panels, dashboards & B2B apps with unmatched flexibility.
https://refine.dev
MIT License
25.95k stars 1.96k forks source link

[BUG] fix(devtools-internal): fix NODE_ENV conditional didn't work #6030

Open sanchezcarlosjr opened 3 weeks ago

sanchezcarlosjr commented 3 weeks ago

Describe the bug

Hello, @aliemir published the PR https://github.com/refinedev/refine/pull/5992 and it works. However, esbuild doesn't compile as expected. The compiler doesn't generate correctly as you write here https://github.com/refinedev/refine/blob/4654353b90b6a09cbf65e41d4c1fa82553a2a3fa/packages/devtools-internal/src/use-query-subscription.tsx#L13 So, instead of

() => {
        return {};
      }

it generates

() => ({})

Steps To Reproduce

  1. Install @refinedev/devtools-internal or visit the link @refinedev/devtools-internal npm package code tab
  2. Check the below expression in index.cjs and index.mjs.
    process.env.NODE_ENV!=="development" ? ()=>({})  : ...

Expected behavior

The below expression

process.env.NODE_ENV!=="development" ? ()=>({}): ...

must be something similar to

process.env.NODE_ENV!=="development" ? ()=> {
   return {};
}: ...

Probably adding a noop function helps.

const noop = () => {
   return {};
}

process.env.NODE_ENV!=="development" ? noop: ...

Packages

Additional Context

No response

aliemir commented 3 weeks ago

Hey @sanchezcarlosjr, thank you for explaining the issue here! 🙏 Did you encounter this issue while working with React Native or is there any other platform that has issues with parsing those lines? 🤔

sanchezcarlosjr commented 3 weeks ago

Thank you for your answer, @aliemir. I'm working with traditional React web apps, and Refine works as expected. The issue only occurs in React Native as far as I know.