clerk / javascript

Official Javascript repository for Clerk authentication
https://clerk.com
MIT License
1.04k stars 235 forks source link

"global" is not defined in vite and not browser friendly. #1031

Closed mind0bender closed 1 year ago

mind0bender commented 1 year ago

Package + Version

Dependencies + versions

Provide a json with the dependencies used in your project (copy paste from yarn.lock / package-lock.json) or a github project / template that reproduces the issue.

*Include the @clerk/ packages and their versions!**

Example:

"dependencies": {
    "@clerk/clerk-react": "^4.14.1",
    "@clerk/themes": "^1.5.1",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.10.0"
  },
  "devDependencies": {
    "@types/node": "^18.15.11",
    "@types/react": "^18.0.28",
    "@types/react-dom": "^18.0.11",
    "@types/react-router-dom": "^5.3.3",
    "@vitejs/plugin-react-swc": "^3.0.0",
    "autoprefixer": "^10.4.14",
    "postcss": "^8.4.21",
    "tailwindcss": "^3.3.1",
    "typescript": "^4.9.3",
    "vite": "^4.2.0"
  }

Browser/OS

If applicable e.g. Chrome {version}, Node {version} , Bun {version} , Cloudflare worker {version}

Description

Describe your issue in detail, a demo repository or a sandbox would be great.

"global" is not defined in vite's development environment(yarn dev). my vite app(react with ts + SWC) throws an error saying

isomorphicClerk.js:494 Uncaught (in promise) Error: Failed to download latest ClerkJS. Contact support@clerk.com. at IsomorphicClerk.loadClerkJS (isomorphicClerk.js:494:27)

For some reason it works fine on a production build(yarn preview)

nikosdouvlis commented 1 year ago

Hello @mind0bender, thanks for the report. This is fixed in @clerk/clerk-react@4.14.2, more details can be found in https://github.com/clerkinc/javascript/issues/1027

Closing this one but feel free to reopen if you hit any issues :)