Skip to content

refactor(build): consolidate to Bun-native build workflow#1644

Merged
tyler-dane merged 4 commits intomainfrom
feat/bun-native-build
Apr 14, 2026
Merged

refactor(build): consolidate to Bun-native build workflow#1644
tyler-dane merged 4 commits intomainfrom
feat/bun-native-build

Conversation

@tyler-dane
Copy link
Copy Markdown
Contributor

Summary

  • New backend build script (packages/scripts/src/commands/build.backend.ts): uses Bun.build({ target: "bun" }) to bundle the Express app to a single build/backend/app.js; copies the env file for the selected environment; installs only the two native-module externals (saslprep, @ngrok/ngrok) via a minimal package.json
  • Fix app.ts entry-point guard: require.main === moduleimport.meta.main so the server starts correctly from the bundled ESM output
  • Replace shelljs with Bun.$ in build.util.ts; async file existence checks via Bun.file().exists()
  • Remove the build CLI subcommand entirely — web uses bun run build:web, backend uses bun run build:backend; deleted build.ts, build.util.ts, webpack.config.mjs, tsconfig.build.json
  • Strip dead build option plumbing from cli.validator, cli.types, cli.utils, cli.constants
  • Remove unused deps: shelljs/@types/shelljs from scripts package, concurrently from root
  • Update docs: deploy.md and cli-and-maintenance-commands.md updated with correct commands and output paths (build/backend instead of build/node)

Test plan

  • bun run test:scripts — 9 suites, 57 tests, all pass
  • bun run build:backend --environment local — verify build/backend/app.js is produced and bun build/backend/app.js starts the server
  • bun run build:web — verify build/web/ assets are produced
  • bun run dev:backend — verify dev server still starts

🤖 Generated with Claude Code

tyler-dane and others added 4 commits April 14, 2026 00:45
Replace the legacy webpack + tsc + shelljs build pipeline with Bun-native
equivalents throughout the monorepo.

- Add `packages/scripts/src/commands/build.backend.ts`: new backend build
  script using `Bun.build({ target: "bun" })` — bundles app.ts to a single
  `build/backend/app.js`, copies the env file, and installs only the two
  native-module externals (saslprep, @ngrok/ngrok)
- Fix `packages/backend/src/app.ts`: replace `require.main === module` with
  `import.meta.main` so the server starts correctly from the bundled ESM output
- Replace shelljs with `Bun.$` in build.util.ts; make file-check async via
  `Bun.file().exists()`
- Remove the `build` CLI subcommand entirely — web uses `bun run build:web`,
  backend uses `bun run build:backend`; strip the dead build.ts, build.util.ts,
  webpack.config.mjs, and tsconfig.build.json
- Collapse cli.validator, cli.types, cli.utils, cli.constants to remove all
  build-specific option parsing and package list constants
- Drop `shelljs`/`@types/shelljs` from scripts package.json and `concurrently`
  from root package.json
- Update deploy.md and cli-and-maintenance-commands.md to reflect new commands
  and output paths (build/backend instead of build/node)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Bun loads .env from the working directory, not the script's location.
The runtime tip and deploy docs now reflect the correct invocation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tyler-dane tyler-dane merged commit 1bbc988 into main Apr 14, 2026
7 of 8 checks passed
@tyler-dane tyler-dane deleted the feat/bun-native-build branch April 14, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant