-
-
Notifications
You must be signed in to change notification settings - Fork 757
fix: improve RuntimeGlobals type definition accuracy #12403
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 rspack canceled.
|
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 improves the TypeScript type definition accuracy for the createCompilerRuntimeGlobals function by changing its return type from typeof RuntimeGlobals to Record<keyof typeof RuntimeGlobals, string>. The RuntimeGlobals enum is internally used to define numeric constants, but createCompilerRuntimeGlobals transforms these into a runtime object where each enum key maps to a string value (e.g., require → "__webpack_require__"). The new type definition more accurately represents this transformation.
- Updated function signature to use
Record<keyof typeof RuntimeGlobals, string>return type - Updated return statement cast to match the new type
- API documentation automatically reflects the exported type as a Record with string values
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/rspack/src/RuntimeGlobals.ts | Updated createCompilerRuntimeGlobals return type and cast to more accurately represent the runtime object structure with string values |
| packages/rspack/etc/core.api.md | Automatically generated API documentation updated to reflect the new Record type instead of the enum type |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Rsdoctor Bundle Diff AnalysisFound 5 project(s) in monorepo. 📁 react-10kPath:
📁 react-1kPath:
📁 react-5kPath:
📁 romePath:
📁 ui-componentsPath:
Generated by Rsdoctor GitHub Action |
📦 Binary Size-limit
🙈 Size remains the same at 47.72MB |
CodSpeed Performance ReportMerging #12403 will not alter performanceComparing Summary
|
Summary
This PR improves the type definition accuracy for the
createCompilerRuntimeGlobalsfunction by changing its return type fromtypeof RuntimeGlobalstoRecord<keyof typeof RuntimeGlobals, string>. This better reflects the actual runtime behavior where the function returns a record object with string values rather than the original RuntimeGlobals type.Changes:
createCompilerRuntimeGlobalsto use more precise Record typeChecklist