DEV Community

Cristian Torres
Cristian Torres

Posted on

1

Compile standalone NextApp using bun

  1. Create index.ts:
import { createServer } from "node:http";
import next from "next";

const dev = process.env.NODE_ENV !== "production";
const app = next({ dev, turbo: true, turbopack: true });
const handle = app.getRequestHandler();

app.prepare().then(() => {
    createServer((req, res) => {
        try {
            handle(req, res);
        } catch(e: any) {
            console.log(e.message)
        }
    }).listen(3000)
    console.log("Server is running on http://localhost:3000");
});
Enter fullscreen mode Exit fullscreen mode
  1. Run the following command in the terminal, change --target to match your system:
bun build --target=bun-darwin-x64 --external=uglify-js --minify --compile index.ts && ll index && ./index
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more