nuxt / nuxt/image

`bun run -b nuxt build` bundle a bun (npm package) inside build

Open
#2,069 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.5k
Forks
331
Avg merge
19h 52m
Merged PRs (30d)
9

Description

Description

Run bun run -b nuxt build with Nuxt Image will bundle a 143 MB (56.8 MB gzip) build with bun inside
(compare to a normal 38.5 MB (16.6 MB gzip) build by bun run nuxt build):

>>> bun run -b nuxt build
┌  Building Nuxt for production...
│
●  Nuxt 4.2.2 (with Nitro 2.12.9, Vite 7.3.0 and Vue 3.5.26)
│
●  Nitro preset: node-server
ℹ Building client...                                                                                                                           8:12:35 PM
ℹ vite v7.3.0 building client environment for production...                                                                                    8:12:35 PM
ℹ ✓ 105 modules transformed.                                                                                                                   8:12:36 PM
ℹ ../node_modules/.cache/nuxt/.nuxt/dist/client/manifest.json                   1.09 kB │ gzip:  0.29 kB                                 
   ...
ℹ ../node_modules/.cache/nuxt/.nuxt/dist/client/_nuxt/B0oku_3T.js             147.15 kB │ gzip: 54.69 kB                                       8:12:36 PM
ℹ ✓ built in 1.69s                                                                                                                             8:12:36 PM
✔ Client built in 1705ms                                                                                                                       8:12:36 PM
ℹ Building server...                                                                                                                           8:12:36 PM
ℹ vite v7.3.0 building ssr environment for production...                                                                                       8:12:37 PM
ℹ ✓ 51 modules transformed.                                                                                                                    8:12:37 PM
ℹ ✓ built in 520ms                                                                                                                             8:12:37 PM
✔ Server built in 534ms                                                                                                                        8:12:37 PM
✔ Generated public .output/public                                                                                                        nitro 8:12:37 PM
ℹ Building Nuxt Nitro server (preset: node-server, compatibility date: 2025-07-15)                                                       nitro 8:12:37 PM
✔ Nuxt Nitro server built                                                                                                                nitro 8:12:41 PM
  ├─ .output/server/chunks/_/error-500.mjs (5.06 kB) (2.06 kB gzip)
     ...
  └─ .output/server/package.json (1.64 kB) (616 B gzip)
Σ Total size: 143 MB (56.8 MB gzip)
ℹ sharp binaries have been included in your build for linux-x64. Make sure you deploy to the same architecture.                    @nuxt/image 8:12:48 PM
✔ You can preview this build using node .output/server/index.mjs                                                                         nitro 8:12:48 PM
│                                                                                                                                               8:12:48 PM
└  ✨ Build complete!  
>>> tree -sh .output/server/node_modules/bun
[4.0K]  .output/server/node_modules/bun
├── [4.0K]  bin
│   └── [ 99M]  bun.exe
└── [1.1K]  package.json

2 directories, 2 files   

The arg -b in bun run -b means run nuxt build by bun, which is necessary for detecting environment in code (e.g. Nuxt Content detect bun to decide whether to use bun:sqlite).

Reproduce

Just run bun run -b nuxt build with the following basic setup base on nuxt minimal template:

  • package.json
{
  "name": "nuxt-app",
  "type": "module",
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "dependencies": {
    "@nuxt/image": "^2.0.0",
    "nuxt": "^4.2.2",
    "vue": "^3.5.25",
    "vue-router": "^4.6.4"
  }
}
  • nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@nuxt/image']
})
  • nuxt info
Nuxt project info:
|                      |                                                   |
| -------------------- | ------------------------------------------------- |
| **Operating system** | `Linux 5.15.167.4-microsoft-standard-WSL2`        |
| **CPU**              | `12th Gen Intel(R) Core(TM) i7-12700H (20 cores)` |
| **Bun version**      | `1.3.5`                                           |
| **nuxt/cli version** | `3.31.3`                                          |
| **Package manager**  | `bun@1.3.5`                                       |
| **Nuxt version**     | `4.2.2`                                           |
| **Nitro version**    | `2.12.9`                                          |
| **Builder**          | `vite@7.3.0`                                      |
| **Config**           | `modules`                                         |
| **Modules**          | `@nuxt/image@2.0.0`                               |

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the minimal setup in package.json and nuxt.config.ts, then compare bun run -b nuxt build with bun run nuxt build. Inspect .output/server/node_modules/bun and the Nuxt Image/Nitro build path to determine why Bun is included; done means the Bun binary is no longer bundled while the Bun runtime detection still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
bun, nuxt, typescript
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.