Lines 59-99javascript
62export async function loadModule(modulePath) {
63 const resolved = path.resolve(process.cwd(), modulePath);
65 await access(resolved);
68 const relativePath = path.relative(process.cwd(), resolved);
69 throw new Error(`File not found: ${relativePath}`);
71 const extension = path.extname(resolved).toLowerCase();
72 const isTypeScript = TYPESCRIPT_EXTENSIONS.has(extension);
73 const moduleUrl = isTypeScript
74 ? await bundleTypeScriptModule(resolved)
75 : `${pathToFileURL(resolved).href}?t=${Date.now()}`;
77 const importOverride = globalState.__hypequeryCliImportOverride;
79 ? await importOverride(moduleUrl)
80 : await import(/* @vite-ignore */ moduleUrl);
81 }
MediumDynamic Require
Package source references dynamic require/import behavior.
dist/utils/load-api.jsView on unpkg · L79 83 const relativePath = path.relative(process.cwd(), resolved);
84 throw new Error(`Failed to load module: ${relativePath}\n\n` +
85 `Error: ${error.message}\n\n` +
86 (error.code === 'ERR_MODULE_NOT_FOUND'
87 ? `This usually means:\n` +
88 ` • A dependency is missing (run 'npm install')\n` +
89 ` • An import path is incorrect\n`
91 (error.stack ? `\nStack trace:\n${error.stack}\n` : ''));
94const globalState = globalThis;
95let tempDirPromise = globalState.__hypequeryCliTempDirPromise ?? null;
96const tempFiles = globalState.__hypequeryCliTempFiles ?? new Set();
97const tempDirs = globalState.__hypequeryCliTempDirs ?? new Set();
98let cleanupHooksInstalled = globalState.__hypequeryCliCleanupInstalled ?? false;
99if (!globalState.__hypequeryCliTempFiles) {