From ceba6835dd60896efc34fe1495a1812c0cc39db7 Mon Sep 17 00:00:00 2001 From: MananTank Date: Mon, 20 Oct 2025 13:55:09 +0000 Subject: [PATCH] SDK: Fix process not defined error in Vite (#8280) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ## PR-Codex overview This PR addresses a `process not defined` error that occurs when using the `thirdweb/contract` import in Vite by ensuring that the `process` variable is only accessed when it is defined. ### Detailed summary - Updated `PUBLISHED_PRIVATE_KEY` export in `packages/thirdweb/src/utils/any-evm/zksync/constants.ts` to check if `process` is defined before accessing `process.env.ZKSYNC_PUBLISHED_PRIVATE_KEY`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` ## Summary by CodeRabbit - **Chores** - Improved robustness of environment configuration handling to avoid runtime issues in non-Node environments. - **Bug Fixes** - Fixed a "process not defined" error that could occur when importing the library in Vite, included in a patch release. --- .changeset/small-taxes-heal.md | 5 +++++ packages/thirdweb/src/utils/any-evm/zksync/constants.ts | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 .changeset/small-taxes-heal.md diff --git a/.changeset/small-taxes-heal.md b/.changeset/small-taxes-heal.md new file mode 100644 index 00000000000..aad6d1fc270 --- /dev/null +++ b/.changeset/small-taxes-heal.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +Fix process not defined error when using "thirdweb/contract" import in Vite diff --git a/packages/thirdweb/src/utils/any-evm/zksync/constants.ts b/packages/thirdweb/src/utils/any-evm/zksync/constants.ts index b980b009b54..074c580eb6e 100644 --- a/packages/thirdweb/src/utils/any-evm/zksync/constants.ts +++ b/packages/thirdweb/src/utils/any-evm/zksync/constants.ts @@ -3,9 +3,10 @@ export const ZKSYNC_SINGLETON_FACTORY = export const CONTRACT_DEPLOYER_ADDRESS = "0x0000000000000000000000000000000000008006" as const; export const KNOWN_CODES_STORAGE = "0x0000000000000000000000000000000000008004"; -export const PUBLISHED_PRIVATE_KEY = process - ? process.env.ZKSYNC_PUBLISHED_PRIVATE_KEY - : undefined; +export const PUBLISHED_PRIVATE_KEY = + typeof process !== "undefined" && process && process.env + ? process.env.ZKSYNC_PUBLISHED_PRIVATE_KEY + : undefined; export const singletonFactoryAbi = [ "function deploy(bytes32,bytes32,bytes) external payable",