Skip to content

Commit 0d7e5e5

Browse files
committed
[SDK] Fix: Process undefined checks in vite (#7844)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR addresses the resolution of the SDK in environments where `process` is undefined, ensuring that the checks for development and test environments are more robust. ### Detailed summary - Updated the `IS_DEV` constant to check if `process` is defined before accessing its properties. - Modified the `IS_TEST` constant similarly to ensure it only evaluates when `process` is defined. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Guarded environment checks to avoid runtime errors where Node globals are absent, improving stability across browsers, serverless, and edge runtimes. * More reliable detection of development and test modes, reducing unexpected crashes during bundling, CI testing, and client-side use. * **Chores** * Added release metadata so the fix will be published as a patch. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 8665e8f commit 0d7e5e5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.changeset/fine-zoos-own.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Fix SDK resolution in environements where process is undefined
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
// You must use typeof process !== "undefined" instead of just "process"
12
export const IS_DEV =
2-
process &&
3+
typeof process !== "undefined" &&
4+
process.env &&
35
(process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test");
46

5-
export const IS_TEST = process && process.env.NODE_ENV === "test";
7+
export const IS_TEST =
8+
typeof process !== "undefined" &&
9+
process.env &&
10+
process.env.NODE_ENV === "test";

0 commit comments

Comments
 (0)