cloudflare/vinext

Webpack loaders that mutate `process.env` at build time not supported

Open

#1,500 建立於 2026年5月22日

在 GitHub 查看
 (0 留言) (0 反應) (0 負責人)TypeScript (329 fork)github user discovery
adapter-api-e2ehelp wanted

倉庫指標

Star
 (8,120 star)
PR 合併指標
 (平均合併 1天 1小時) (30 天內合併 462 個 PR)

描述

This issue was created by an agent analysing CI failures from the Next.js Deploy Suite (vinext main vs Next.js v16.2.6, 2026-05-22).

Problem

Next.js allows webpack loaders to set environment variables during the build (e.g. via process.env.X = ...), which then become available in user code. vinext (Vite/Rolldown-based) does not run webpack loaders, so these env vars are absent and the test app renders the default error page.

Webpack loader sets process.env.X at build time; user code reads undefined

Estimated Impact

~1 test failures across the deploy suite.

Affected Test Suites

  • test/e2e/app-dir/webpack-loader-set-environment-variable/webpack-loader-set-environment-variable.test.ts

Recommendation

  1. Reproduce first in vinext's own test suite. Add a fixture with a webpack loader that sets process.env.MY_VAR and a page that prints process.env.MY_VAR. Confirm the page does not see the value.

  2. Decide on a vinext equivalent. Either implement a Vite plugin that runs at build start and can mutate the define map, or document that webpack loaders are not portable. Update fixture / triage decision accordingly.

貢獻者指南