nuxt-bun-compile 0.1.0 β 0.1.3
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 -1
- package/README.ptBR.md +11 -0
- package/dist/module.d.mts +13 -0
- package/dist/module.json +9 -0
- package/{src/module.ts β dist/module.mjs} +17 -40
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/runtime/types/bun.d.ts +8 -0
- package/dist/types.d.mts +3 -0
- package/package.json +53 -11
- package/.vscode/extensions.json +0 -14
- package/.vscode/settings.json +0 -15
- package/bun.lock +0 -858
- package/dprint.json +0 -34
- package/nuxt-bun-compile-0.1.0.tgz +0 -0
- package/tsconfig.json +0 -11
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# nuxt-bun-compile
|
|
2
2
|
|
|
3
|
+
[](https://badge.socket.dev/npm/package/nuxt-bun-compile/0.1.0)
|
|
4
|
+
|
|
3
5
|
> π Nuxt module that automatically configures Nitro for `bun build --compile`, generating a **standalone executable binary** from your Nuxt app β zero runtime dependencies needed.
|
|
4
6
|
|
|
5
7
|
[Leia em PortuguΓͺs](README.ptBR.md)
|
|
@@ -58,7 +60,16 @@ That's it. One binary. No `node_modules`. No runtime. Just your app.
|
|
|
58
60
|
|
|
59
61
|
---
|
|
60
62
|
|
|
61
|
-
##
|
|
63
|
+
## π Example
|
|
64
|
+
|
|
65
|
+
Check out a real project using this module:
|
|
66
|
+
|
|
67
|
+
- **Repository:** [nuxt-duckdb-wasm](https://github.com/jprando/nuxt-duckdb-wasm)
|
|
68
|
+
- **Demo:** [https://nuxt-duckdb-wasm.jeudi.workers.dev/](https://nuxt-duckdb-wasm.jeudi.workers.dev/)
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## οΏ½ What It Does
|
|
62
73
|
|
|
63
74
|
The module hooks into Nuxt's build pipeline and handles **everything** automatically:
|
|
64
75
|
|
package/README.ptBR.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# nuxt-bun-compile
|
|
2
2
|
|
|
3
|
+
[](https://badge.socket.dev/npm/package/nuxt-bun-compile/0.1.0)
|
|
4
|
+
|
|
3
5
|
> π Modulo Nuxt que configura automaticamente o Nitro para `bun build --compile`, gerando um **binario executavel standalone** a partir da sua aplicacao Nuxt β sem dependencias de runtime.
|
|
4
6
|
|
|
5
7
|
[Read in English](README.md)
|
|
@@ -58,6 +60,15 @@ So isso. Um binario. Sem `node_modules`. Sem runtime. Apenas sua aplicacao.
|
|
|
58
60
|
|
|
59
61
|
---
|
|
60
62
|
|
|
63
|
+
## π Exemplo
|
|
64
|
+
|
|
65
|
+
Veja um projeto real utilizando este modulo:
|
|
66
|
+
|
|
67
|
+
- **Repositorio:** [nuxt-duckdb-wasm](https://github.com/jprando/nuxt-duckdb-wasm)
|
|
68
|
+
- **Demo:** [https://nuxt-duckdb-wasm.jeudi.workers.dev/](https://nuxt-duckdb-wasm.jeudi.workers.dev/)
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
61
72
|
## π― O que faz
|
|
62
73
|
|
|
63
74
|
O modulo se conecta ao pipeline de build do Nuxt e cuida de **tudo** automaticamente:
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
|
|
3
|
+
interface ModuleOptions {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
outfile: string;
|
|
6
|
+
extraExternals: (string | RegExp)[];
|
|
7
|
+
autoCompile: boolean;
|
|
8
|
+
bunPath?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
11
|
+
|
|
12
|
+
export { _default as default };
|
|
13
|
+
export type { ModuleOptions };
|
package/dist/module.json
ADDED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
import { defineNuxtModule, useLogger } from
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import { statSync } from "node:fs";
|
|
6
|
-
import { join } from "node:path";
|
|
1
|
+
import { defineNuxtModule, useLogger } from '@nuxt/kit';
|
|
2
|
+
import { execSync } from 'node:child_process';
|
|
3
|
+
import { statSync } from 'node:fs';
|
|
4
|
+
import { join } from 'node:path';
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
enabled: boolean;
|
|
10
|
-
outfile: string;
|
|
11
|
-
extraExternals: (string | RegExp)[];
|
|
12
|
-
autoCompile: boolean;
|
|
13
|
-
bunPath?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const DEFAULT_EXTERNALS: (string | RegExp)[] = [
|
|
6
|
+
const DEFAULT_EXTERNALS = [
|
|
17
7
|
"sharp",
|
|
18
8
|
/^@img\//,
|
|
19
9
|
"css-tree",
|
|
@@ -22,64 +12,51 @@ const DEFAULT_EXTERNALS: (string | RegExp)[] = [
|
|
|
22
12
|
/^csso\//,
|
|
23
13
|
"svgo",
|
|
24
14
|
"mdn-data",
|
|
25
|
-
/^mdn-data
|
|
15
|
+
/^mdn-data\//
|
|
26
16
|
];
|
|
27
|
-
|
|
28
|
-
export default defineNuxtModule<ModuleOptions>({
|
|
17
|
+
const module$1 = defineNuxtModule({
|
|
29
18
|
meta: {
|
|
30
19
|
name: "nuxt-bun-compile",
|
|
31
|
-
configKey: "bunCompile"
|
|
20
|
+
configKey: "bunCompile"
|
|
32
21
|
},
|
|
33
22
|
defaults: {
|
|
34
23
|
enabled: true,
|
|
35
24
|
outfile: "nuxtbin",
|
|
36
25
|
extraExternals: [],
|
|
37
|
-
autoCompile: true
|
|
26
|
+
autoCompile: true
|
|
38
27
|
},
|
|
39
|
-
setup(options
|
|
28
|
+
setup(options, nuxt) {
|
|
40
29
|
if (!options.enabled) return;
|
|
41
|
-
|
|
42
30
|
const logger = useLogger("nuxt-bun-compile");
|
|
43
|
-
|
|
44
|
-
// Configure Nitro for bun compile
|
|
45
|
-
nuxt.hook("nitro:config" as any, (nitroConfig: NitroConfig) => {
|
|
31
|
+
nuxt.hook("nitro:config", (nitroConfig) => {
|
|
46
32
|
logger.info("Configuring Nitro for bun --compile build");
|
|
47
|
-
|
|
48
33
|
nitroConfig.preset = "bun";
|
|
49
34
|
nitroConfig.noExternals = true;
|
|
50
35
|
nitroConfig.inlineDynamicImports = true;
|
|
51
36
|
nitroConfig.serveStatic = "inline";
|
|
52
|
-
|
|
53
37
|
nitroConfig.esbuild = nitroConfig.esbuild || {};
|
|
54
38
|
nitroConfig.esbuild.options = nitroConfig.esbuild.options || {};
|
|
55
39
|
nitroConfig.esbuild.options.target = "esnext";
|
|
56
|
-
|
|
57
40
|
const allExternals = [...DEFAULT_EXTERNALS, ...options.extraExternals];
|
|
58
|
-
|
|
59
41
|
nitroConfig.rollupConfig = nitroConfig.rollupConfig || {};
|
|
60
42
|
const existing = nitroConfig.rollupConfig.external;
|
|
61
43
|
if (Array.isArray(existing)) {
|
|
62
44
|
nitroConfig.rollupConfig.external = [...existing, ...allExternals];
|
|
63
45
|
} else if (existing) {
|
|
64
|
-
nitroConfig.rollupConfig.external = [existing
|
|
46
|
+
nitroConfig.rollupConfig.external = [existing, ...allExternals];
|
|
65
47
|
} else {
|
|
66
48
|
nitroConfig.rollupConfig.external = allExternals;
|
|
67
49
|
}
|
|
68
|
-
|
|
69
|
-
// Auto-compile after Nitro build completes
|
|
70
50
|
if (options.autoCompile) {
|
|
71
51
|
nitroConfig.hooks = nitroConfig.hooks || {};
|
|
72
52
|
nitroConfig.hooks.compiled = () => {
|
|
73
|
-
const isBun = typeof
|
|
74
|
-
|| process.versions.bun !== undefined;
|
|
75
|
-
|
|
53
|
+
const isBun = typeof globalThis.Bun !== "undefined" || process.versions.bun !== void 0;
|
|
76
54
|
if (!isBun) {
|
|
77
55
|
logger.warn("Bun runtime not detected, skipping --compile step. Run with bun to enable.");
|
|
78
56
|
logger.info("Try running: bun run -b build");
|
|
79
57
|
logger.info("Read more: https://github.com/jprando/nuxt-bun-compile?tab=readme-ov-file#why-is--b-required");
|
|
80
58
|
return;
|
|
81
59
|
}
|
|
82
|
-
|
|
83
60
|
const outputPath = ".output/server/index.mjs";
|
|
84
61
|
let bunExecutable = "bun";
|
|
85
62
|
if (options.bunPath) {
|
|
@@ -90,14 +67,12 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
90
67
|
} else {
|
|
91
68
|
bunExecutable = options.bunPath;
|
|
92
69
|
}
|
|
93
|
-
} catch
|
|
70
|
+
} catch {
|
|
94
71
|
logger.warn(`Could not stat bunPath "${options.bunPath}", assuming it's a direct path.`);
|
|
95
72
|
bunExecutable = options.bunPath;
|
|
96
73
|
}
|
|
97
74
|
}
|
|
98
|
-
|
|
99
75
|
const cmd = `${bunExecutable} build ${outputPath} --compile --outfile ${options.outfile}`;
|
|
100
|
-
|
|
101
76
|
logger.info(`Bun v${process.versions.bun} detected, running --compile step`);
|
|
102
77
|
logger.info(`Compiling binary: ${cmd}`);
|
|
103
78
|
try {
|
|
@@ -109,5 +84,7 @@ export default defineNuxtModule<ModuleOptions>({
|
|
|
109
84
|
};
|
|
110
85
|
}
|
|
111
86
|
});
|
|
112
|
-
}
|
|
87
|
+
}
|
|
113
88
|
});
|
|
89
|
+
|
|
90
|
+
export { module$1 as default };
|
package/dist/types.d.mts
ADDED
package/package.json
CHANGED
|
@@ -1,26 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-bun-compile",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Nuxt module that automatically configures Nitro for `bun build --compile`, generating a standalone executable binary from your Nuxt app.",
|
|
5
|
+
"repository": "jprando/nuxt-bun-compile",
|
|
6
|
+
"license": "MIT",
|
|
4
7
|
"type": "module",
|
|
5
|
-
"
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/types.d.mts",
|
|
11
|
+
"import": "./dist/module.mjs"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"main": "./dist/module.mjs",
|
|
15
|
+
"typesVersions": {
|
|
16
|
+
"*": {
|
|
17
|
+
".": [
|
|
18
|
+
"./dist/types.d.mts"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"workspaces": [
|
|
26
|
+
"playground"
|
|
27
|
+
],
|
|
6
28
|
"scripts": {
|
|
7
|
-
"
|
|
29
|
+
"prepack": "nuxt-module-build build",
|
|
30
|
+
"dev": "npm run dev:prepare && nuxt dev playground",
|
|
31
|
+
"dev:build": "nuxt build playground",
|
|
32
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt prepare playground",
|
|
33
|
+
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
|
|
34
|
+
"lint": "eslint .",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"test:watch": "vitest watch",
|
|
37
|
+
"test:types": "vue-tsc --noEmit && cd playground && vue-tsc --noEmit",
|
|
38
|
+
"format": "dprint fmt package.json tsconfig.json dprint.json ./src/*.ts ./src/**/*.ts",
|
|
39
|
+
"prepare": "husky"
|
|
8
40
|
},
|
|
9
41
|
"dependencies": {
|
|
10
|
-
"@nuxt/kit": "^3.
|
|
11
|
-
"@nuxt/schema": "^4.3.1"
|
|
42
|
+
"@nuxt/kit": "^4.3.1"
|
|
12
43
|
},
|
|
13
44
|
"devDependencies": {
|
|
14
|
-
"@
|
|
45
|
+
"@nuxt/devtools": "^3.1.1",
|
|
46
|
+
"@nuxt/eslint-config": "^1.14.0",
|
|
47
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
48
|
+
"@nuxt/schema": "^4.3.1",
|
|
49
|
+
"@nuxt/test-utils": "^4.0.0",
|
|
50
|
+
"@types/bun": "^1.3.9",
|
|
51
|
+
"@types/node": "latest",
|
|
52
|
+
"changelogen": "^0.6.2",
|
|
15
53
|
"dprint": "^0.51.1",
|
|
16
|
-
"
|
|
54
|
+
"eslint": "^10.0.0",
|
|
55
|
+
"husky": "^9.1.7",
|
|
56
|
+
"nuxt": "^4.3.1",
|
|
57
|
+
"typescript": "~5.9.3",
|
|
58
|
+
"vitest": "^4.0.18",
|
|
59
|
+
"vue-tsc": "^3.2.4"
|
|
17
60
|
},
|
|
18
61
|
"packageManager": "bun@1.3.9",
|
|
19
62
|
"engines": {
|
|
20
|
-
"node": "^24.13.1",
|
|
21
|
-
"npm": "^11.10.0",
|
|
22
|
-
"pnpm": "^10.29.3",
|
|
23
63
|
"bun": "^1.3.9"
|
|
24
64
|
},
|
|
25
|
-
"trustedDependencies": [
|
|
65
|
+
"trustedDependencies": [
|
|
66
|
+
"dprint"
|
|
67
|
+
]
|
|
26
68
|
}
|
package/.vscode/extensions.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"recommendations": [
|
|
3
|
-
"dprint.dprint",
|
|
4
|
-
"nuxtr.nuxtr-vscode",
|
|
5
|
-
"usernamehw.errorlens",
|
|
6
|
-
"oderwat.indent-rainbow",
|
|
7
|
-
"ms-vscode.vscode-typescript-next",
|
|
8
|
-
"davidanson.vscode-markdownlint",
|
|
9
|
-
"pkief.material-icon-theme",
|
|
10
|
-
"yoavbls.pretty-ts-errors",
|
|
11
|
-
"pflannery.vscode-versionlens",
|
|
12
|
-
"fab1o.dark-plus-with-italics"
|
|
13
|
-
]
|
|
14
|
-
}
|
package/.vscode/settings.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"dprint.path": "./node_modules/.bin/dprint",
|
|
3
|
-
"editor.formatOnSave": true,
|
|
4
|
-
"editor.formatOnSaveMode": "modificationsIfAvailable",
|
|
5
|
-
"files.trimTrailingWhitespace": true,
|
|
6
|
-
"explorer.fileNesting.enabled": true,
|
|
7
|
-
"editor.defaultFormatter": "dprint.dprint",
|
|
8
|
-
"editor.gotoLocation.multipleDefinitions": "goto",
|
|
9
|
-
"editor.gotoLocation.multipleTypeDefinitions": "goto",
|
|
10
|
-
"editor.rulers": [
|
|
11
|
-
80,
|
|
12
|
-
100,
|
|
13
|
-
120
|
|
14
|
-
]
|
|
15
|
-
}
|