Skip to content

Move process.env.NODE_ENV injection out of vat bundler #812

@rekmarks

Description

@rekmarks

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)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions