u
This commit is contained in:
@@ -18,10 +18,7 @@ if (!fs.existsSync(distDir)) {
|
||||
fs.mkdirSync(distDir, { recursive: true });
|
||||
}
|
||||
|
||||
console.log('Packaging application, siblings, and JavaScript dependencies into SEA payload...');
|
||||
|
||||
// Native C++ addon folders that will be loaded from the host filesystem via dlopen
|
||||
const NATIVE_ADDON_PKGS = new Set(['better-sqlite3', 'canvas', 'sharp', '@img']);
|
||||
console.log('Packaging application, siblings, and dependencies into SEA payload...');
|
||||
|
||||
function packDirectory(dir, prefix, result) {
|
||||
if (!fs.existsSync(dir)) return;
|
||||
@@ -30,11 +27,10 @@ function packDirectory(dir, prefix, result) {
|
||||
const full = path.join(dir, entry.name);
|
||||
const rel = path.join(prefix, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
if (entry.name === 'test' || entry.name === 'tests' || entry.name === 'docs' || entry.name === '.github' || entry.name === '.git') continue;
|
||||
if (entry.name === 'test' || entry.name === 'tests' || entry.name === 'docs' || entry.name === '.github' || entry.name === '.git' || entry.name === 'obj.target') continue;
|
||||
packDirectory(full, rel, result);
|
||||
} else if (entry.isFile()) {
|
||||
// Ignore compiled native binary extensions which are linked from the host
|
||||
if (entry.name.endsWith('.node') || entry.name.endsWith('.so') || entry.name.endsWith('.dylib') || entry.name.endsWith('.dll') || entry.name.endsWith('.a')) continue;
|
||||
if (entry.name.endsWith('.a') || entry.name.endsWith('.o') || entry.name.endsWith('.cc') || entry.name.endsWith('.cpp') || entry.name.endsWith('.c') || entry.name.endsWith('.h')) continue;
|
||||
result[rel] = fs.readFileSync(full).toString('base64');
|
||||
}
|
||||
}
|
||||
@@ -67,15 +63,14 @@ if (fs.existsSync(path.join(llmorbiterDir, 'src'))) {
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Pack all non-native node_modules dependencies
|
||||
// 3. Pack all node_modules dependencies
|
||||
function packNodeModules(nmPath) {
|
||||
if (!fs.existsSync(nmPath)) return;
|
||||
for (const name of fs.readdirSync(nmPath)) {
|
||||
if (NATIVE_ADDON_PKGS.has(name) || name.startsWith('.') || name === 'libdashstore' || name === 'libllmorbiter') continue;
|
||||
if (name.startsWith('.') || name === 'libdashstore' || name === 'libllmorbiter') continue;
|
||||
const pkgDir = path.join(nmPath, name);
|
||||
if (name.startsWith('@')) {
|
||||
for (const sub of fs.readdirSync(pkgDir)) {
|
||||
if (NATIVE_ADDON_PKGS.has(sub) || NATIVE_ADDON_PKGS.has(`${name}/${sub}`)) continue;
|
||||
packDirectory(path.join(pkgDir, sub), `node_modules/${name}/${sub}`, payload);
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user