-
Notifications
You must be signed in to change notification settings - Fork 43
chore(build): rename configs, remove dead code, fix runtime bugs #1141
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
Closed
Closed
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
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
156 changes: 0 additions & 156 deletions
156
packages/build-infra/lib/esbuild-plugin-dead-code-elimination.mjs
This file was deleted.
Oops, something went wrong.
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,58 @@ | ||
| /** | ||
| * esbuild build orchestrator for Socket CLI. | ||
| * Builds all variants (CLI bundle + entry point) in parallel. | ||
| * | ||
| * Usage: | ||
| * node .config/esbuild.build.mjs # Build all variants | ||
| * node .config/esbuild.build.mjs cli # Build CLI bundle | ||
| * node .config/esbuild.build.mjs index # Build entry point | ||
| */ | ||
|
|
||
| import { fileURLToPath } from 'node:url' | ||
|
|
||
| import { getDefaultLogger } from '@socketsecurity/lib/logger' | ||
|
|
||
| import { runBuild } from '../scripts/esbuild-utils.mjs' | ||
| import cliConfig from './esbuild.cli.mjs' | ||
| import indexConfig from './esbuild.index.mjs' | ||
|
|
||
| const logger = getDefaultLogger() | ||
|
|
||
| export const CONFIGS = { | ||
| __proto__: null, | ||
| cli: cliConfig, | ||
| index: indexConfig, | ||
| } | ||
|
|
||
| async function main() { | ||
| const variant = process.argv[2] || 'all' | ||
|
|
||
| if (variant !== 'all' && !(variant in CONFIGS)) { | ||
| logger.error(`Unknown variant: ${variant}`) | ||
| logger.error(`Available variants: all, ${Object.keys(CONFIGS).join(', ')}`) | ||
| process.exitCode = 1 | ||
| return | ||
| } | ||
|
|
||
| const targets = | ||
| variant === 'all' | ||
| ? Object.entries(CONFIGS) | ||
| : [[variant, CONFIGS[variant]]] | ||
|
|
||
| const results = await Promise.allSettled( | ||
| targets.map(({ 0: name, 1: config }) => runBuild(config, name)), | ||
| ) | ||
| const failed = results.filter(r => r.status === 'rejected') | ||
| if (failed.length > 0) { | ||
| process.exitCode = 1 | ||
| } | ||
| } | ||
|
|
||
| if (fileURLToPath(import.meta.url) === process.argv[1]) { | ||
| main().catch(error => { | ||
| logger.error('Build failed:', error) | ||
| process.exitCode = 1 | ||
| }) | ||
| } | ||
|
|
||
| export default CONFIGS | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Orchestrator failure detection is unreachable dead code
Medium Severity
The
runBuildfunction catches all errors internally and never rejects — it always resolves toundefined. The orchestrator usesPromise.allSettledand filters forr.status === 'rejected', which can therefore never match. Thefailedarray is always empty andprocess.exitCode = 1in the orchestrator is unreachable. The build still exits correctly becauserunBuilditself setsprocess.exitCode = 1, but the orchestrator's failure-detection logic is dead code and gives a false impression of where error handling occurs.Additional Locations (1)
packages/cli/scripts/esbuild-utils.mjs#L137-L162