Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

__DEV__ logic is now ‘NODE_ENV is not production’ #2907

Merged

Conversation

steveluscher
Copy link
Contributor

Summary

A few folks have been caught out not having any setting for NODE_ENV. In cases like this, the __DEV__ flag will be false because NODE_ENV is not 'development'.

It would be preferable for development to be the default when there is no NODE_ENV. This means it will be harder to get ‘into’ production mode (you have to set an env variable) but it will mean that people fall into the pit of success when debug functionality is what they're looking for.

Test Plan

pnpm i
pnpm turbo compile:js

Observe that all of the __DEV__ constants have been replaced with process.env.NODE_ENV !== 'production'

Copy link

changeset-bot bot commented Jul 3, 2024

🦋 Changeset detected

Latest commit: b9f7231

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

This PR includes changesets to release 37 packages
Name Type
@solana/errors Patch
@solana/rpc Patch
@solana/rpc-subscriptions Patch
@solana/rpc-subscriptions-transport-websocket Patch
@solana/rpc-transport-http Patch
@solana/webcrypto-ed25519-polyfill Patch
@solana/accounts Patch
@solana/addresses Patch
@solana/assertions Patch
@solana/codecs-core Patch
@solana/codecs-data-structures Patch
@solana/codecs-numbers Patch
@solana/codecs-strings Patch
@solana/compat Patch
@solana/instructions Patch
@solana/keys Patch
@solana/web3.js-experimental Patch
@solana/options Patch
@solana/programs Patch
@solana/react Patch
@solana/rpc-api Patch
@solana/rpc-spec Patch
@solana/rpc-subscriptions-spec Patch
@solana/rpc-types Patch
@solana/signers Patch
@solana/sysvars Patch
@solana/transaction-confirmation Patch
@solana/transaction-messages Patch
@solana/transactions Patch
@solana/rpc-graphql Patch
@solana/rpc-subscriptions-api Patch
@solana/rpc-parsed-types Patch
@solana/codecs Patch
@solana/rpc-transformers Patch
@solana/fast-stable-stringify Patch
@solana/functional Patch
@solana/rpc-spec-types Patch

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

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @steveluscher and the rest of your teammates on Graphite Graphite

Copy link
Contributor Author

cc/ @Jac0xb

@steveluscher steveluscher force-pushed the 07-03-___dev___logic_is_now_node_env_is_not_production_ branch from 626886e to c1f70fe Compare July 3, 2024 06:20
@steveluscher
Copy link
Contributor Author

This mirrors, for instance, React's behaviour. Their library uses process.env.NODE_ENV === 'production' to kick it into production mode.

@steveluscher steveluscher force-pushed the 07-03-___dev___logic_is_now_node_env_is_not_production_ branch from c1f70fe to d90c030 Compare July 3, 2024 06:33
Copy link
Contributor

@mcintyre94 mcintyre94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

await expect(subscribePromise).rejects.toThrow(new SolanaError(123 as SolanaErrorCode, undefined));
await expect(subscribePromise).rejects.toThrow(
new SolanaError(SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED),
);
Copy link
Contributor

@mcintyre94 mcintyre94 Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI error seems to be related to the changes in this file - are they intended to be in this PR at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. This change was supposed to fix a test failure owing to the fact that error 123 doesn’t exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it’s lint I left behind.

Maybe I’ll try to do this properly with mocks this time.

Copy link
Contributor

@lorisleiva lorisleiva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I'll make sure I replicate on Kinobi when I'm out of this documentation hole.

@steveluscher steveluscher force-pushed the 07-03-___dev___logic_is_now_node_env_is_not_production_ branch from d90c030 to b9f7231 Compare July 3, 2024 17:06
@steveluscher steveluscher merged commit 677a9c4 into master Jul 3, 2024
8 checks passed
@steveluscher steveluscher deleted the 07-03-___dev___logic_is_now_node_env_is_not_production_ branch July 3, 2024 17:19
@github-actions github-actions bot mentioned this pull request Jul 3, 2024
Copy link
Contributor

github-actions bot commented Jul 8, 2024

🎉 This PR is included in version 1.95.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Contributor

Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants