Skip to content

fix(desktop): resolve Windows build compatibility issues#694

Closed
vthuan1889 wants to merge 1 commit into
superset-sh:mainfrom
vthuan1889:fix-build-win
Closed

fix(desktop): resolve Windows build compatibility issues#694
vthuan1889 wants to merge 1 commit into
superset-sh:mainfrom
vthuan1889:fix-build-win

Conversation

@vthuan1889
Copy link
Copy Markdown

@vthuan1889 vthuan1889 commented Jan 9, 2026

  • Fix symlink handling in copy-native-modules script (unlinkSync → rmSync)

  • Convert electron-builder config from TS to JS to avoid symlink issues

  • Update package.json build scripts to use new JS config

  • Disable npmRebuild to eliminate Python dependency on Windows

Description

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes

Summary by CodeRabbit

Release Notes

  • Chores

    • Refactored desktop build system configuration for improved maintainability.
    • Updated build scripts to use explicit configuration references.
  • Bug Fixes

    • Enhanced native module compatibility on Windows systems.

✏️ Tip: You can customize this high-level summary in your review settings.

- Fix symlink handling in copy-native-modules script (unlinkSync → rmSync)

- Convert electron-builder config from TS to JS to avoid symlink issues

- Update package.json build scripts to use new JS config

- Disable npmRebuild to eliminate Python dependency on Windows
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

This change introduces a new Electron Builder configuration file (electron-builder.js) with comprehensive build settings for macOS, Linux, and Windows platforms, updates package scripts to reference this configuration explicitly, and improves native module symlink removal to support Windows by adding a fallback mechanism.

Changes

Cohort / File(s) Summary
Electron Builder Configuration
apps/desktop/electron-builder.js
New configuration file (149 lines) defining platform-specific build targets, native module handling (better-sqlite3, bindings, file-uri-to-path, node-pty), ASAR unpacking patterns, deep linking protocol, macOS notarization, NSIS installer options, and GitHub publishing settings. Reads metadata from package.json.
Build Script References
apps/desktop/package.json
Updated build and package scripts to explicitly reference electron-builder.js via --config flag instead of implicit configuration discovery.
Native Module Handling
apps/desktop/scripts/copy-native-modules.ts
Replaced direct rmSync call with guarded approach: attempts unlinkSync first for symlink removal, falls back to rmSync with force: true for Windows compatibility and better error handling.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 Hopping through configs with care and delight,
Building electrons for Linux, Mac, Windows—all right!
Native modules dance in their ASAR embrace,
Symlinks find gentle fallbacks, a Windows-proof place! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description provides a bullet-point summary of changes but lacks detailed explanations in most template sections, particularly Testing and Additional Notes. Expand the Description section with specific details about why these changes fix Windows build issues. Fill in the Testing section with the steps taken to verify the fixes work on Windows systems.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main objective of the PR: resolving Windows build compatibility issues through symlink handling fixes and configuration conversions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
apps/desktop/electron-builder.js (3)

18-18: Consider handling additional semver prefixes.

The current regex only strips ^ prefixes. While safe (returns original if no match), it won't handle other semver prefixes like ~ or >=.

♻️ More robust version parsing
-	electronVersion: pkg.devDependencies.electron.replace(/^\^/, ""),
+	electronVersion: pkg.devDependencies.electron.replace(/^[\^~>=<]+/, ""),

92-94: Clarify that npmRebuild is disabled for all platforms.

The comment suggests this is Windows-specific, but the setting applies to all platforms. Since native modules are pre-copied via the copy-native-modules script for all platforms, consider updating the comment for clarity.

📝 Suggested comment update
-	// Rebuild native modules for Electron's Node.js version
-	// Disabled on Windows - native modules already copied by copy-native-modules script
+	// Rebuild native modules for Electron's Node.js version
+	// Disabled - native modules are already copied by copy-native-modules script before building
 	npmRebuild: false,

139-139: Inconsistent artifact naming between platforms.

Windows uses JavaScript interpolation (${pkg.version}) while Linux uses electron-builder template variables (\${version}). Consider aligning both platforms to use electron-builder variables for consistency.

♻️ Consistent template variable usage
-		artifactName: `${productName}-${pkg.version}-\${arch}.\${ext}`,
+		artifactName: `superset-\${version}-\${arch}.\${ext}`,

This matches the Linux configuration pattern at line 127.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3e43658 and d11f3bb.

📒 Files selected for processing (4)
  • apps/desktop/electron-builder.js
  • apps/desktop/electron-builder.json
  • apps/desktop/package.json
  • apps/desktop/scripts/copy-native-modules.ts
🧰 Additional context used
📓 Path-based instructions (4)
apps/desktop/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

apps/desktop/**/*.{ts,tsx}: For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc
Use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary.
For tRPC subscriptions with trpc-electron, ALWAYS use the observable pattern from @trpc/server/observable instead of async generators, as the library explicitly checks isObservable(result) and throws an error otherwise

Files:

  • apps/desktop/scripts/copy-native-modules.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use object parameters for functions with 2+ parameters instead of positional arguments
Functions with 2+ parameters should accept a single params object with named properties for self-documentation and extensibility
Use prefixed console logging with context pattern: [domain/operation] message
Extract magic numbers and hardcoded values to named constants at module top
Use lookup objects/maps instead of repeated if (type === ...) conditionals
Avoid using any type - maintain type safety in TypeScript code
Never swallow errors silently - at minimum log them with context
Import from concrete files directly when possible - avoid barrel file abuse that creates circular dependencies
Avoid deep nesting (4+ levels) - use early returns, extract functions, and invert conditions
Use named properties in options objects instead of boolean parameters to avoid boolean blindness

Files:

  • apps/desktop/scripts/copy-native-modules.ts
apps/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Drizzle ORM for all database operations - never use raw SQL

Files:

  • apps/desktop/scripts/copy-native-modules.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Biome for formatting and linting - run at root level with bun run lint:fix or biome check --write

Files:

  • apps/desktop/scripts/copy-native-modules.ts
  • apps/desktop/electron-builder.js
🧠 Learnings (5)
📚 Learning: 2026-01-02T06:50:28.671Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-02T06:50:28.671Z
Learning: Applies to apps/desktop/src/renderer/**/*.{ts,tsx} : Never import Node.js modules (fs, path, os, net) in renderer process or shared code - they are externalized for browser compatibility

Applied to files:

  • apps/desktop/scripts/copy-native-modules.ts
📚 Learning: 2026-01-02T06:50:28.671Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-02T06:50:28.671Z
Learning: Applies to apps/desktop/src/lib/electron-router-dom.ts : Do not import Node.js modules like node:path or dotenv in electron-router-dom.ts and similar shared files - they run in both main and renderer processes

Applied to files:

  • apps/desktop/scripts/copy-native-modules.ts
📚 Learning: 2026-01-02T06:50:28.671Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-02T06:50:28.671Z
Learning: Applies to apps/desktop/src/lib/*.ts : Never import Node.js modules in shared code like electron-router-dom.ts - it runs in both main and renderer processes

Applied to files:

  • apps/desktop/scripts/copy-native-modules.ts
📚 Learning: 2026-01-02T06:50:28.671Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-02T06:50:28.671Z
Learning: Use Bun as the package manager - never use npm/yarn/pnpm

Applied to files:

  • apps/desktop/scripts/copy-native-modules.ts
  • apps/desktop/package.json
📚 Learning: 2026-01-02T06:50:28.671Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-02T06:50:28.671Z
Learning: Applies to **/*.{ts,tsx,js,jsx} : Use Biome for formatting and linting - run at root level with `bun run lint:fix` or `biome check --write`

Applied to files:

  • apps/desktop/package.json
🔇 Additional comments (6)
apps/desktop/scripts/copy-native-modules.ts (2)

16-16: LGTM - Import addition supports Windows compatibility.

The unlinkSync import is correctly added to support the improved symlink removal logic below.


49-55: Robust symlink removal with appropriate fallback.

The try-catch approach correctly prioritizes unlinkSync (the standard method for symlinks) with a defensive fallback to rmSync. The recursive: false option is appropriate since we've already confirmed this is a symlink at line 43.

apps/desktop/electron-builder.js (3)

6-11: LGTM - Appropriate CommonJS format for electron-builder configuration.

The use of CommonJS (require/module.exports) is correct for electron-builder config files, and the metadata extraction from package.json safely handles different author formats.


55-90: Well-structured native module packaging configuration.

The explicit packaging of native modules with matching asarUnpack patterns (lines 35-43) ensures proper runtime access. The comments clearly explain the dependency chain (e.g., better-sqlite3 → bindings → file-uri-to-path).


96-146: Platform configurations are well-structured.

The macOS (arm64), Linux (AppImage/deb), and Windows (NSIS x64) configurations are appropriate for modern desktop distribution. The NSIS settings allow installation directory customization, improving user experience.

apps/desktop/package.json (1)

24-26: LGTM - Build scripts correctly reference the new JS configuration.

The migration from electron-builder.ts to electron-builder.js aligns with the PR's objective to resolve Windows symlink compatibility issues. Both build and package scripts consistently reference the new configuration file.

@Kitenite
Copy link
Copy Markdown
Collaborator

Closing: this early Windows build PR from Jan 9 has been superseded by multiple newer Windows support efforts (#2100, #2196, #2322).

@Kitenite Kitenite closed this Mar 13, 2026
@Kitenite
Copy link
Copy Markdown
Collaborator

Hey — just a heads up, this was closed as part of an automated stale PR cleanup. If you think this was done in error, feel free to reopen it!

@Kitenite
Copy link
Copy Markdown
Collaborator

Hey — this was closed by an automated cleanup of PRs with major merge conflicts that are 3+ weeks old. If you think this was done incorrectly, please feel free to reopen it. Sorry for any inconvenience!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants