fix(runtime): avoid std-env in warning stub#4296
Conversation
|
@onmax is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe pull request removes a dependency on the ChangesRemove std-env dependency
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
ce0a6a7 to
39e47f3
Compare
39e47f3 to
a82bc56
Compare
🔗 Linked issue
No existing issue found. Minimal reproduction:
ERR_MODULE_NOT_FOUNDforstd-envRelated history: #3629, #3861
PR made with Codex
❓ Type of change
📚 Description
Nitro v3's published virtual runtime stubs are intended to let imports such as
nitro/runtime-configwork outside a built Nitro app. When that fallback is used outside tests, Nitro should show the warning added in #3861 and continue with the stub implementation.The issue comes from the interaction between two earlier changes:
dependencies;std-envmoved out of production dependencies as part of that direction._runtime_warn.tsfor the public virtual runtime stubs, and that warning helper importedisTestfromstd-env.That creates a clean-install failure in Nitro v3 before the intended warning can run:
With only
nitro@3.0.260522-betainstalled, this currently throws:This PR keeps the install-footprint direction from #3629 by making the test guard dependency-free instead of adding
std-envback to Nitro's production dependencies. The guard preserves the relevantstd-envisTestbehavior for this use case: suppress the warning whenNODE_ENV === "test"orTESTis set.The guard uses optional
globalThis.process?.env, matching the environment access pattern already used by Nitro's runtime config and bystd-envitself. The existingconsola.warnbehavior is left unchanged; this PR only removes the missingstd-envruntime import.I verified lint, build, and a local packed clean install without
std-env;import("nitro/runtime-config")reaches Nitro's intended warning and returns the stub config.📝 Checklist