Files
Genarrative/scripts/vite-cli.mjs

23 lines
778 B
JavaScript

import crypto from 'node:crypto';
import { createRequire } from 'node:module';
import { dirname, join } from 'node:path';
import { pathToFileURL } from 'node:url';
if (crypto.webcrypto) {
if (typeof crypto.getRandomValues !== 'function') {
crypto.getRandomValues = crypto.webcrypto.getRandomValues.bind(crypto.webcrypto);
}
if (!globalThis.crypto || typeof globalThis.crypto.getRandomValues !== 'function') {
Object.defineProperty(globalThis, 'crypto', {
value: crypto.webcrypto,
configurable: true,
});
}
}
const require = createRequire(import.meta.url);
const vitePackageJsonPath = require.resolve('vite/package.json');
const viteBinPath = join(dirname(vitePackageJsonPath), 'bin', 'vite.js');
await import(pathToFileURL(viteBinPath).href);