Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
codegraph/scripts/build-bundle.sh at main · jamesrwatsonx-creator/codegraph · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
jamesrwatsonx-creator
codegraph
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
codegraph
/
scripts
/
build-bundle.sh
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
118 lines (109 loc) · 4.7 KB
main
Breadcrumbs
codegraph
/
scripts
/
build-bundle.sh
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
118 lines (109 loc) · 4.7 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!
/usr/bin/env bash
#
#
Build a self-contained CodeGraph bundle: an official Node runtime + the
#
compiled app + its production deps, so CodeGraph runs with NO system Node and
#
NO native build — node:sqlite is built into the bundled Node. One archive per
#
platform.
#
#
Because dropping better-sqlite3 left zero native addons, the recipe is pure
#
file-packaging (download the target's Node, copy the app, archive) — so any
#
platform's bundle can be built on any OS. No cross-compile, no native runners.
#
#
Usage:
#
scripts/build-bundle.sh <target> [node-version]
#
target: darwin-arm64 | darwin-x64 | linux-x64 | linux-arm64
#
| win32-x64 | win32-arm64
#
node-version: e.g. v24.16.0 (default below; pin for reproducible builds)
#
#
Output:
#
unix: release/codegraph-<target>.tar.gz (launcher: bin/codegraph)
#
windows: release/codegraph-<target>.zip (launcher: bin/codegraph.cmd)
set
-euo pipefail
TARGET=
"
${1
:?
usage
:
build-bundle.sh <target> [node-version]}
"
NODE_VERSION=
"
${2
:-
v24.16.0}
"
ROOT=
"
$(
cd
"
$(
dirname
"
$0
"
)
/..
"
&&
pwd
)
"
OUT=
"
$ROOT
/release
"
WORK=
"
$(
mktemp -d
)
"
trap
'
rm -rf "$WORK"
'
EXIT
ARCH=
"
${TARGET
##*
-}
"
#
x64 | arm64
OSFAM=
"
${TARGET
%
-
*
}
"
#
darwin | linux | win32
echo
"
[bundle] target=
${TARGET}
node=
${NODE_VERSION}
"
#
1. Download + extract the official Node runtime for the target platform.
if
[
"
$OSFAM
"
=
"
win32
"
]
;
then
NODE_DIST=
"
node-
${NODE_VERSION}
-win-
${ARCH}
"
NODE_URL=
"
https://nodejs.org/dist/
${NODE_VERSION}
/
${NODE_DIST}
.zip
"
echo
"
[bundle] downloading
${NODE_URL}
"
curl -fsSL
"
$NODE_URL
"
-o
"
$WORK
/node.zip
"
if
command
-v unzip
>
/dev/null
2>&1
;
then
unzip -q
"
$WORK
/node.zip
"
-d
"
$WORK
"
else
tar -xf
"
$WORK
/node.zip
"
-C
"
$WORK
"
#
bsdtar can read zip
fi
NODE_BIN=
"
$WORK
/
${NODE_DIST}
/node.exe
"
else
NODE_DIST=
"
node-
${NODE_VERSION}
-
${TARGET}
"
NODE_URL=
"
https://nodejs.org/dist/
${NODE_VERSION}
/
${NODE_DIST}
.tar.gz
"
echo
"
[bundle] downloading
${NODE_URL}
"
curl -fsSL
"
$NODE_URL
"
-o
"
$WORK
/node.tar.gz
"
tar -xzf
"
$WORK
/node.tar.gz
"
-C
"
$WORK
"
NODE_BIN=
"
$WORK
/
${NODE_DIST}
/bin/node
"
fi
[
-f
"
$NODE_BIN
"
]
||
{
echo
"
[bundle] error: node binary not found (
$NODE_BIN
)
"
>&2
;
exit
1
;
}
#
2. Build the app (compiled JS + copied wasm/schema assets).
echo
"
[bundle] building app
"
(
cd
"
$ROOT
"
&&
npm run build
>
/dev/null )
#
3. Stage: app + production-only deps (pure JS/wasm → portable across platforms).
STAGE=
"
$WORK
/codegraph-
${TARGET}
"
mkdir -p
"
$STAGE
/lib
"
"
$STAGE
/bin
"
cp -R
"
$ROOT
/dist
"
"
$STAGE
/lib/dist
"
cp
"
$ROOT
/package.json
"
"
$ROOT
/package-lock.json
"
"
$STAGE
/lib/
"
echo
"
[bundle] installing production dependencies
"
(
cd
"
$STAGE
/lib
"
&&
npm ci --omit=dev --ignore-scripts
>
/dev/null
2>&1
)
rm -f
"
$STAGE
/lib/package-lock.json
"
#
4. Vendored Node + launcher (the launcher uses the bundled Node by relative
#
path, so no system Node is ever needed).
#
#
`--liftoff-only`: keep tree-sitter's large WASM grammars on V8's Liftoff
#
baseline compiler so they never reach the turboshaft optimizing tier, whose
#
per-compilation Zone arena OOMs the whole process (`Fatal process out of
#
memory: Zone`) on Node >= 22 — even with tens of GB free. The flag is read at
#
V8 engine init so it must be on node's command line; the parse worker inherits
#
it. See issues #293/#298 and src/extraction/wasm-runtime-flags.ts. (The CLI
#
also self-relaunches with this flag when launched without it, so non-bundled
#
runs are covered too; passing it here avoids that extra spawn.)
if
[
"
$OSFAM
"
=
"
win32
"
]
;
then
cp
"
$NODE_BIN
"
"
$STAGE
/node.exe
"
printf
'
@"%%~dp0..\\node.exe" --liftoff-only "%%~dp0..\\lib\\dist\\bin\\codegraph.js" %%*\r\n
'
\
>
"
$STAGE
/bin/codegraph.cmd
"
else
cp
"
$NODE_BIN
"
"
$STAGE
/node
"
cat
>
"
$STAGE
/bin/codegraph
"
<<
'
LAUNCH
'
#!/bin/sh
# Resolve symlinks (e.g. the ~/.local/bin/codegraph link install.sh creates) so
# we find the real bundle dir, not the symlink's location.
SELF="$0"
while [ -L "$SELF" ]; do
target="$(readlink "$SELF")"
case "$target" in
/*) SELF="$target" ;;
*) SELF="$(dirname "$SELF")/$target" ;;
esac
done
DIR="$(cd "$(dirname "$SELF")/.." && pwd)"
# --liftoff-only: avoid the V8 turboshaft WASM Zone OOM (issues #293/#298).
exec "$DIR/node" --liftoff-only "$DIR/lib/dist/bin/codegraph.js" "$@"
LAUNCH
chmod +x
"
$STAGE
/bin/codegraph
"
fi
#
5. Archive (.zip for Windows, .tar.gz otherwise).
mkdir -p
"
$OUT
"
if
[
"
$OSFAM
"
=
"
win32
"
]
;
then
ARCHIVE=
"
$OUT
/codegraph-
${TARGET}
.zip
"
rm -f
"
$ARCHIVE
"
(
cd
"
$WORK
"
&&
zip -rqX
"
$ARCHIVE
"
"
codegraph-
${TARGET}
"
)
else
ARCHIVE=
"
$OUT
/codegraph-
${TARGET}
.tar.gz
"
#
--no-xattrs: don't embed macOS xattrs that make GNU tar warn on Linux.
tar --no-xattrs -czf
"
$ARCHIVE
"
-C
"
$WORK
"
"
codegraph-
${TARGET}
"
fi
echo
"
[bundle] wrote
${ARCHIVE}
(
$(
du -h
"
$ARCHIVE
"
|
cut -f1
)
)
"
You can’t perform that action at this time.