Problem
packages/cli/src/vite/vat-bundler.ts hardcodes a define block that replaces process.env.NODE_ENV with "production" in all vat bundles:
define: {
'process.env.NODE_ENV': JSON.stringify('production'),
},
This is a workaround for libraries like immer that check process.env.NODE_ENV, but it injects into all bundles indiscriminately. The vat bundler shouldn't be responsible for shimming environment globals.
Proposed solution
Configure Vite (via a plugin or the Vite config used at build time) to inject globals like process.env.NODE_ENV, and remove this define block from the vat bundler. This keeps the bundler focused on bundling and moves environment concerns to the build configuration layer where they belong.
Location
packages/cli/src/vite/vat-bundler.ts (lines 23-28)
Problem
packages/cli/src/vite/vat-bundler.tshardcodes adefineblock that replacesprocess.env.NODE_ENVwith"production"in all vat bundles:This is a workaround for libraries like
immerthat checkprocess.env.NODE_ENV, but it injects into all bundles indiscriminately. The vat bundler shouldn't be responsible for shimming environment globals.Proposed solution
Configure Vite (via a plugin or the Vite config used at build time) to inject globals like
process.env.NODE_ENV, and remove thisdefineblock from the vat bundler. This keeps the bundler focused on bundling and moves environment concerns to the build configuration layer where they belong.Location
packages/cli/src/vite/vat-bundler.ts(lines 23-28)