-
Notifications
You must be signed in to change notification settings - Fork 903
Adjust build script to work with isolated node modules (bun 1.3) #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| # production | ||
| /build | ||
| /dist | ||
| /.native-modules | ||
|
|
||
| # misc | ||
| .DS_Store | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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(); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 514
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 2685
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 1226
The
.native-modulesentry is unnecessary and can be removed.The
copy-native-modules.tsscript works withnode_modules/node-pty, which is already covered by the/node_modulesignore pattern on line 2. No part of the codebase creates or references a.native-modulesdirectory—this entry appears to be unused dead code in.gitignore.🤖 Prompt for AI Agents