Skip to content

Commit 2cece06

Browse files
committed
fix: move webidl-conversions polyfill to config file top
Apply ArrayBuffer/SharedArrayBuffer polyfills at the very top of the vite.config.test.ts file, before any imports. This ensures the polyfills are applied before webidl-conversions is loaded by any dependencies. The previous globalSetup approach didn't work in CI because globalSetup runs in a separate context after modules are already loaded. Moving the polyfill to the config file ensures it runs early enough to prevent 'Cannot read properties of undefined (reading get)' errors in Node 18.
1 parent c9ed2cc commit 2cece06

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

vite.config.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
// Polyfill ArrayBuffer and SharedArrayBuffer properties before any imports
2+
// This prevents webidl-conversions errors in Node 18 CI environment
3+
if (
4+
typeof ArrayBuffer !== "undefined" &&
5+
!Object.getOwnPropertyDescriptor(ArrayBuffer.prototype, "resizable")
6+
) {
7+
Object.defineProperty(ArrayBuffer.prototype, "resizable", {
8+
get() {
9+
return false;
10+
},
11+
configurable: true,
12+
});
13+
}
14+
15+
if (
16+
typeof SharedArrayBuffer !== "undefined" &&
17+
!Object.getOwnPropertyDescriptor(SharedArrayBuffer.prototype, "growable")
18+
) {
19+
Object.defineProperty(SharedArrayBuffer.prototype, "growable", {
20+
get() {
21+
return false;
22+
},
23+
configurable: true,
24+
});
25+
}
26+
127
import { defineConfig } from "vitest/config";
228
import react from "@vitejs/plugin-react-swc";
329
import path from "path";

0 commit comments

Comments
 (0)