next-bun-compile 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/cli.js +5 -3
- package/dist/compile.js +3 -2
- package/dist/index.js +10 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,6 +54,18 @@ bun run build # Builds Next.js + compiles to ./server
|
|
|
54
54
|
|
|
55
55
|
The binary is fully self-contained — static assets, public files, and the Next.js server are all embedded. Just copy it anywhere and run.
|
|
56
56
|
|
|
57
|
+
### Cross-Compilation
|
|
58
|
+
|
|
59
|
+
Any flags passed to `next-bun-compile` are forwarded to `bun build --compile`. Use `--target` to cross-compile for a different platform:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
next-bun-compile --target=bun-linux-x64
|
|
63
|
+
next-bun-compile --target=bun-linux-arm64
|
|
64
|
+
next-bun-compile --target=bun-windows-x64
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
See the [Bun cross-compilation docs](https://bun.sh/docs/bundler/executables#cross-compile) for all available targets.
|
|
68
|
+
|
|
57
69
|
### Environment Variables
|
|
58
70
|
|
|
59
71
|
| Variable | Default | Description |
|
package/dist/cli.js
CHANGED
|
@@ -158,7 +158,7 @@ extractAssets().then(() => {
|
|
|
158
158
|
import { execFileSync } from "node:child_process";
|
|
159
159
|
import { join as join2 } from "node:path";
|
|
160
160
|
function compile(options) {
|
|
161
|
-
const { standaloneDir, outfile } = options;
|
|
161
|
+
const { standaloneDir, outfile, extraArgs = [] } = options;
|
|
162
162
|
const entryPoint = join2(standaloneDir, "server-entry.js");
|
|
163
163
|
const args = [
|
|
164
164
|
"build",
|
|
@@ -175,7 +175,8 @@ function compile(options) {
|
|
|
175
175
|
"--define",
|
|
176
176
|
'process.env.NEXT_RUNTIME="nodejs"',
|
|
177
177
|
"--outfile",
|
|
178
|
-
outfile
|
|
178
|
+
outfile,
|
|
179
|
+
...extraArgs
|
|
179
180
|
];
|
|
180
181
|
console.log(`next-bun-compile: Compiling to ${outfile}...`);
|
|
181
182
|
execFileSync("bun", args, { stdio: "inherit" });
|
|
@@ -185,6 +186,7 @@ function compile(options) {
|
|
|
185
186
|
// src/cli.ts
|
|
186
187
|
import { existsSync as existsSync2 } from "node:fs";
|
|
187
188
|
import { join as join3, resolve } from "node:path";
|
|
189
|
+
var extraArgs = process.argv.slice(2);
|
|
188
190
|
var projectDir = resolve(".");
|
|
189
191
|
var distDir = join3(projectDir, ".next");
|
|
190
192
|
var standaloneDir = join3(distDir, "standalone");
|
|
@@ -197,4 +199,4 @@ if (existsSync2(ctxPath)) {
|
|
|
197
199
|
console.log("next-bun-compile: Using build context from adapter");
|
|
198
200
|
}
|
|
199
201
|
generateEntryPoint({ standaloneDir, distDir, projectDir });
|
|
200
|
-
compile({ standaloneDir, outfile: join3(projectDir, "server") });
|
|
202
|
+
compile({ standaloneDir, outfile: join3(projectDir, "server"), extraArgs });
|
package/dist/compile.js
CHANGED
|
@@ -5,7 +5,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
5
5
|
import { execFileSync } from "node:child_process";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
function compile(options) {
|
|
8
|
-
const { standaloneDir, outfile } = options;
|
|
8
|
+
const { standaloneDir, outfile, extraArgs = [] } = options;
|
|
9
9
|
const entryPoint = join(standaloneDir, "server-entry.js");
|
|
10
10
|
const args = [
|
|
11
11
|
"build",
|
|
@@ -22,7 +22,8 @@ function compile(options) {
|
|
|
22
22
|
"--define",
|
|
23
23
|
'process.env.NEXT_RUNTIME="nodejs"',
|
|
24
24
|
"--outfile",
|
|
25
|
-
outfile
|
|
25
|
+
outfile,
|
|
26
|
+
...extraArgs
|
|
26
27
|
];
|
|
27
28
|
console.log(`next-bun-compile: Compiling to ${outfile}...`);
|
|
28
29
|
execFileSync("bun", args, { stdio: "inherit" });
|
package/dist/index.js
CHANGED
|
@@ -157,7 +157,7 @@ extractAssets().then(() => {
|
|
|
157
157
|
import { execFileSync } from "node:child_process";
|
|
158
158
|
import { join as join2 } from "node:path";
|
|
159
159
|
function compile(options) {
|
|
160
|
-
const { standaloneDir, outfile } = options;
|
|
160
|
+
const { standaloneDir, outfile, extraArgs = [] } = options;
|
|
161
161
|
const entryPoint = join2(standaloneDir, "server-entry.js");
|
|
162
162
|
const args = [
|
|
163
163
|
"build",
|
|
@@ -174,7 +174,8 @@ function compile(options) {
|
|
|
174
174
|
"--define",
|
|
175
175
|
'process.env.NEXT_RUNTIME="nodejs"',
|
|
176
176
|
"--outfile",
|
|
177
|
-
outfile
|
|
177
|
+
outfile,
|
|
178
|
+
...extraArgs
|
|
178
179
|
];
|
|
179
180
|
console.log(`next-bun-compile: Compiling to ${outfile}...`);
|
|
180
181
|
execFileSync("bun", args, { stdio: "inherit" });
|
|
@@ -187,8 +188,14 @@ var knownTranspilePackages = ["pino", "pino-pretty"];
|
|
|
187
188
|
var adapter = {
|
|
188
189
|
name: "next-bun-compile",
|
|
189
190
|
modifyConfig(config, ctx) {
|
|
190
|
-
if (ctx
|
|
191
|
+
if (!ctx) {
|
|
192
|
+
throw new Error("next-bun-compile: Next.js 16+ is required. Please upgrade your Next.js version.");
|
|
193
|
+
}
|
|
194
|
+
if (ctx.phase !== "phase-production-build")
|
|
191
195
|
return config;
|
|
196
|
+
if (process.argv.includes("--webpack")) {
|
|
197
|
+
throw new Error("next-bun-compile: Webpack builds are not supported. Remove --webpack to use Turbopack (default).");
|
|
198
|
+
}
|
|
192
199
|
if (config.output !== "standalone") {
|
|
193
200
|
console.warn('next-bun-compile: Setting output to "standalone" (required for compilation)');
|
|
194
201
|
config.output = "standalone";
|