Skip to content

Commit 094a693

Browse files
committed
chore(deps): Use crypto.randomUUID() instead of uuid module
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.
1 parent 75260b8 commit 094a693

File tree

3 files changed

+8522
-13356
lines changed

3 files changed

+8522
-13356
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
"troika-three-text": "^0.52.0",
6767
"tunnel-rat": "^0.1.2",
6868
"utility-types": "^3.11.0",
69-
"uuid": "^9.0.1",
7069
"zustand": "^5.0.1"
7170
},
7271
"devDependencies": {

src/core/Cloud.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
} from 'three'
1616
import { MaterialNode, extend, applyProps, useFrame, ReactThreeFiber } from '@react-three/fiber'
1717
import { useTexture } from './Texture'
18-
import { v4 } from 'uuid'
1918
import { setUpdateRange } from '../helpers/deprecated'
2019

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

247246
const parent = React.useContext(context)
248247
const ref = React.useRef<Group>(null!)
249-
const [uuid] = React.useState(() => v4())
248+
const [uuid] = React.useState(() => crypto.randomUUID())
250249
const clouds: CloudState[] = React.useMemo(() => {
251250
return [...new Array(segments)].map(
252251
(_, index) =>

0 commit comments

Comments
 (0)