I’m developing a Svelte application using TypeScript and have integrated Web3Auth (version 7.2.0) for authentication with the Solana blockchain. I am encountering an issue during the build process specifically related to importing named exports from the ‘@web3auth/base’ module. The application builds and runs fine on localhost, but I face this problem when building for production.
Here are the details:
-
SDK Version: @web3auth/base 7.2.0
-
Platform: Building on macOS
-
Node.js Version: v20.10.0
-
Error Description: When building the application, I receive a
SyntaxError
related to the import ofCHAIN_NAMESPACES
from ‘@web3auth/base’. The error message indicates that the module is a CommonJS module and may not support all module.exports as named exports. The specific error is:SyntaxError: Named export 'CHAIN_NAMESPACES' not found. The requested module '@web3auth/base' is a CommonJS module, which may not support all module.exports as named exports.
-
Web3Auth Initialization Code:
import { Web3Auth } from "@web3auth/modal"; import { CHAIN_NAMESPACES } from "@web3auth/base"; import { SolanaPrivateKeyProvider } from "@web3auth/solana-provider"; import { OpenloginAdapter } from "@web3auth/openlogin-adapter"; export const chainConfig = { chainNamespace: CHAIN_NAMESPACES.SOLANA, chainId: "0x3", // Mainnet rpcTarget: "https://summer-frosty-friday.solana-devnet.quiknode.pro/5430f85cfb9a90ac2763131b24d8a746f2d18825", displayName: "Sapphire Devnet", blockExplorer: "https://explorer.solana.com", ticker: "SOL", tickerName: "Solana", };
Could you please help me understand why this issue is occurring and how I can resolve it? Are there specific configurations or changes required in the Svelte TypeScript setup to correctly handle CommonJS modules or any additional steps to ensure compatibility with Web3Auth’s latest version?
Thank you for your assistance.