Skip to content

fix(browser): remove default process shim while keep env stubbing support#981

Merged
fi3ework merged 1 commit intomainfrom
max/2026-02-25--09-00PM
Feb 26, 2026
Merged

fix(browser): remove default process shim while keep env stubbing support#981
fi3ework merged 1 commit intomainfrom
max/2026-02-25--09-00PM

Conversation

@fi3ework
Copy link
Copy Markdown
Member

@fi3ework fi3ework commented Feb 26, 2026

Summary

Removes the automatic injection of a process object shim in browser mode, eliminating global namespace pollution. Replaces the string-keyed __RSTEST_ENV__ with a Symbol-based store (Symbol.for('rstest.env')) to hold environment variables, while ensuring rstest.stubEnv() continues to work seamlessly.

Behavior diff:

Aspect Before After
Global process Injected with env/argv/version/cwd/platform/nextTick undefined by default
Env store key globalThis.__RSTEST_ENV__ (string) globalThis[Symbol.for('rstest.env')]
process.env access Direct property access on shim Compiled to Symbol store via source.define
Global pollution Visible string key __RSTEST_ENV__ No visible string keys added

Changes:

  • Replace ensureProcessEnv with ensureRuntimeEnv using Symbol.for('rstest.env') as the canonical store
  • Update stubEnv/unstubAllEnvs to resolve env target from Symbol store first, fallback to process.env in Node
  • Configure Rsbuild source.define to rewrite process.env and import.meta.env to the Symbol store
  • Update E2E assertions to verify no global process and no __RSTEST_ENV__ string key
  • Revise CLI help text and type documentation to reference "runtime env" instead of "process.env"

Related Links

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8da6d0fc60

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@fi3ework fi3ework force-pushed the max/2026-02-25--09-00PM branch from 8da6d0f to 50d9ca3 Compare February 26, 2026 06:08
@fi3ework fi3ework requested a review from 9aoy February 26, 2026 06:23
@fi3ework fi3ework merged commit 0bcdbb9 into main Feb 26, 2026
10 checks passed
@fi3ework fi3ework deleted the max/2026-02-25--09-00PM branch February 26, 2026 07:19
@fi3ework fi3ework mentioned this pull request Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants