Skip to content

Conversation

@obadakhalili
Copy link

when running the devtools bin with bun using bunx --bun devtools in user's codebase, the lib doesn't work properly and runs in dev mode for the user if they have a .env file with the value NODE_ENV set to development because bun auto loads the user's vars from the .env file. I don't think its wise to use environment variables in libraries' code because users' environments can affect the runtime behaviour, especially so for popular runtime variables such as NODE_ENV.

I also noticed that the devToolsMiddleware function also uses NODE_ENV to throw an error if the user using this in production. i think the same reasoning against env vars in libraries' code applies again, but its less harmful here.

I checked that this fix works but pointing to the local build for the devtools code from my own project where i encountered the code and made sure that bunx --bun devtools works (not in dev mode) even if i have a .env file with NODE_ENV set to development.

Checklist

  • Tests have been added / updated (for bug fixes / features)
  • Documentation has been added / updated (for bug fixes / features)
  • A patch changeset for relevant packages has been added (for bug fixes / features - run pnpm changeset in the project root)
  • I have reviewed this pull request (self-review)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant