FIX: QVAC (QuantumVerse Automatic Computer) Packing
This commit is contained in:
+24
-2
@@ -55,18 +55,40 @@ export function createQvacEngine(deps) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve @qvac/sdk for both ESM (pear run) and CJS Electron bundle.
|
||||
* Packaged Electron: packages are external requires under app/node_modules.
|
||||
* @param {number} [timeoutMs]
|
||||
*/
|
||||
async function tryLoadSdk(timeoutMs = 8_000) {
|
||||
if (sdk) return sdk
|
||||
try {
|
||||
const load = import('@qvac/sdk').then((m) => m)
|
||||
const load = (async () => {
|
||||
// Prefer dynamic import (ESM / pear). Falls back to createRequire for CJS.
|
||||
try {
|
||||
return await import('@qvac/sdk')
|
||||
} catch (importErr) {
|
||||
try {
|
||||
const { createRequire } = await import('module')
|
||||
const req = createRequire(
|
||||
typeof __filename !== 'undefined'
|
||||
? __filename
|
||||
: `${process.cwd()}/package.json`
|
||||
)
|
||||
return req('@qvac/sdk')
|
||||
} catch {
|
||||
throw importErr
|
||||
}
|
||||
}
|
||||
})()
|
||||
const timed =
|
||||
timeoutMs > 0
|
||||
? Promise.race([
|
||||
load,
|
||||
new Promise((_, reject) => {
|
||||
setTimeout(() => reject(new Error(`@qvac/sdk import timed out after ${timeoutMs}ms`)), timeoutMs)
|
||||
setTimeout(
|
||||
() => reject(new Error(`@qvac/sdk import timed out after ${timeoutMs}ms`)),
|
||||
timeoutMs
|
||||
)
|
||||
}),
|
||||
])
|
||||
: load
|
||||
|
||||
Reference in New Issue
Block a user