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

Function getEngineModules

packages/editor-app/vite.config.ts:68–125  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

66 const packagesDir = path.resolve(__dirname, '..');
67
68 function getEngineModules() {
69 const modules: Array<{
70 id: string;
71 name: string;
72 displayName: string;
73 packageDir: string;
74 moduleJsonPath: string;
75 distPath: string;
76 editorPackage?: string;
77 isCore: boolean;
78 category: string;
79 }> = [];
80
81 let packages: string[];
82 try {
83 packages = fs.readdirSync(packagesDir);
84 } catch {
85 return modules;
86 }
87
88 for (const pkg of packages) {
89 const pkgDir = path.join(packagesDir, pkg);
90 const moduleJsonPath = path.join(pkgDir, 'module.json');
91
92 try {
93 if (!fs.statSync(pkgDir).isDirectory()) continue;
94 } catch {
95 continue;
96 }
97
98 if (!fs.existsSync(moduleJsonPath)) continue;
99
100 try {
101 const moduleJson = JSON.parse(fs.readFileSync(moduleJsonPath, 'utf-8'));
102 if (moduleJson.isEngineModule !== false) {
103 // Use outputPath from module.json, default to "dist/index.js"
104 const outputPath = moduleJson.outputPath || 'dist/index.js';
105 const distPath = path.join(pkgDir, outputPath);
106
107 modules.push({
108 id: moduleJson.id || pkg,
109 name: moduleJson.name || `@esengine/${pkg}`,
110 displayName: moduleJson.displayName || pkg,
111 packageDir: pkgDir,
112 moduleJsonPath,
113 distPath,
114 editorPackage: moduleJson.editorPackage,
115 isCore: moduleJson.isCore || false,
116 category: moduleJson.category || 'Other'
117 });
118 }
119 } catch {
120 // Ignore parse errors
121 }
122 }
123
124 return modules;
125 }

Callers 1

writeBundleFunction · 0.70

Calls 4

parseMethod · 0.65
readFileSyncMethod · 0.65
pushMethod · 0.65
joinMethod · 0.45

Tested by

no test coverage detected