Skip to content

Commit 550bd39

Browse files
anandgupta42claude
andauthored
fix: exclude 220MB of unused .node binaries from dbt-tools bundle (#320)
`bun build` copies `@altimateai/altimate-core` native binaries into `dbt-tools/dist/` as transitive build artifacts, but dbt-tools never loads them. Selectively copy only `index.js` and `altimate_python_packages/` instead of the entire dist directory (223MB → 3MB). Closes #319 Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9c2134e commit 550bd39

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

packages/opencode/script/publish.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bun
22
import { $ } from "bun"
3+
import fs from "fs"
34
import pkg from "../package.json"
45
import { Script } from "@opencode-ai/script"
56
import { fileURLToPath } from "url"
@@ -56,10 +57,16 @@ async function copyAssets(targetDir: string) {
5657
await $`cp -r ./bin ${targetDir}/bin`
5758
await $`cp -r ../../.opencode/skills ${targetDir}/skills`
5859
await $`cp ./script/postinstall.mjs ${targetDir}/postinstall.mjs`
59-
// Bundle dbt-tools: copy its bin wrapper + built dist
60+
// Bundle dbt-tools: copy its bin wrapper + only the files it actually needs.
61+
// The full dist/ contains ~220 MB of .node native binaries from altimate-core
62+
// that bun copies as transitive build artifacts but dbt-tools never loads.
6063
await $`mkdir -p ${targetDir}/dbt-tools/bin`
6164
await $`cp ../dbt-tools/bin/altimate-dbt ${targetDir}/dbt-tools/bin/altimate-dbt`
62-
await $`cp -r ../dbt-tools/dist ${targetDir}/dbt-tools/dist`
65+
await $`mkdir -p ${targetDir}/dbt-tools/dist`
66+
await $`cp ../dbt-tools/dist/index.js ${targetDir}/dbt-tools/dist/`
67+
if (fs.existsSync("../dbt-tools/dist/altimate_python_packages")) {
68+
await $`cp -r ../dbt-tools/dist/altimate_python_packages ${targetDir}/dbt-tools/dist/`
69+
}
6370
await Bun.file(`${targetDir}/LICENSE`).write(await Bun.file("../../LICENSE").text())
6471
await Bun.file(`${targetDir}/CHANGELOG.md`).write(await Bun.file("../../CHANGELOG.md").text())
6572
}

packages/opencode/test/branding/build-integrity.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,15 @@ describe("Bundle Completeness", () => {
297297
expect(publishScript).toContain("bun run build")
298298
})
299299

300+
test("publish.ts copies only needed dbt-tools dist files (not .node binaries)", () => {
301+
const publishScript = readFileSync(join(repoRoot, "packages/opencode/script/publish.ts"), "utf-8")
302+
// Should copy index.js and altimate_python_packages selectively, not `cp -r dist`
303+
expect(publishScript).toContain("dist/index.js")
304+
expect(publishScript).toContain("altimate_python_packages")
305+
// Should NOT do a blanket `cp -r ../dbt-tools/dist` (would include ~220MB of .node files)
306+
expect(publishScript).not.toMatch(/cp -r \.\.\/dbt-tools\/dist [^/]/)
307+
})
308+
300309
test("postinstall.mjs sets up dbt-tools symlink", () => {
301310
const postinstall = readFileSync(join(repoRoot, "packages/opencode/script/postinstall.mjs"), "utf-8")
302311
expect(postinstall).toContain("setupDbtTools")

0 commit comments

Comments
 (0)