fix(bundler): inline Bun.env the same as process.env with --env#28560
Open
SferaDev wants to merge 1 commit intooven-sh:mainfrom
Open
fix(bundler): inline Bun.env the same as process.env with --env#28560SferaDev wants to merge 1 commit intooven-sh:mainfrom
Bun.env the same as process.env with --env#28560SferaDev wants to merge 1 commit intooven-sh:mainfrom
Conversation
Fixes oven-sh#20430 The bundler's define system only registered `process.env.<KEY>` when inlining environment variables via `--env=inline` or `--env='PREFIX_*'`. `Bun.env.<KEY>` member expressions were left untouched, even though `Bun.env` is documented as equivalent to `process.env`. Register `Bun.env.<KEY>` defines alongside `process.env.<KEY>` in: - `env_loader.zig` `copyForDefine` (both prefix and load_all paths) - `options.zig` default NODE_ENV/BUN_ENV defines - `HTMLBundle.zig` production NODE_ENV define
Contributor
WalkthroughThe PR extends environment variable inlining support to Changes
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #20430
bun build --env=inlineandbun build --env='PREFIX_*'inlineprocess.env.<KEY>but leaveBun.env.<KEY>untouched. SinceBun.envis equivalent toprocess.env, both should be inlined.The bundler's define system only registered
process.env.<KEY>entries. This PR addsBun.env.<KEY>defines alongside them in:env_loader.zig—copyForDefine, bothprefixandload_allpaths. Usesinline forover both prefixes to avoid duplication. Also tightened thee_stringsallocation to the exact worst-case bound.options.zig— defaultNODE_ENV/BUN_ENVdefines.HTMLBundle.zig— productionNODE_ENVdefine in the Bake path.Example
test.js
Before:
After: