MCPcopy Create free account
hub / github.com/esengine/esengine / scanNodeModulesForWasm

Function scanNodeModulesForWasm

packages/editor-app/vite.config.ts:467–498  ·  view source on GitHub ↗
(nodeModulesDir: string)

Source from the content-addressed store, hash-verified

465}
466
467function 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
500detectWasmPackages();
501

Callers 1

detectWasmPackagesFunction · 0.85

Calls 4

hasWasmFilesFunction · 0.85
pushMethod · 0.65
joinMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected