Skip to content

Commit 2bbe9cc

Browse files
committed
refactor(build): replace rollup with esbuild for SEA bootstrap
- Replace rollup.cli-sea.config.mjs with esbuild.sea-bootstrap.build.mjs - Remove all rollup dependencies and plugins from package.json - Update build:sea:internal:bootstrap script to use esbuild - Update test to reference new esbuild config - Update comments to reference esbuild define instead of rollup replace - External nanotar module (vendored at runtime)
1 parent 7daf075 commit 2bbe9cc

File tree

6 files changed

+69
-61
lines changed

6 files changed

+69
-61
lines changed

package.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@
2626
"@pnpm/lockfile.detect-dep-types": "1001.0.13",
2727
"@pnpm/lockfile.fs": "1001.1.17",
2828
"@pnpm/logger": "1001.0.0",
29-
"@rollup/plugin-babel": "6.0.4",
30-
"@rollup/plugin-commonjs": "28.0.6",
31-
"@rollup/plugin-json": "6.1.0",
32-
"@rollup/plugin-node-resolve": "16.0.1",
33-
"@rollup/plugin-replace": "6.0.2",
34-
"@rollup/pluginutils": "5.3.0",
3529
"@socketregistry/hyrious__bun.lockb": "1.0.19",
3630
"@socketregistry/indent-string": "1.0.14",
3731
"@socketregistry/is-interactive": "1.0.6",
@@ -92,8 +86,6 @@
9286
"react-reconciler": "0.33.0",
9387
"registry-auth-token": "5.1.0",
9488
"registry-url": "7.2.0",
95-
"rollup": "4.50.1",
96-
"rollup-plugin-visualizer": "^6.0.5",
9789
"semver": "7.7.2",
9890
"ssri": "12.0.0",
9991
"synp": "1.9.14",
@@ -124,7 +116,6 @@
124116
"overrides": {
125117
"@octokit/graphql": "9.0.1",
126118
"@octokit/request-error": "7.0.0",
127-
"@rollup/plugin-commonjs": "28.0.6",
128119
"aggregate-error": "npm:@socketregistry/aggregate-error@^1.0.15",
129120
"ansi-regex": "6.1.0",
130121
"brace-expansion": "2.0.2",
@@ -148,7 +139,6 @@
148139
"npm-package-arg": "13.0.0",
149140
"packageurl-js": "npm:@socketregistry/packageurl-js@^1.3.0",
150141
"path-parse": "npm:@socketregistry/path-parse@^1.0.8",
151-
"rollup": "4.52.5",
152142
"safe-buffer": "npm:@socketregistry/safe-buffer@^1.0.9",
153143
"safer-buffer": "npm:@socketregistry/safer-buffer@^1.0.10",
154144
"semver": "7.7.2",
@@ -166,7 +156,6 @@
166156
"yargs-parser": "21.1.1"
167157
},
168158
"patchedDependencies": {
169-
"@rollup/plugin-commonjs@28.0.6": "patches/@rollup__plugin-commonjs@28.0.6.patch",
170159
"brace-expansion@2.0.2": "patches/brace-expansion@2.0.2.patch",
171160
"graceful-fs@4.2.11": "patches/graceful-fs@4.2.11.patch",
172161
"lodash@4.17.21": "patches/lodash@4.17.21.patch",
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* esbuild configuration for building SEA bootstrap thin wrapper.
3+
* Compiles TypeScript bootstrap to CommonJS for Node.js SEA compatibility.
4+
*/
5+
6+
import { build } from 'esbuild'
7+
import { existsSync } from 'node:fs'
8+
import path from 'node:path'
9+
import { fileURLToPath } from 'node:url'
10+
11+
import { getLocalPackageAliases } from '../scripts/utils/get-local-package-aliases.mjs'
12+
13+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
14+
const rootDir = path.join(__dirname, '..')
15+
16+
const inputFile = process.env['SEA_BOOTSTRAP'] || path.join(rootDir, 'src/stub/bootstrap.mts')
17+
const outputFile = process.env['SEA_OUTPUT'] || path.join(rootDir, 'dist/sea/bootstrap.cjs')
18+
19+
const isWatch = process.argv.includes('--watch')
20+
21+
// Get local package aliases for development.
22+
const aliases = getLocalPackageAliases(rootDir)
23+
24+
// Create alias mapping for esbuild.
25+
const aliasEntries = {}
26+
for (const [pkg, distPath] of Object.entries(aliases)) {
27+
// For each package, create an alias that points to the dist folder.
28+
aliasEntries[pkg] = distPath
29+
}
30+
31+
const config = {
32+
entryPoints: [inputFile],
33+
outfile: outputFile,
34+
bundle: true,
35+
format: 'cjs',
36+
platform: 'node',
37+
target: 'node18',
38+
sourcemap: false,
39+
minify: false,
40+
// Only externalize Node.js built-ins and nanotar (vendored at runtime).
41+
external: ['node:*', 'nanotar'],
42+
alias: aliasEntries,
43+
logLevel: 'info',
44+
banner: {
45+
js: `// SEA Bootstrap - esbuild generated\n`,
46+
},
47+
}
48+
49+
try {
50+
if (isWatch) {
51+
const context = await build({
52+
...config,
53+
logLevel: 'info',
54+
})
55+
await context.watch()
56+
console.log('Watching for changes...')
57+
} else {
58+
await build(config)
59+
console.log(`✓ SEA bootstrap built: ${outputFile}`)
60+
}
61+
} catch (error) {
62+
console.error('Build failed:', error)
63+
process.exit(1)
64+
}

packages/cli/.config/rollup.cli-sea.config.mjs

Lines changed: 0 additions & 45 deletions
This file was deleted.

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
"scripts": {
3434
"build": "node --import=./scripts/load.mjs scripts/build.mjs",
35-
"build:sea:internal:bootstrap": "rollup -c .config/rollup.cli-sea.config.mjs",
35+
"build:sea:internal:bootstrap": "node .config/esbuild.sea-bootstrap.build.mjs",
3636
"build:js": "node scripts/extract-yoga-wasm.mjs && node .config/esbuild.cli.build.mjs",
3737
"build:watch": "node scripts/extract-yoga-wasm.mjs && node .config/esbuild.cli.build.mjs --watch",
3838
"dev": "pnpm run build:watch",

packages/cli/src/constants/env.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export {
7474
}
7575

7676
// Getter functions for build metadata.
77-
// Use direct process.env access (not env imports) so rollup replace plugin can inline values.
77+
// Use direct process.env access (not env imports) so esbuild define can inline values.
7878
export function getCliVersion(): string | undefined {
7979
return process.env['INLINED_SOCKET_CLI_VERSION']
8080
}
@@ -164,7 +164,7 @@ const ENV = {
164164
CI: env['CI'],
165165
GITHUB_REPOSITORY: env['GITHUB_REPOSITORY'],
166166
SOCKET_CLI_ORG_SLUG: env['SOCKET_CLI_ORG_SLUG'],
167-
// Build metadata (inlined by rollup replace plugin).
167+
// Build metadata (inlined by esbuild define).
168168
INLINED_SOCKET_CLI_CDXGEN_VERSION:
169169
process.env['INLINED_SOCKET_CLI_CDXGEN_VERSION'],
170170
INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION:

packages/cli/test/build-sea.test.mts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('SEA build validation', () => {
1212
const bootstrapPath = path.join(
1313
process.cwd(),
1414
'src',
15-
'sea',
15+
'stub',
1616
'bootstrap.mts',
1717
)
1818
expect(existsSync(bootstrapPath)).toBe(true)
@@ -22,7 +22,7 @@ describe('SEA build validation', () => {
2222
const configPath = path.join(
2323
process.cwd(),
2424
'.config',
25-
'rollup.cli-sea.config.mjs',
25+
'esbuild.sea-bootstrap.build.mjs',
2626
)
2727
expect(existsSync(configPath)).toBe(true)
2828
})

0 commit comments

Comments
 (0)