(nodeModulesDir: string)
| 465 | } |
| 466 | |
| 467 | function scanNodeModulesForWasm(nodeModulesDir: string) { |
| 468 | try { |
| 469 | const entries = fs.readdirSync(nodeModulesDir); |
| 470 | for (const entry of entries) { |
| 471 | if (entry.startsWith('.')) continue; |
| 472 | |
| 473 | const entryPath = path.join(nodeModulesDir, entry); |
| 474 | const stat = fs.statSync(entryPath); |
| 475 | if (!stat.isDirectory()) continue; |
| 476 | |
| 477 | if (entry.startsWith('@')) { |
| 478 | const scopedPackages = fs.readdirSync(entryPath); |
| 479 | for (const scopedPkg of scopedPackages) { |
| 480 | const scopedPath = path.join(entryPath, scopedPkg); |
| 481 | if (fs.statSync(scopedPath).isDirectory()) { |
| 482 | if (!wasmPackages.includes(`${entry}/${scopedPkg}`) && hasWasmFiles(scopedPath)) { |
| 483 | wasmPackages.push(`${entry}/${scopedPkg}`); |
| 484 | console.log(`[Vite] Detected WASM package in node_modules: ${entry}/${scopedPkg}`); |
| 485 | } |
| 486 | } |
| 487 | } |
| 488 | } else { |
| 489 | if (!wasmPackages.includes(entry) && hasWasmFiles(entryPath)) { |
| 490 | wasmPackages.push(entry); |
| 491 | console.log(`[Vite] Detected WASM package in node_modules: ${entry}`); |
| 492 | } |
| 493 | } |
| 494 | } |
| 495 | } catch { |
| 496 | // Ignore errors |
| 497 | } |
| 498 | } |
| 499 | |
| 500 | detectWasmPackages(); |
| 501 |
no test coverage detected