-
-
Notifications
You must be signed in to change notification settings - Fork 237
refactor: optimize environment handling with environmentList #6560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for rsbuild ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR optimizes environment handling by introducing an environmentList array to the InternalContext, eliminating repeated Object.values(environments) calls for better performance and code readability.
Key Changes:
- Added
environmentList: EnvironmentContext[]toInternalContexttype and initialization - Replaced all
Object.values(context.environments)calls with directcontext.environmentListaccess - Refactored
devServer.tsto simplify environment API creation usingenvironmentListiteration
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core/src/types/context.ts | Added environmentList array field to InternalContext type |
| packages/core/src/types/hooks.ts | Added JSDoc comment for index field in EnvironmentContext |
| packages/core/src/createContext.ts | Initialized environmentList as empty array and synchronized it with environments object during context updates |
| packages/core/src/server/devServer.ts | Refactored environment API creation to use environmentList with forEach instead of Object.fromEntries |
| packages/core/src/server/socketServer.ts | Replaced Object.values(environments) with environmentList in token mapping and environment lookup |
| packages/core/src/server/prodServer.ts | Updated assetPrefixes mapping to use environmentList |
| packages/core/src/server/helper.ts | Updated environment filtering to use environmentList |
| packages/core/src/server/assets-middleware/index.ts | Simplified environment lookup by index using environmentList array access |
| packages/core/src/server/assets-middleware/setupWriteToDisk.ts | Added environmentList parameter and used it instead of Object.values |
| packages/core/src/server/assets-middleware/getFileFromUrl.ts | Updated distPaths mapping to use environmentList |
| packages/core/src/hooks.ts | Removed manual environmentList construction, now uses context.environmentList directly |
| packages/core/src/plugins/nonce.ts | Refactored nonces mapping to be more concise (cosmetic change unrelated to environmentList) |
| packages/core/src/provider/createCompiler.ts | Renamed variable from c to item for clarity (cosmetic change unrelated to environmentList) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this 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.
ℹ️ 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".

Summary
environmentListtoInternalContexttype and initializationObject.values(environments)withenvironmentListfor better performance and readabilityenvironmentListinstead ofObject.valuesChecklist