Rolldown "Run build with devtools" produces a development build (inherits the dev server's NODE_ENV)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, typescript, vite
- Domain
- build-system, devtools
Research direction
Start in packages/rolldown/src/node/rolldown/build-runner.ts, especially getBuildCommand() and its call to ctx.terminals.startChildProcess(), then reproduce the issue with a running Vite dev server and compare the generated bundle with a plain vite build. Done means Run build with devtools uses production NODE_ENV, the confirmation command reflects that environment, and the Rolldown analysis matches the plain production build.
Written by the indexing model from the issue text.
Description
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:
- The dev server sets
process.env.NODE_ENV = 'development'at startup when it is unset (viteresolveConfig,isNodeEnvSet/defaultNodeEnv). getBuildCommand()spawnsvite buildthroughctx.terminals.startChildProcess()withenv: { VITE_DEVTOOLS_ROLLDOWN: 'true' }(build-runner.ts#L41-L48). The hub merges that onto the dev server'sprocess.env, so the child inheritsNODE_ENV=development.vite buildkeeps an already-setNODE_ENV(documented:NODE_ENV=development vite buildis how you ask for a development build), and replacesprocess.env.NODE_ENVin library code withprocess.env.NODE_ENV || mode. So everyif (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.
- Any Vite 8 app with
@vitejs/devtools+@vitejs/devtools-rolldown0.7.5 and a dependency that hasprocess.env.NODE_ENVbranches (e.g. Vue + Pinia). vite(dev), open DevTools → Rolldown → Run build with devtools.- Compare the new session's first-load size and the
dist/output with a plainvite buildfrom a fresh shell: the button's build is larger and contains dev-only code (for Vue,__VUE_DEVTOOLS_GLOBAL_HOOK__strings appear indist/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.
- Dominant language
- TypeScript
- Stars
- 1.2k
- Forks
- 91
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 20
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vitejs/devtools
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
vitejs/devtools#589 · 1 comment ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
vitejs/devtools#261 · 1 comment ·
Maintainers usually reply within 1 day
-
feat(oxc): add rule timing stats to the lint inspectorPossibly taken @yuyinws claimed this 12 days ago. Openenhancement
vitejs/devtools#584 · 1 assignee ·
Maintainers usually reply within 1 day
-
pending triage
Difficulty 3/5 1-2 days Newbie friendliness 58/100
Maintainers usually reply within 1 day
-
pending triage
Difficulty 4/5 3-5 days Newbie friendliness 35/100
vitejs/devtools#571 · 3 comments ·
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
callstackincubator/rozenite#518 ·
Maintainers usually reply within 1 day
-
Area/Workflow Priority/Blocker Type/Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
wso2/product-integrator#2622 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
area:bash bug has repro platform:macos
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
anthropics/claude-code#98644 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
allure-framework/allure-js#1603 ·
Maintainers usually reply within 1 day