Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Rolldown "Run build with devtools" produces a development build (inherits the dev server's NODE_ENV)

Đang mở Phù hợp với người mới
#586 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
84/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
node.js, typescript, vite
Lĩnh vực
build-system, devtools

Hướng nghiên cứu

Bắt đầu tại packages/rolldown/src/node/rolldown/build-runner.ts, đặc biệt là getBuildCommand() và lệnh gọi đến ctx.terminals.startChildProcess(), sau đó tái hiện vấn đề với một máy chủ phát triển Vite đang chạy và so sánh bundle được tạo với một vite build thuần túy. Hoàn tất khi Run build with devtools sử dụng NODE_ENV production, lệnh xác nhận phản ánh môi trường đó và phân tích của Rolldown khớp với production build thuần túy.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Describe the bug

The Rolldown panel's Run build with devtools button (vite:rolldown:run-build) produces a development bundle, not a production one. Every size, chunk and duplicate-package figure the Rolldown panel then shows for that session describes the wrong build.

In our Vue app, the button's build ships 259.2 KB gz of first-load JS, while a plain vite build of the same commit ships 200.9 KB gz. The button's build keeps Vue's dev warnings, Pinia's devtools plugin and @vue/devtools-kit in the first-load chunk. The build log still prints building client environment for production, so nothing looks wrong from the outside.

Mechanism:

  1. The dev server sets process.env.NODE_ENV = 'development' at startup when it is unset (vite resolveConfig, isNodeEnvSet / defaultNodeEnv).
  2. getBuildCommand() spawns vite build through ctx.terminals.startChildProcess() with env: { VITE_DEVTOOLS_ROLLDOWN: 'true' } (build-runner.ts#L41-L48). The hub merges that onto the dev server's process.env, so the child inherits NODE_ENV=development.
  3. vite build keeps an already-set NODE_ENV (documented: NODE_ENV=development vite build is how you ask for a development build), and replaces process.env.NODE_ENV in library code with process.env.NODE_ENV || mode. So every if (process.env.NODE_ENV !== 'production') branch stays in the bundle.

Passing the parent env through in startChildProcess() seems right in general (PATH, proxies, the user's own variables), so the fix probably belongs here: the build runner should set NODE_ENV: 'production', which is what a plain vite build resolves to. The confirmation dialog would then also show the real command line: NODE_ENV=production VITE_DEVTOOLS_ROLLDOWN=true vite build.

Reproduction

Inline steps below; the key part needs a running Vite dev server with DevTools.

  1. Any Vite 8 app with @vitejs/devtools + @vitejs/devtools-rolldown 0.7.5 and a dependency that has process.env.NODE_ENV branches (e.g. Vue + Pinia).
  2. vite (dev), open DevTools → Rolldown → Run build with devtools.
  3. Compare the new session's first-load size and the dist/ output with a plain vite build from a fresh shell: the button's build is larger and contains dev-only code (for Vue, __VUE_DEVTOOLS_GLOBAL_HOOK__ strings appear in dist/assets/*.js).

The Vite behaviour alone, without DevTools (Vite 8.3.0):

# index.html: <script type="module" src="./main.js"></script>
# main.js:
#   if (process.env.NODE_ENV !== 'production') console.log('DEV-ONLY-BRANCH')
#   console.log('app')
vite build --outDir clean                        # what a user runs
NODE_ENV=development vite build --outDir inherited   # what the button's child effectively runs
grep -l DEV-ONLY-BRANCH clean/assets/*.js        # no match: dev branch removed
grep -l DEV-ONLY-BRANCH inherited/assets/*.js    # match: dev branch kept

Expected: the button's build matches a plain vite build (production NODE_ENV).
Actual: it is a development build, and the Rolldown panel analyses that.

System Info
OS: Windows 11 Pro 10.0.26200 (x64)
Node: 24.21.0
pnpm: 12.5.1
@vitejs/devtools / @vitejs/devtools-rolldown: 0.7.5 (also upstream main ad2d6df)
devframe / @devframes/hub: 1.0.0
vite: 8.3.0
Used Package Manager

pnpm

Validations
  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
Ngôn ngữ chính
TypeScript
Star
1.2k
Fork
91
Merge trung bình
1 ngày 3 giờ
Pull request đã merge (30 ngày)
21

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của vitejs/devtools

Tất cả issue của vitejs/devtools

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.