Skip to content

Conversation

@chenjiahan
Copy link
Member

Summary

  • add environmentList to InternalContext type and initialization
  • replace Object.values(environments) with environmentList for better performance and readability
  • update all related usages to use environmentList instead of Object.values

Checklist

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

Copilot AI review requested due to automatic review settings November 12, 2025 13:23
@netlify
Copy link

netlify bot commented Nov 12, 2025

Deploy Preview for rsbuild ready!

Name Link
🔨 Latest commit d0e78a6
🔍 Latest deploy log https://app.netlify.com/projects/rsbuild/deploys/69148d8bab54b600088cf1fb
😎 Deploy Preview https://deploy-preview-6560--rsbuild.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 57 (🟢 up 4 from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 100 (no change from production)
PWA: 60 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

Copilot AI left a 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[] to InternalContext type and initialization
  • Replaced all Object.values(context.environments) calls with direct context.environmentList access
  • Refactored devServer.ts to simplify environment API creation using environmentList iteration

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.

Copy link

@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.

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

@chenjiahan chenjiahan merged commit f4a588c into main Nov 12, 2025
11 checks passed
@chenjiahan chenjiahan deleted the environment_list_1112 branch November 12, 2025 14:02
@chenjiahan chenjiahan mentioned this pull request Nov 12, 2025
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