### Run Build and Start Server Source: https://github.com/ramonmalcolm10/next-bun-compile/blob/main/README.md Execute the build script to create the executable and then run the compiled server. The server will start on the default port 3000. ```bash bun run build # Builds Next.js + compiles to ./server ./server # Starts on port 3000 ``` -------------------------------- ### Install next-bun-compile Source: https://github.com/ramonmalcolm10/next-bun-compile/blob/main/README.md Add the next-bun-compile package as a development dependency to your project. ```bash bun add -D next-bun-compile ``` -------------------------------- ### Cross-Compile for Different Platforms Source: https://github.com/ramonmalcolm10/next-bun-compile/blob/main/README.md Use the --target flag with next-bun-compile to create executables for specific Bun runtime targets. This allows for cross-platform deployment. ```bash next-bun-compile --target=bun-linux-x64 next-bun-compile --target=bun-linux-arm64 next-bun-compile --target=bun-windows-x64 ``` -------------------------------- ### Build Next.js App Source: https://github.com/ramonmalcolm10/next-bun-compile/blob/main/README.md Build your Next.js application into a single executable file. This command generates the output in the './server' directory. ```bash next build # → ./server (single executable with embedded assets) ``` -------------------------------- ### Configure next-bun-compile in next.config.ts Source: https://github.com/ramonmalcolm10/next-bun-compile/blob/main/README.md Integrate the adapter into your Next.js configuration. This specifies the path to the adapter module. ```typescript import type { NextConfig } from "next"; const nextConfig: NextConfig = { adapterPath: import.meta.resolve("next-bun-compile"), }; export default nextConfig; ``` -------------------------------- ### Experimental Config for Next.js 16.1 Source: https://github.com/ramonmalcolm10/next-bun-compile/blob/main/README.md For Next.js version 16.1, use the experimental configuration object to specify the adapter path. ```typescript const nextConfig: NextConfig = { experimental: { adapterPath: import.meta.resolve("next-bun-compile"), }, }; ``` -------------------------------- ### Update package.json build script Source: https://github.com/ramonmalcolm10/next-bun-compile/blob/main/README.md Modify your package.json to include the next-bun-compile command in your build process. This ensures the app is built and then compiled into a single executable. ```json { "scripts": { "build": "next build && next-bun-compile" } } ``` -------------------------------- ### Fix Stale Standalone Output Source: https://github.com/ramonmalcolm10/next-bun-compile/blob/main/README.md If you encounter errors after upgrading Next.js, clean the standalone output directory before rebuilding. This ensures no stale files interfere with the new build. ```bash rm -rf .next/standalone && bun next build && next-bun-compile ``` -------------------------------- ### Configure assetPrefix for CDN Source: https://github.com/ramonmalcolm10/next-bun-compile/blob/main/README.md When using a CDN for static assets, configure assetPrefix in next.config.ts. The adapter will automatically skip embedding static assets into the binary, resulting in a smaller file size. ```typescript const nextConfig: NextConfig = { assetPrefix: "https://cdn.example.com", adapterPath: import.meta.resolve("next-bun-compile"), }; ``` -------------------------------- ### Configure Transpile Packages for Dynamic Requires Source: https://github.com/ramonmalcolm10/next-bun-compile/blob/main/README.md Add packages with dynamic require() calls to `transpilePackages` in `next.config.ts` to ensure they are fully compiled by Turbopack. This resolves runtime errors related to missing dynamic modules. ```typescript const nextConfig: NextConfig = { transpilePackages: ["pino", "pino-pretty"], adapterPath: import.meta.resolve("next-bun-compile"), }; ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.