Skip to content

Commit e75a5c8

Browse files
committed
chore: patch vitest for SES compatibility
1 parent c145b20 commit e75a5c8

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"eslint-plugin-react": "^7.30.1",
6363
"eslint-plugin-react-hooks": "^4.6.0",
6464
"framer-motion": "^7.2.1",
65+
"patch-package": "^6.5.0",
6566
"prettier": "^2.7.1",
6667
"typescript": "~4.7.4",
6768
"vite": "^3.1.3",

patches/vitest+0.25.3.patch

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
diff --git a/node_modules/vitest/dist/chunk-runtime-rpc.1e7530d3.js b/node_modules/vitest/dist/chunk-runtime-rpc.1e7530d3.js
2+
index 9bef457..3ac9045 100644
3+
--- a/node_modules/vitest/dist/chunk-runtime-rpc.1e7530d3.js
4+
+++ b/node_modules/vitest/dist/chunk-runtime-rpc.1e7530d3.js
5+
@@ -1,18 +1,19 @@
6+
import { g as getWorkerState } from './chunk-typecheck-constants.4891f22f.js';
7+
import { s as safeSetTimeout } from './chunk-utils-timers.06f993db.js';
8+
9+
-const safeRandom = Math.random;
10+
+// const safeRandom = Math.random;
11+
function withSafeTimers(fn) {
12+
const currentSetTimeout = globalThis.setTimeout;
13+
- const currentRandom = globalThis.Math.random;
14+
+ // const currentRandom = globalThis.Math.random;
15+
try {
16+
globalThis.setTimeout = safeSetTimeout;
17+
- globalThis.Math.random = safeRandom;
18+
+ // SES does not allow setting Math.random
19+
+ // globalThis.Math.random = safeRandom;
20+
const result = fn();
21+
return result;
22+
} finally {
23+
globalThis.setTimeout = currentSetTimeout;
24+
- globalThis.Math.random = currentRandom;
25+
+ // globalThis.Math.random = currentRandom;
26+
}
27+
}
28+
const rpc = () => {

0 commit comments

Comments
 (0)