KEMBAR78
Set default values when statically replacing `process.env.NODE_ENV` by jamesopstad · Pull Request #11027 · cloudflare/workers-sdk · GitHub
Skip to content

Conversation

@jamesopstad
Copy link
Contributor

@jamesopstad jamesopstad commented Oct 20, 2025

Fixes #10983.
Fixes #10984.
Fixes #9802.
Fixes #7886.

Statically replace the value of process.env.NODE_ENV with development for development builds and production for production builds if it is not set. Else, use the given value. This ensures that libraries, such as React, that branch code based on process.env.NODE_ENV can be properly tree shaken.

Note that this effectively duplicates the logic we already have in the Vite plugin


  • Tests
    • Tests included
    • Tests not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: bug fix
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: not a patch change

@changeset-bot
Copy link

changeset-bot bot commented Oct 20, 2025

🦋 Changeset detected

Latest commit: f181512

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Oct 20, 2025
@jamesopstad jamesopstad force-pushed the james/default-process-env branch 2 times, most recently from db2eef5 to 2d8c56f Compare October 20, 2025 11:21
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 20, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@11027

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@11027

miniflare

npm i https://pkg.pr.new/miniflare@11027

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@11027

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@11027

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@11027

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@11027

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@11027

wrangler

npm i https://pkg.pr.new/wrangler@11027

commit: f181512

@jamesopstad jamesopstad marked this pull request as ready for review October 20, 2025 11:56
@jamesopstad jamesopstad requested a review from a team as a code owner October 20, 2025 11:56
Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks James.
LGTM with a few minor nits.

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Oct 20, 2025
@jamesopstad jamesopstad force-pushed the james/default-process-env branch 2 times, most recently from 36105c6 to 797f68d Compare October 20, 2025 18:18
@jamesopstad jamesopstad force-pushed the james/default-process-env branch from 797f68d to f181512 Compare October 20, 2025 22:17
@jamesopstad jamesopstad merged commit 1a2bbf8 into main Oct 20, 2025
30 checks passed
@jamesopstad jamesopstad deleted the james/default-process-env branch October 20, 2025 22:54
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Oct 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

2 participants