nuxt-bun-compile 0.1.17 → 0.1.18
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 +18 -95
- package/README.ptBR.md +54 -131
- package/dist/module.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,25 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
>
|
|
15
|
-
> The following commands **DO NOT** trigger binary compilation:
|
|
16
|
-
> ```bash
|
|
17
|
-
> bun run build # ❌ does not generate the binary
|
|
18
|
-
> npm run build # ❌ does not generate the binary
|
|
19
|
-
> pnpm run build # ❌ does not generate the binary
|
|
20
|
-
> ```
|
|
21
|
-
>
|
|
22
|
-
> The correct command is:
|
|
23
|
-
> ```bash
|
|
24
|
-
> bun run -b build # ✅ generates the binary (nuxtbin or the name set in outfile)
|
|
25
|
-
> ```
|
|
26
|
-
>
|
|
27
|
-
> [Why is `-b` required?](https://github.com/jprando/nuxt-bun-compile?tab=readme-ov-file#why-is--b-required)
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
## 🚀 Super Flash Start
|
|
13
|
+
## ⚡ Quick Start
|
|
32
14
|
|
|
33
15
|
Add the module to any Nuxt project in two steps:
|
|
34
16
|
|
|
@@ -44,56 +26,23 @@ bun nuxt add nuxt-bun-compile
|
|
|
44
26
|
bun run -b build
|
|
45
27
|
```
|
|
46
28
|
|
|
47
|
-
|
|
29
|
+
[Why is `-b` required?](https://github.com/jprando/nuxt-bun-compile?tab=readme-ov-file#why-is--b-required)
|
|
48
30
|
|
|
49
|
-
|
|
31
|
+
[If you encounter memory issues during build](https://github.com/jprando/nuxt-bun-compile?tab=readme-ov-file#why-node_options--max-old-space-size8192)
|
|
50
32
|
|
|
51
|
-
|
|
33
|
+
**Step 3: Run your binary**
|
|
52
34
|
|
|
53
35
|
```bash
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
# Or install directly from GitHub
|
|
58
|
-
bun add -D github:jprando/nuxt-bun-compile
|
|
59
|
-
|
|
60
|
-
# Or link locally for development
|
|
61
|
-
git clone https://github.com/jprando/nuxt-bun-compile.git
|
|
62
|
-
cd nuxt-bun-compile && bun install && bun link
|
|
63
|
-
cd your-nuxt-app && bun link nuxt-bun-compile && bun nuxt add nuxt-bun-compile
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Add to your `nuxt.config.ts`:
|
|
67
|
-
|
|
68
|
-
```ts
|
|
69
|
-
export default defineNuxtConfig({
|
|
70
|
-
modules: ["nuxt-bun-compile"],
|
|
71
|
-
bunCompile: {
|
|
72
|
-
outfile: "myapp",
|
|
73
|
-
},
|
|
74
|
-
})
|
|
36
|
+
./nuxtbin
|
|
37
|
+
# Listening on http://localhost:3000
|
|
75
38
|
```
|
|
76
39
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
NODE_OPTIONS="--max-old-space-size=8192" bun run -b build
|
|
81
|
-
./myapp
|
|
82
|
-
```
|
|
40
|
+
Done! Your standalone binary is ready.
|
|
83
41
|
|
|
84
42
|
That's it. One binary. No `node_modules`. No runtime. Just your app.
|
|
85
43
|
|
|
86
44
|
---
|
|
87
45
|
|
|
88
|
-
## 🌟 Example
|
|
89
|
-
|
|
90
|
-
Check out a real project using this module:
|
|
91
|
-
|
|
92
|
-
- **Repository:** [nuxt-duckdb-wasm](https://github.com/jprando/nuxt-duckdb-wasm)
|
|
93
|
-
- **Demo:** [https://nuxt-duckdb-wasm.jeudi.workers.dev/](https://nuxt-duckdb-wasm.jeudi.workers.dev/)
|
|
94
|
-
|
|
95
|
-
---
|
|
96
|
-
|
|
97
46
|
## 🎯 What It Does
|
|
98
47
|
|
|
99
48
|
The module hooks into Nuxt's build pipeline and handles **everything** automatically:
|
|
@@ -153,14 +102,6 @@ bunCompile: {
|
|
|
153
102
|
|
|
154
103
|
## 🏗️ Architecture
|
|
155
104
|
|
|
156
|
-
```
|
|
157
|
-
src/
|
|
158
|
-
module.ts # Main module — configures Nitro + auto-compiles
|
|
159
|
-
package.json
|
|
160
|
-
tsconfig.json
|
|
161
|
-
dprint.json # Code formatter config
|
|
162
|
-
```
|
|
163
|
-
|
|
164
105
|
The module uses a **hook-based architecture**:
|
|
165
106
|
|
|
166
107
|
- **`nitro:config`** — Adjusts Nitro settings (preset, externals, bundling)
|
|
@@ -200,7 +141,7 @@ The **`-b`** (or `--bun`) flag forces Bun to be the runtime that executes the sc
|
|
|
200
141
|
|---|---|---|
|
|
201
142
|
| 🔤 | **TypeScript** | ESNext target, strict mode, bundler resolution |
|
|
202
143
|
| 🐰 | **Bun** | Runtime 1.3.9+, package manager |
|
|
203
|
-
| 💚 | **Nuxt** |
|
|
144
|
+
| 💚 | **Nuxt** | 4.x |
|
|
204
145
|
| 📐 | **dprint** | Code formatter (TS, JSON, MD, TOML, YAML, and more) |
|
|
205
146
|
| 📦 | **ESM** | Pure ES modules (`"type": "module"`) |
|
|
206
147
|
|
|
@@ -208,43 +149,25 @@ The **`-b`** (or `--bun`) flag forces Bun to be the runtime that executes the sc
|
|
|
208
149
|
|
|
209
150
|
## 🧑💻 Development
|
|
210
151
|
|
|
211
|
-
### Commands
|
|
212
|
-
|
|
213
|
-
```bash
|
|
214
|
-
# Install dependencies
|
|
215
|
-
bun install
|
|
216
|
-
|
|
217
|
-
# Format code
|
|
218
|
-
bun run format
|
|
219
|
-
|
|
220
|
-
# Link for local testing
|
|
221
|
-
bun link
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### Code Style
|
|
225
|
-
|
|
226
|
-
- **Formatter:** dprint — always run `bun run format` before committing
|
|
227
|
-
- **Strings:** Double quotes
|
|
228
|
-
- **Semicolons:** Yes
|
|
229
|
-
- **Constants:** `UPPER_SNAKE_CASE` for module-level (`DEFAULT_EXTERNALS`)
|
|
230
|
-
- **Types:** `interface` for public APIs, `import type` for type-only imports
|
|
231
|
-
- **Node built-ins:** Use `node:` prefix (e.g. `node:child_process`)
|
|
232
|
-
|
|
233
152
|
### Testing Locally in a Nuxt App
|
|
234
153
|
|
|
235
154
|
```bash
|
|
236
|
-
# 1.
|
|
237
|
-
|
|
155
|
+
# 1. Clone this repo for local development
|
|
156
|
+
git clone https://github.com/jprando/nuxt-bun-compile.git
|
|
238
157
|
|
|
239
|
-
# 2.
|
|
158
|
+
# 2. Link the module
|
|
159
|
+
cd nuxt-bun-compile && bun install && bun prepack && bun link
|
|
160
|
+
|
|
161
|
+
# 3. Use it in your Nuxt app
|
|
240
162
|
cd your-nuxt-app && bun link nuxt-bun-compile
|
|
241
163
|
|
|
242
|
-
#
|
|
164
|
+
# 4. Add to nuxt.config.ts modules array
|
|
165
|
+
bun nuxt add nuxt-bun-compile
|
|
243
166
|
|
|
244
|
-
#
|
|
167
|
+
# 5. Build
|
|
245
168
|
NODE_OPTIONS="--max-old-space-size=8192" bun run -b build
|
|
246
169
|
|
|
247
|
-
#
|
|
170
|
+
# 6. Run the binary
|
|
248
171
|
./nuxtbin
|
|
249
172
|
```
|
|
250
173
|
|
package/README.ptBR.md
CHANGED
|
@@ -4,131 +4,80 @@
|
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
7
|
-
> 🚀
|
|
7
|
+
> 🚀 Módulo Nuxt que configura automaticamente o Nitro para `bun build --compile`, gerando um **binário executável standalone** a partir da sua aplicação Nuxt — sem dependências de runtime.
|
|
8
8
|
|
|
9
9
|
[Read in English](README.md)
|
|
10
10
|
|
|
11
11
|
---
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
>
|
|
15
|
-
> Os comandos abaixo **NAO** acionam a compilacao do binario:
|
|
16
|
-
> ```bash
|
|
17
|
-
> bun run build # ❌ nao gera o binario
|
|
18
|
-
> npm run build # ❌ nao gera o binario
|
|
19
|
-
> pnpm run build # ❌ nao gera o binario
|
|
20
|
-
> ```
|
|
21
|
-
>
|
|
22
|
-
> O comando correto eh:
|
|
23
|
-
> ```bash
|
|
24
|
-
> bun run -b build # ✅ gera o binario (nuxtbin ou o nome definido em outfile)
|
|
25
|
-
> ```
|
|
26
|
-
>
|
|
27
|
-
> [Por que é necessário o parâmetro `-b`?](https://github.com/jprando/nuxt-bun-compile/blob/main/README.ptBR.md#por-que-o--b-eh-obrigatorio)
|
|
13
|
+
## ⚡ Início Rápido
|
|
28
14
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
## 🚀 Super Flash Start
|
|
32
|
-
|
|
33
|
-
Adicione o modulo a qualquer projeto Nuxt em dois passos:
|
|
15
|
+
Adicione o módulo a qualquer projeto Nuxt em dois passos:
|
|
34
16
|
|
|
35
|
-
**Passo 1: Instalar o
|
|
17
|
+
**Passo 1: Instalar o módulo**
|
|
36
18
|
|
|
37
19
|
```bash
|
|
38
20
|
bun nuxt add nuxt-bun-compile
|
|
39
21
|
```
|
|
40
22
|
|
|
41
|
-
**Passo 2:
|
|
23
|
+
**Passo 2: Compilar seu binário**
|
|
42
24
|
|
|
43
25
|
```bash
|
|
44
26
|
bun run -b build
|
|
45
27
|
```
|
|
46
28
|
|
|
47
|
-
|
|
29
|
+
[Por que é necessário o parâmetro `-b`?](https://github.com/jprando/nuxt-bun-compile?tab=readme-ov-file#por-que--b-eh-obrigatorio)
|
|
48
30
|
|
|
49
|
-
---
|
|
31
|
+
[Se você enfrentar problemas de memória durante a compilação](https://github.com/jprando/nuxt-bun-compile?tab=readme-ov-file#por-que-node_options---max-old-space-size8192)
|
|
50
32
|
|
|
51
|
-
|
|
33
|
+
**Passo 3: Executar seu binário**
|
|
52
34
|
|
|
53
35
|
```bash
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
# Instalar diretamente do GitHub
|
|
58
|
-
bun add -D github:jprando/nuxt-bun-compile
|
|
59
|
-
|
|
60
|
-
# Ou linkar localmente para desenvolvimento
|
|
61
|
-
git clone https://github.com/jprando/nuxt-bun-compile.git
|
|
62
|
-
cd nuxt-bun-compile && bun install && bun link
|
|
63
|
-
cd sua-app-nuxt && bun link nuxt-bun-compile && bun nuxt add nuxt-bun-compile
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Adicione ao seu `nuxt.config.ts`:
|
|
67
|
-
|
|
68
|
-
```ts
|
|
69
|
-
export default defineNuxtConfig({
|
|
70
|
-
modules: ["nuxt-bun-compile"],
|
|
71
|
-
bunCompile: {
|
|
72
|
-
outfile: "myapp",
|
|
73
|
-
},
|
|
74
|
-
})
|
|
36
|
+
./nuxtbin
|
|
37
|
+
# Listening on http://localhost:3000
|
|
75
38
|
```
|
|
76
39
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
NODE_OPTIONS="--max-old-space-size=8192" bun run -b build
|
|
81
|
-
./myapp
|
|
82
|
-
```
|
|
40
|
+
Pronto! Seu binário standalone está pronto.
|
|
83
41
|
|
|
84
|
-
|
|
42
|
+
Só um binário. Sem `node_modules`. Sem runtime. Apenas sua aplicação.
|
|
85
43
|
|
|
86
44
|
---
|
|
87
45
|
|
|
88
|
-
##
|
|
46
|
+
## 🎯 O que Faz
|
|
89
47
|
|
|
90
|
-
|
|
48
|
+
O módulo se conecta ao pipeline de build do Nuxt e cuida de **tudo** automaticamente:
|
|
91
49
|
|
|
92
|
-
|
|
93
|
-
|
|
50
|
+
1. **Configura o Nitro** com as configurações ótimas para compilação em binário
|
|
51
|
+
2. **Externaliza pacotes problemáticos** que quebram com bundling completo
|
|
52
|
+
3. **Executa `bun build --compile`** após o build para produzir um executável standalone
|
|
94
53
|
|
|
95
|
-
|
|
54
|
+
### Configuração do Nitro (aplicada automaticamente)
|
|
96
55
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
O modulo se conecta ao pipeline de build do Nuxt e cuida de **tudo** automaticamente:
|
|
100
|
-
|
|
101
|
-
1. **Configura o Nitro** com as configuracoes otimas para compilacao em binario
|
|
102
|
-
2. **Externaliza pacotes problematicos** que quebram com bundling completo
|
|
103
|
-
3. **Executa `bun build --compile`** apos o build para produzir um executavel standalone
|
|
104
|
-
|
|
105
|
-
### Configuracao do Nitro (aplicada automaticamente)
|
|
106
|
-
|
|
107
|
-
| Configuracao | Valor | Motivo |
|
|
56
|
+
| Configuração | Valor | Motivo |
|
|
108
57
|
|---|---|---|
|
|
109
58
|
| `preset` | `"bun"` | Usar o runtime Bun como alvo |
|
|
110
59
|
| `noExternals` | `true` | Empacotar tudo no output |
|
|
111
|
-
| `inlineDynamicImports` | `true` | Achatar imports
|
|
112
|
-
| `serveStatic` | `"inline"` | Embutir assets
|
|
113
|
-
| `esbuild.options.target` | `"esnext"` | Usar as features JS mais recentes para
|
|
60
|
+
| `inlineDynamicImports` | `true` | Achatar imports dinâmicos para output em arquivo único |
|
|
61
|
+
| `serveStatic` | `"inline"` | Embutir assets estáticos no binário |
|
|
62
|
+
| `esbuild.options.target` | `"esnext"` | Usar as features JS mais recentes para máximo desempenho |
|
|
114
63
|
|
|
115
64
|
---
|
|
116
65
|
|
|
117
|
-
## ⚙️
|
|
66
|
+
## ⚙️ Opções
|
|
118
67
|
|
|
119
|
-
|
|
|
68
|
+
| Opção | Tipo | Padrão | Descrição |
|
|
120
69
|
|---|---|---|---|
|
|
121
|
-
| `enabled` | `boolean` | `true` | Habilitar/desabilitar o
|
|
122
|
-
| `outfile` | `string` | `"nuxtbin"` | Nome do arquivo
|
|
70
|
+
| `enabled` | `boolean` | `true` | Habilitar/desabilitar o módulo |
|
|
71
|
+
| `outfile` | `string` | `"nuxtbin"` | Nome do arquivo binário de saída |
|
|
123
72
|
| `bunPath` | `string` | `undefined` | Caminho para o executável do bun. Pode ser um diretório (ex: `/opt/bun/`) ou o caminho direto para o binário (ex: `/opt/bun/bun`). Se for um diretório, '/bun' será anexado. O padrão é 'bun' do PATH do sistema. |
|
|
124
73
|
| `extraExternals` | `(string \| RegExp)[]` | `[]` | Pacotes adicionais para marcar como external |
|
|
125
|
-
| `autoCompile` | `boolean` | `true` | Executar `bun build --compile` automaticamente
|
|
74
|
+
| `autoCompile` | `boolean` | `true` | Executar `bun build --compile` automaticamente após o build |
|
|
126
75
|
|
|
127
76
|
---
|
|
128
77
|
|
|
129
|
-
## 📦 Pacotes External
|
|
78
|
+
## 📦 Pacotes External Padrão
|
|
130
79
|
|
|
131
|
-
Estes pacotes
|
|
80
|
+
Estes pacotes são conhecidos por quebrar com `noExternals: true` e são excluídos por padrão:
|
|
132
81
|
|
|
133
82
|
| Pacote | Pattern |
|
|
134
83
|
|---|---|
|
|
@@ -147,24 +96,16 @@ bunCompile: {
|
|
|
147
96
|
}
|
|
148
97
|
```
|
|
149
98
|
|
|
150
|
-
> **⚠️ Importante:** As bibliotecas listadas em `extraExternals` (assim como as externals
|
|
99
|
+
> **⚠️ Importante:** As bibliotecas listadas em `extraExternals` (assim como as externals padrão) **não são embutidas no binário**. Para que o binário `nuxtbin` execute corretamente, essas dependências precisam estar disponíveis em uma pasta `node_modules` ao lado do binário gerado.
|
|
151
100
|
|
|
152
101
|
---
|
|
153
102
|
|
|
154
103
|
## 🏗️ Arquitetura
|
|
155
104
|
|
|
156
|
-
|
|
157
|
-
src/
|
|
158
|
-
module.ts # Modulo principal — configura o Nitro + auto-compila
|
|
159
|
-
package.json
|
|
160
|
-
tsconfig.json
|
|
161
|
-
dprint.json # Configuracao do formatador de codigo
|
|
162
|
-
```
|
|
105
|
+
O módulo usa uma **arquitetura baseada em hooks**:
|
|
163
106
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
- **`nitro:config`** — Ajusta configuracoes do Nitro (preset, externals, bundling)
|
|
167
|
-
- **`nitro:compiled`** — Aciona `bun build --compile` apos o Nitro terminar o build do servidor
|
|
107
|
+
- **`nitro:config`** — Ajusta configurações do Nitro (preset, externals, bundling)
|
|
108
|
+
- **`nitro:compiled`** — Aciona `bun build --compile` após o Nitro terminar o build do servidor
|
|
168
109
|
|
|
169
110
|
### Como Funciona
|
|
170
111
|
|
|
@@ -177,12 +118,12 @@ bun run -b build
|
|
|
177
118
|
│
|
|
178
119
|
└─ hook nitro compiled ──▶ bun build .output/server/index.mjs --compile --outfile <nome>
|
|
179
120
|
│
|
|
180
|
-
└──▶ 🎉
|
|
121
|
+
└──▶ 🎉 Binário standalone pronto!
|
|
181
122
|
```
|
|
182
123
|
|
|
183
|
-
### Por que
|
|
124
|
+
### Por que `-b` é obrigatório?
|
|
184
125
|
|
|
185
|
-
Quando
|
|
126
|
+
Quando você executa `bun run build` (sem `-b`), o Bun age como um **gerenciador de tarefas** e pode delegar a execução do script ao Node.js. Nesse cenário, as variáveis `globalThis.Bun` e `process.versions.bun` **não existem**, e o módulo não consegue detectar o runtime Bun:
|
|
186
127
|
|
|
187
128
|
```ts
|
|
188
129
|
const isBun = typeof globalThis.Bun !== "undefined"
|
|
@@ -190,7 +131,7 @@ const isBun = typeof globalThis.Bun !== "undefined"
|
|
|
190
131
|
```
|
|
191
132
|
[src/module.ts:L70-L76](https://github.com/jprando/nuxt-bun-compile/blob/main/src/module.ts#L70-L76)
|
|
192
133
|
|
|
193
|
-
O
|
|
134
|
+
O parâmetro **`-b`** (ou `--bun`) força o Bun a ser o runtime que executa o script. Com ele, as variáveis acima ficam disponíveis e a etapa de `bun build --compile` é executada corretamente.
|
|
194
135
|
|
|
195
136
|
---
|
|
196
137
|
|
|
@@ -200,51 +141,33 @@ O parametro **`-b`** (ou `--bun`) forca o Bun a ser o runtime que executa o scri
|
|
|
200
141
|
|---|---|---|
|
|
201
142
|
| 🔤 | **TypeScript** | Target ESNext, strict mode, bundler resolution |
|
|
202
143
|
| 🐰 | **Bun** | Runtime 1.3.9+, gerenciador de pacotes |
|
|
203
|
-
| 💚 | **Nuxt** |
|
|
204
|
-
| 📐 | **dprint** | Formatador de
|
|
144
|
+
| 💚 | **Nuxt** | 4.x |
|
|
145
|
+
| 📐 | **dprint** | Formatador de código (TS, JSON, MD, TOML, YAML e mais) |
|
|
205
146
|
| 📦 | **ESM** | ES modules puro (`"type": "module"`) |
|
|
206
147
|
|
|
207
148
|
---
|
|
208
149
|
|
|
209
150
|
## 🧑💻 Desenvolvimento
|
|
210
151
|
|
|
211
|
-
###
|
|
152
|
+
### Testando Localmente em uma Aplicação Nuxt
|
|
212
153
|
|
|
213
154
|
```bash
|
|
214
|
-
#
|
|
215
|
-
bun
|
|
216
|
-
|
|
217
|
-
# Formatar codigo
|
|
218
|
-
bun run format
|
|
219
|
-
|
|
220
|
-
# Linkar para testes locais
|
|
221
|
-
bun link
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
### Estilo de Codigo
|
|
225
|
-
|
|
226
|
-
- **Formatador:** dprint — sempre execute `bun run format` antes de commitar
|
|
227
|
-
- **Strings:** Aspas duplas
|
|
228
|
-
- **Ponto e virgula:** Sim
|
|
229
|
-
- **Constantes:** `UPPER_SNAKE_CASE` para nivel de modulo (`DEFAULT_EXTERNALS`)
|
|
230
|
-
- **Tipos:** `interface` para APIs publicas, `import type` para imports somente de tipo
|
|
231
|
-
- **Built-ins do Node:** Use prefixo `node:` (ex: `node:child_process`)
|
|
232
|
-
|
|
233
|
-
### Testando Localmente em uma App Nuxt
|
|
155
|
+
# 1. Clone este repositório para desenvolvimento local
|
|
156
|
+
git clone https://github.com/jprando/nuxt-bun-compile.git
|
|
234
157
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
cd nuxt-bun-compile && bun link
|
|
158
|
+
# 2. Linke o módulo
|
|
159
|
+
cd nuxt-bun-compile && bun install && bun prepack && bun link
|
|
238
160
|
|
|
239
|
-
#
|
|
161
|
+
# 3. Use em sua aplicação Nuxt
|
|
240
162
|
cd sua-app-nuxt && bun link nuxt-bun-compile
|
|
241
163
|
|
|
242
|
-
#
|
|
164
|
+
# 4. Adicione ao array modules no nuxt.config.ts
|
|
165
|
+
bun nuxt add nuxt-bun-compile
|
|
243
166
|
|
|
244
|
-
#
|
|
167
|
+
# 5. Compile
|
|
245
168
|
NODE_OPTIONS="--max-old-space-size=8192" bun run -b build
|
|
246
169
|
|
|
247
|
-
#
|
|
170
|
+
# 6. Execute o binário
|
|
248
171
|
./nuxtbin
|
|
249
172
|
```
|
|
250
173
|
|
|
@@ -254,7 +177,7 @@ NODE_OPTIONS="--max-old-space-size=8192" bun run -b build
|
|
|
254
177
|
|
|
255
178
|
- [Bun](https://bun.sh) 1.3.9+ (para a etapa de `--compile`)
|
|
256
179
|
- Nuxt 3.x / 4.x
|
|
257
|
-
- Node 24+ (quando
|
|
180
|
+
- Node 24+ (quando não usar Bun como runtime)
|
|
258
181
|
|
|
259
182
|
---
|
|
260
183
|
|
|
@@ -262,18 +185,18 @@ NODE_OPTIONS="--max-old-space-size=8192" bun run -b build
|
|
|
262
185
|
|
|
263
186
|
### Por que `NODE_OPTIONS="--max-old-space-size=8192"`?
|
|
264
187
|
|
|
265
|
-
O processo de build do Nuxt com `noExternals: true` e `inlineDynamicImports: true` faz com que o Rollup/esbuild tente empacotar **todas** as
|
|
188
|
+
O processo de build do Nuxt com `noExternals: true` e `inlineDynamicImports: true` faz com que o Rollup/esbuild tente empacotar **todas** as dependências em um único bundle. Em projetos com muitas dependências, isso pode consumir mais memória do que o limite padrão do V8 (aproximadamente 1.5–2 GB), causando o erro:
|
|
266
189
|
|
|
267
190
|
```
|
|
268
191
|
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
|
|
269
192
|
```
|
|
270
193
|
|
|
271
|
-
A
|
|
194
|
+
A variável `NODE_OPTIONS="--max-old-space-size=8192"` aumenta o limite de memória heap do V8 para 8 GB, dando margem suficiente para que o bundling termine sem estourar a memória. O valor de `8192` (MB) é uma referência segura para a maioria dos projetos — ajuste conforme necessário para projetos maiores ou máquinas com menos RAM.
|
|
272
195
|
|
|
273
|
-
> **Nota:** Essa
|
|
196
|
+
> **Nota:** Essa variável afeta o processo do Node.js/V8 que roda o build do Nuxt, e não o binário final gerado pelo `bun build --compile`.
|
|
274
197
|
|
|
275
198
|
---
|
|
276
199
|
|
|
277
|
-
## 📄
|
|
200
|
+
## 📄 Licença
|
|
278
201
|
|
|
279
202
|
MIT
|
package/dist/module.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-bun-compile",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
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",
|