Skip to content

Commit a0f1253

Browse files
Matt-Dionisclaude
andcommitted
Move crypto polyfill to vitest config entry point
- Create separate vitest-polyfill.mjs file - Import polyfill at the very beginning of vitest.config.mjs - Ensures polyfill is loaded before Vitest needs crypto.getRandomValues - Fixes startup error in CI with Node 18 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b6c89d5 commit a0f1253

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Polyfill for crypto.getRandomValues for Node < 19
2+
import crypto from 'crypto';
3+
4+
if (!globalThis.crypto) {
5+
globalThis.crypto = crypto;
6+
}
7+
if (!globalThis.crypto.getRandomValues) {
8+
globalThis.crypto.getRandomValues = function(array) {
9+
return crypto.randomFillSync(array);
10+
};
11+
}

claude-config-composer/vitest.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import './vitest-polyfill.mjs';
12
import path from 'path';
23
import { defineConfig } from 'vitest/config';
34
import { fileURLToPath } from 'url';

0 commit comments

Comments
 (0)