Hey Samir, the shopify team totally borked this one and have provided absolutely sub standard service when addressing them about the issue. The solution is below, update your vite.config with the commonJs transformations as such:
export default defineConfig({
root: dirname(fileURLToPath(import.meta.url)),
plugins: [react()],
define: {
"process.env.SHOPIFY_API_KEY": JSON.stringify(process.env.SHOPIFY_API_KEY),
},
// ADD THIS LINE TO CONVERT THE require()
build: {
commonjsOptions: {
transformMixedEsModules: true,
}
},
// END LINE
resolve: {
preserveSymlinks: true,
},
server: {
host: "localhost",
port: process.env.FRONTEND_PORT,
hmr: hmrConfig,
proxy: {
"^/(\\?.*)?$": proxyOptions,
"^/api(/|(\\?.*)?$)": proxyOptions,
"^/bundle/checkout(\\?.*)?$": proxyOptions,
},
},
});