Skip to content

Commit ff20a44

Browse files
committed
fix(cli): force production JSX runtime in binary build
Add --jsx=react-jsx flag to bun build --compile to use production JSX runtime (jsx from react/jsx-runtime) instead of development runtime (jsxDEV from react/jsx-dev-runtime). This fixes the 'jsxDEV is not a function' error when running the compiled CLI binary.
1 parent 39c54db commit ff20a44

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

cli/scripts/build-binary.ts

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ async function main() {
155155
`--target=${targetInfo.bunTarget}`,
156156
`--outfile=${outputFile}`,
157157
'--sourcemap=none',
158+
'--jsx=react-jsx',
158159
...defineFlags.flatMap(([key, value]) => ['--define', `${key}=${value}`]),
159160
]
160161

@@ -170,7 +171,9 @@ async function main() {
170171
chmodSync(outputFile, 0o755)
171172
}
172173

173-
logAlways(`✅ Built ${outputFilename} (${targetInfo.platform}-${targetInfo.arch})`)
174+
logAlways(
175+
`✅ Built ${outputFilename} (${targetInfo.platform}-${targetInfo.arch})`,
176+
)
174177
}
175178

176179
main().catch((error: unknown) => {
@@ -232,9 +235,13 @@ async function ensureOpenTuiNativeBundle(targetInfo: TargetInfo) {
232235
},
233236
]
234237

235-
const missingTargets = installTargets.filter(({ packageDir }) => !existsSync(packageDir))
238+
const missingTargets = installTargets.filter(
239+
({ packageDir }) => !existsSync(packageDir),
240+
)
236241
if (missingTargets.length === 0) {
237-
log(`OpenTUI native bundle already present for ${targetInfo.platform}-${targetInfo.arch}`)
242+
log(
243+
`OpenTUI native bundle already present for ${targetInfo.platform}-${targetInfo.arch}`,
244+
)
238245
return
239246
}
240247

@@ -252,7 +259,9 @@ async function ensureOpenTuiNativeBundle(targetInfo: TargetInfo) {
252259
}
253260
const version = corePackageJson.optionalDependencies?.[packageName]
254261
if (!version) {
255-
log(`No optional dependency declared for ${packageName}; skipping native bundle fetch`)
262+
log(
263+
`No optional dependency declared for ${packageName}; skipping native bundle fetch`,
264+
)
256265
return
257266
}
258267

@@ -306,15 +315,27 @@ async function ensureOpenTuiNativeBundle(targetInfo: TargetInfo) {
306315
mkdirSync(target.packageDir, { recursive: true })
307316

308317
if (!existsSync(target.packageDir)) {
309-
throw new Error(`Failed to create directory for ${packageName}: ${target.packageDir}`)
318+
throw new Error(
319+
`Failed to create directory for ${packageName}: ${target.packageDir}`,
320+
)
310321
}
311322

312323
const tarballForTar =
313-
process.platform === 'win32' ? tarballPath.replace(/\\/g, '/') : tarballPath
324+
process.platform === 'win32'
325+
? tarballPath.replace(/\\/g, '/')
326+
: tarballPath
314327
const extractDirForTar =
315-
process.platform === 'win32' ? target.packageDir.replace(/\\/g, '/') : target.packageDir
316-
317-
const tarArgs = ['-xzf', tarballForTar, '--strip-components=1', '-C', extractDirForTar]
328+
process.platform === 'win32'
329+
? target.packageDir.replace(/\\/g, '/')
330+
: target.packageDir
331+
332+
const tarArgs = [
333+
'-xzf',
334+
tarballForTar,
335+
'--strip-components=1',
336+
'-C',
337+
extractDirForTar,
338+
]
318339
if (process.platform === 'win32') {
319340
tarArgs.unshift('--force-local')
320341
}
@@ -324,7 +345,9 @@ async function ensureOpenTuiNativeBundle(targetInfo: TargetInfo) {
324345
`Installed OpenTUI native bundle for ${targetInfo.platform}-${targetInfo.arch} in ${target.label}`,
325346
)
326347
}
327-
logAlways(`Fetched OpenTUI native bundle for ${targetInfo.platform}-${targetInfo.arch}`)
348+
logAlways(
349+
`Fetched OpenTUI native bundle for ${targetInfo.platform}-${targetInfo.arch}`,
350+
)
328351
} finally {
329352
rmSync(tempDir, { recursive: true, force: true })
330353
}

0 commit comments

Comments
 (0)