Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/desktop/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# production
/build
/dist
/.native-modules
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check 1: Look for .native-modules directory references
fd -t d "^.native-modules$" -d 1 2>/dev/null || echo "No .native-modules dir found in root"

# Check 2: Search for .native-modules references in the codebase
rg "\.native-modules" --type-list | head -5
rg "\.native-modules" -n 2>/dev/null | head -20

# Check 3: Find the copy-native-modules.ts script
fd "copy-native-modules" -t f

Repository: superset-sh/superset

Length of output: 514


🏁 Script executed:

#!/bin/bash
# Check script size first
wc -l apps/desktop/scripts/copy-native-modules.ts

# Read the script
cat -n apps/desktop/scripts/copy-native-modules.ts

# Search for .native-modules references (corrected)
echo "=== .native-modules references ==="
rg "native-modules" -n 2>/dev/null || echo "No matches found"

# Check if it's mentioned in package.json
echo "=== Checking package.json ==="
fd "package.json" -t f | xargs grep -l "native-modules" 2>/dev/null || echo "Not found in package.json"

Repository: superset-sh/superset

Length of output: 2685


🏁 Script executed:

#!/bin/bash
# Comprehensive search for actual .native-modules directory references
echo "=== Searching for .native-modules directory (not script name) ==="
rg "\.native-modules" --type-list | head -5 && echo "---" || true
rg "\.native-modules" -n 2>/dev/null || echo "No exact matches"

# Check .gitignore content around line 12
echo ""
echo "=== .gitignore content ==="
cat -n apps/desktop/.gitignore

# Check if there are any build or dist patterns
echo ""
echo "=== Checking build/output related configs ==="
fd "tsconfig|webpack|vite|build" -t f apps/desktop/ | head -10

Repository: superset-sh/superset

Length of output: 1226


The .native-modules entry is unnecessary and can be removed.

The copy-native-modules.ts script works with node_modules/node-pty, which is already covered by the /node_modules ignore pattern on line 2. No part of the codebase creates or references a .native-modules directory—this entry appears to be unused dead code in .gitignore.

🤖 Prompt for AI Agents
In apps/desktop/.gitignore around line 12 the entry "/.native-modules" is
dead/unnecessary because node-native artifacts are already ignored via
"/node_modules" and no code creates or references a ".native-modules" directory;
remove the "/.native-modules" line from the .gitignore to clean up unused
entries and keep the file minimal.


# misc
.DS_Store
Expand Down
10 changes: 8 additions & 2 deletions apps/desktop/electron-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@ const config: Configuration = {
to: "resources",
filter: ["**/*"],
},
// Only include node-pty (native module that can't be bundled)
"node_modules/node-pty/**/*",
// Native module that can't be bundled by Vite.
// The copy:native-modules script replaces symlinks with real files
// before building (required for Bun 1.3+ isolated installs).
{
from: "node_modules/node-pty",
to: "node_modules/node-pty",
filter: ["**/*"],
},
"!**/.DS_Store",
],

Expand Down
4 changes: 3 additions & 1 deletion apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
"predev": "bun run clean:dev",
"dev": "cross-env NODE_ENV=development electron-vite dev --watch",
"compile:app": "electron-vite build",
"prebuild": "bun run clean:dev && bun run compile:app",
"copy:native-modules": "bun run scripts/copy-native-modules.ts",
"prebuild": "bun run clean:dev && bun run compile:app && bun run copy:native-modules",
"build": "electron-builder",
"prepackage": "bun run copy:native-modules",
"package": "electron-builder --config electron-builder.ts",
"install:deps": "electron-builder install-app-deps",
"make:release": "tsx ./src/lib/electron-app/release/modules/release.ts",
Expand Down
57 changes: 57 additions & 0 deletions apps/desktop/scripts/copy-native-modules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Prepare native modules for electron-builder.
*
* With Bun 1.3+ isolated installs, node_modules contains symlinks to packages
* stored in node_modules/.bun/. electron-builder cannot follow these symlinks
* when creating asar archives.
*
* This script:
* 1. Detects if native modules are symlinks
* 2. Replaces symlinks with actual file copies
* 3. electron-builder can then properly package and unpack them
*
* This is safe because bun install will recreate the symlinks on next install.
*/

import { cpSync, existsSync, lstatSync, realpathSync, rmSync } from "node:fs";
import { dirname, join } from "node:path";

const NATIVE_MODULES = ["node-pty"] as const;

function prepareNativeModules() {
console.log("Preparing native modules for electron-builder...");

const nodeModulesDir = join(dirname(import.meta.dirname), "node_modules");

for (const moduleName of NATIVE_MODULES) {
const modulePath = join(nodeModulesDir, moduleName);

if (!existsSync(modulePath)) {
console.error(` [ERROR] ${moduleName} not found at ${modulePath}`);
process.exit(1);
}

const stats = lstatSync(modulePath);

if (stats.isSymbolicLink()) {
// Resolve symlink to get real path
const realPath = realpathSync(modulePath);
console.log(` ${moduleName}: symlink -> replacing with real files`);
console.log(` Real path: ${realPath}`);

// Remove the symlink
rmSync(modulePath);

// Copy the actual files
cpSync(realPath, modulePath, { recursive: true });

console.log(` Copied to: ${modulePath}`);
} else {
console.log(` ${moduleName}: already real directory (not a symlink)`);
}
}

console.log("Done!");
}

prepareNativeModules();