Skip to content

Commit

Permalink
chore(deps): Use crypto.randomUUID() instead of uuid module
Browse files Browse the repository at this point in the history
The `crypto` global is available in all supported Node.js versions as well as [in all major browsers](https://caniuse.com/mdn-api_crypto_randomuuid).
The uuid module is rendered unnecessary for uuidv4.

`@react-three/drei` is currently downloaded about 253000 times per week, so about 13409000 times per year.
`uuid@9` is about 3.7 kB in size (gzipped+minified). Removing this dependency saves about 50GB traffic per year.
  • Loading branch information
nikeee committed Dec 5, 2024
1 parent 75260b8 commit 094a693
Show file tree
Hide file tree
Showing 3 changed files with 8,522 additions and 13,356 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"troika-three-text": "^0.52.0",
"tunnel-rat": "^0.1.2",
"utility-types": "^3.11.0",
"uuid": "^9.0.1",
"zustand": "^5.0.1"
},
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions src/core/Cloud.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from 'three'
import { MaterialNode, extend, applyProps, useFrame, ReactThreeFiber } from '@react-three/fiber'
import { useTexture } from './Texture'
import { v4 } from 'uuid'
import { setUpdateRange } from '../helpers/deprecated'

declare global {
Expand Down Expand Up @@ -246,7 +245,7 @@ export const CloudInstance = /* @__PURE__ */ React.forwardRef<Group, CloudProps>

const parent = React.useContext(context)
const ref = React.useRef<Group>(null!)
const [uuid] = React.useState(() => v4())
const [uuid] = React.useState(() => crypto.randomUUID())
const clouds: CloudState[] = React.useMemo(() => {
return [...new Array(segments)].map(
(_, index) =>
Expand Down
Loading

0 comments on commit 094a693

Please sign in to comment.