build.ts 1017 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env bun
  2. /**
  3. * Build script for Claude Code from leaked source.
  4. *
  5. * Usage: bun build.ts
  6. */
  7. import { $ } from 'bun';
  8. const version = process.env.VERSION || '2.1.88';
  9. const buildTime = new Date().toISOString();
  10. console.log(`Building Claude Code v${version}...`);
  11. const result = await Bun.build({
  12. entrypoints: ['src/entrypoints/cli.tsx'],
  13. outdir: 'dist',
  14. target: 'bun',
  15. sourcemap: 'linked',
  16. define: {
  17. 'MACRO.VERSION': JSON.stringify(version),
  18. 'MACRO.BUILD_TIME': JSON.stringify(buildTime),
  19. 'MACRO.FEEDBACK_CHANNEL': JSON.stringify('#claude-code'),
  20. 'MACRO.ISSUES_EXPLAINER': JSON.stringify(
  21. 'report the issue at https://github.com/anthropics/claude-code/issues',
  22. ),
  23. },
  24. external: ['react-devtools-core', 'sharp'],
  25. });
  26. if (!result.success) {
  27. console.error('Build failed:');
  28. for (const log of result.logs) {
  29. console.error(log);
  30. }
  31. process.exit(1);
  32. }
  33. console.log(`Build succeeded: dist/cli.js (${(result.outputs[0]!.size / 1024 / 1024).toFixed(1)} MB)`);