Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,21 @@ jobs:
run: bun install

- name: Build ${{ matrix.name }}
run: bun run packages/opencode/script/build.ts --target-index=${{ matrix.index }}
# altimate_change start — retry a failed build once, so one flaky target can't hold up
# the release (see the Solid plugin warm-up in build.ts for the flake we know of). The
# retry is a new `bun run`: Bun keeps a misread resolver entry for the life of the
# process. The warning keeps the first failure visible on the run summary.
run: |
for attempt in 1 2; do
Comment thread
ralphstodomingo marked this conversation as resolved.
Resolved
if bun run packages/opencode/script/build.ts --target-index=${{ matrix.index }}; then
exit 0
fi
if [ "$attempt" = 1 ]; then
echo "::warning::Build (${{ matrix.name }}) failed on attempt 1; retrying once in a fresh process"
fi
done
exit 1
# altimate_change end
env:
OPENCODE_VERSION: ${{ github.ref_name }}
# altimate_change — derive channel from the tag: a prerelease tag (e.g. v0.9.0-beta.1)
Expand Down
25 changes: 25 additions & 0 deletions packages/opencode/script/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import { $ } from "bun"
import fs from "fs"
// altimate_change start — tmpdir for the Solid plugin warm-up build below
import os from "os"
// altimate_change end
import path from "path"
import { fileURLToPath } from "url"
import { createRequire } from "node:module"
Expand Down Expand Up @@ -500,6 +503,28 @@ function locatePlatformPackageDir(pkgName: string): string {
const pkgJsonPath = altimateCoreLoaderRequire.resolve(`${pkgName}/package.json`)
return fs.realpathSync(path.dirname(pkgJsonPath))
}

// altimate_change start — warm the Solid plugin before the real bundles.
// The plugin's .tsx loader runs Babel on the JS thread, and Babel requires most of its
// dependencies lazily on its first transform. Inside `Bun.build` those lookups race the
// bundle thread, which resolves the same symlinked `node_modules/.bun` entries for the
// copy of @babel/core this binary embeds (via @opentui/solid/runtime-plugin-support).
// Bun 1.3.14's resolver fills each entry's kind without a lock, so either side can read a
// package directory as a file: `EISDIR reading ".../node_modules/@babel/traverse"`, on a
// random target. One throwaway transform here, in a build that resolves nothing, does
// those lookups first. Bun 1.4 locks that lookup; this block can go once we build on it.
{
const warmDir = fs.mkdtempSync(path.join(os.tmpdir(), "altimate-solid-warm-"))
try {
const warmEntry = path.join(warmDir, "warm.tsx")
fs.writeFileSync(warmEntry, "export const Warm = (props: { n: number }) => <box>{props.n}</box>\n")
await Bun.build({ entrypoints: [warmEntry], plugins: [solidPlugin], target: "bun", external: ["*"] })
Comment thread
ralphstodomingo marked this conversation as resolved.
Resolved
} finally {
fs.rmSync(warmDir, { recursive: true, force: true })
}
}
// altimate_change end

for (const item of targets) {
const name = [
pkg.name,
Expand Down
Loading