nuxt-bun-compile 0.1.22 → 0.1.24
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/dist/module.json +1 -1
- package/dist/module.mjs +30 -5
- package/package.json +1 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { defineNuxtModule, useLogger } from '@nuxt/kit';
|
|
2
2
|
import { execFileSync } from 'node:child_process';
|
|
3
|
-
import { statSync } from 'node:fs';
|
|
3
|
+
import { statSync, readFileSync } from 'node:fs';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
|
|
6
6
|
const VALID_TARGETS = [
|
|
7
7
|
"bun-linux-x64",
|
|
8
|
+
// glibc (padrão)
|
|
8
9
|
"bun-linux-x64-musl",
|
|
10
|
+
// musl (Alpine)
|
|
9
11
|
"bun-linux-arm64",
|
|
12
|
+
// glibc ARM
|
|
10
13
|
"bun-linux-arm64-musl"
|
|
14
|
+
// musl ARM (Alpine)
|
|
11
15
|
];
|
|
12
16
|
const DEFAULT_EXTERNALS = [
|
|
13
17
|
"sharp",
|
|
@@ -20,6 +24,25 @@ const DEFAULT_EXTERNALS = [
|
|
|
20
24
|
"mdn-data",
|
|
21
25
|
/^mdn-data\//
|
|
22
26
|
];
|
|
27
|
+
function detectMusl() {
|
|
28
|
+
try {
|
|
29
|
+
const ldd = execFileSync("ldd", ["--version"], { encoding: "utf8", stdio: "pipe" });
|
|
30
|
+
return ldd.includes("musl");
|
|
31
|
+
} catch {
|
|
32
|
+
try {
|
|
33
|
+
const osRelease = readFileSync("/etc/os-release", "utf8");
|
|
34
|
+
return osRelease.includes("alpine") || osRelease.includes("musl");
|
|
35
|
+
} catch {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function detectTarget() {
|
|
41
|
+
const arch = process.arch === "arm64" ? "arm64" : "x64";
|
|
42
|
+
const isMusl = detectMusl();
|
|
43
|
+
const target = `bun-linux-${arch}${isMusl ? "-musl" : ""}`;
|
|
44
|
+
return target;
|
|
45
|
+
}
|
|
23
46
|
const module$1 = defineNuxtModule({
|
|
24
47
|
meta: {
|
|
25
48
|
name: "nuxt-bun-compile",
|
|
@@ -88,13 +111,15 @@ const module$1 = defineNuxtModule({
|
|
|
88
111
|
bunExecutable = options.bunPath;
|
|
89
112
|
}
|
|
90
113
|
}
|
|
91
|
-
|
|
92
|
-
|
|
114
|
+
const selectedTarget = options.target || detectTarget();
|
|
115
|
+
if (!VALID_TARGETS.includes(selectedTarget)) {
|
|
116
|
+
logger.error(`Invalid target: "${selectedTarget}". Must be one of: ${VALID_TARGETS.join(", ")}`);
|
|
93
117
|
return;
|
|
94
118
|
}
|
|
95
119
|
const args = ["build", outputPath, "--compile", "--outfile", options.outfile];
|
|
96
|
-
|
|
97
|
-
|
|
120
|
+
args.push("--target", selectedTarget);
|
|
121
|
+
if (!options.target) {
|
|
122
|
+
logger.info(`Target auto-detected: ${selectedTarget}`);
|
|
98
123
|
}
|
|
99
124
|
logger.info(`Bun v${process.versions.bun} detected, running bun compile step`);
|
|
100
125
|
logger.info(`Compiling binary: ${bunExecutable} ${args.join(" ")}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-bun-compile",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"description": "Nuxt module that automatically configures Nitro for `bun build --compile`, generating a standalone executable binary from your Nuxt app.",
|
|
5
5
|
"repository": "jprando/nuxt-bun-compile",
|
|
6
6
|
"license": "MIT",
|