Skip to content

feat(core): preserve env presets instead of inlining - #1764

Draft
elecmonkey wants to merge 1 commit into
mainfrom
elecmonkey/preserve-env-define
Draft

feat(core): preserve env presets instead of inlining#1764
elecmonkey wants to merge 1 commit into
mainfrom
elecmonkey/preserve-env-define

Conversation

@elecmonkey

@elecmonkey elecmonkey commented Jul 14, 2026

Copy link
Copy Markdown
Member

Summary

Stop inlining Rsbuild's default env presets so downstream consumers can replace them:

  • process.env.BASE_URL / process.env.ASSET_PREFIX: preserved for all formats.
  • import.meta.env.*: preserved for ESM only.

Checklist

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

@elecmonkey
elecmonkey force-pushed the elecmonkey/preserve-env-define branch 3 times, most recently from 8dc0348 to b9afaa3 Compare July 14, 2026 12:09
@elecmonkey
elecmonkey force-pushed the elecmonkey/preserve-env-define branch 3 times, most recently from 5b37460 to 7e8b1a9 Compare August 4, 2026 09:52
@elecmonkey

Copy link
Copy Markdown
Member Author

@codex review

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

Copy link
Copy Markdown

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: 7e8b1a99de

ℹ️ 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".

const processEnvDefine: ConstructorParameters<
typeof rspack.DefinePlugin
>[0] = {
'process.env': {},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retain UMD preset values before stubbing process.env

When a UMD source reads process.env.BASE_URL or process.env.ASSET_PREFIX without a user override, those keys have already been removed from nextDefine, and this parent definition then compiles the access against an empty object, yielding undefined instead of Rsbuild's previous "/"/"" defaults. The new UMD test only detects the unrelated "production" literal, so it misses this runtime value regression; preserve these preset literals for UMD before stubbing unknown process.env properties.

Useful? React with 👍 / 👎.

@elecmonkey
elecmonkey force-pushed the elecmonkey/preserve-env-define branch from 7e8b1a9 to d0b43ad Compare August 4, 2026 10:32
@elecmonkey
elecmonkey force-pushed the elecmonkey/preserve-env-define branch from d0b43ad to 7d43494 Compare August 4, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant