Standalone server.js does not default NODE_ENV to production
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- node.js, react, typescript
- Domain
- backend, build-system
Research direction
Start by running vinext build with output: "standalone", then inspect the generated dist/standalone/server.js and run it with node while NODE_ENV is unset. The work is done when the generated server defaults NODE_ENV to production before React is imported and the runtime no longer selects the development bundle.
Written by the indexing model from the issue text.
Description
Summary
The generated dist/standalone/server.js does not set NODE_ENV. If the variable is not set in the environment, react-dom/server selects its development bundle at runtime.
Repro
output: "standalone", vinext build, then node dist/standalone/server.js without NODE_ENV. react-dom/server resolves to its development build, which is slower and prints development-only warnings. Next.js's standalone server.js sets process.env.NODE_ENV = "production" itself.
Suggestion
Add process.env.NODE_ENV ??= "production" at the top of the generated server.js, before anything imports React.
- Dominant language
- TypeScript
- Stars
- 9.2k
- Forks
- 441
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 412
Getting set up
- No Dockerfile or Docker Compose file
- No 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 cloudflare/vinext
-
nextjs-tracking
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
cloudflare/vinext#3920 ·
Maintainers usually reply within 1 day
-
nextjs-tracking
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
cloudflare/vinext#3887 ·
Maintainers usually reply within 1 day
-
docs: document deployment with Cloudflare Workers Builds / Git integrationPossibly taken @reginaldalfret claimed this 8 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
cloudflare/vinext#3738 ·
Maintainers usually reply within 1 day
-
create-vinext-app generates `packageManager` without a pnpm version on windows, causing corepack to failPossibly taken @NriotHrreion claimed this 27 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cloudflare/vinext#3322 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
cloudflare/vinext#3221 · 2 comments ·
Maintainers usually reply within 1 day
All issues in cloudflare/vinext
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
dsh-market/dsh-market#877 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
stellar/stellar-dev-skill#151 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
area:arcade game ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
fderuiter/deruiter.dev#2281 · 1 comment ·
Maintainers usually reply within 1 day
-
scope: data grid type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days