Skip to content

Conversation

@LingyuCoder
Copy link
Contributor

Summary

This PR improves the type definition accuracy for the createCompilerRuntimeGlobals function by changing its return type from typeof RuntimeGlobals to Record<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:

  • Updated return type of createCompilerRuntimeGlobals to use more precise Record type
  • This improves type safety and makes the TypeScript types more accurate

Checklist

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

Copilot AI review requested due to automatic review settings December 10, 2025 05:55
@netlify
Copy link

netlify bot commented Dec 10, 2025

Deploy Preview for rspack canceled.

Name Link
🔨 Latest commit 4966ba1
🔍 Latest deploy log https://app.netlify.com/projects/rspack/deploys/69390d224337990008db681e

@github-actions github-actions bot added release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack. labels Dec 10, 2025
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 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.

chenjiahan
chenjiahan previously approved these changes Dec 10, 2025
@github-actions
Copy link
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 project(s) in monorepo.

📁 react-10k

Path: ../build-tools-performance/cases/react-10k/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 5.7 MB - -
📄 JavaScript 5.7 MB - -
🎨 CSS 21.0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 react-1k

Path: ../build-tools-performance/cases/react-1k/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 823.6 KB - -
📄 JavaScript 823.6 KB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 react-5k

Path: ../build-tools-performance/cases/react-5k/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 2.7 MB - -
📄 JavaScript 2.7 MB - -
🎨 CSS 21.0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 rome

Path: ../build-tools-performance/cases/rome/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 984.3 KB - -
📄 JavaScript 984.3 KB - -
🎨 CSS 0 B - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

📁 ui-components

Path: ../build-tools-performance/cases/ui-components/dist/rsdoctor-data.json

⚠️ No baseline data found - Unable to perform comparison analysis

Metric Current Baseline Change
📊 Total Size 2.1 MB - -
📄 JavaScript 2.0 MB - -
🎨 CSS 83.0 KB - -
🌐 HTML 0 B - -
📁 Other Assets 0 B - -

Generated by Rsdoctor GitHub Action

@github-actions
Copy link
Contributor

📦 Binary Size-limit

Comparing 4966ba1 to fix: relative-resource-path should handle output.filename (#12398) by Cong-Cong Pan

🙈 Size remains the same at 47.72MB

@codspeed-hq
Copy link

codspeed-hq bot commented Dec 10, 2025

CodSpeed Performance Report

Merging #12403 will not alter performance

Comparing fix/runtime-globals-types (4966ba1) with main (df793ab)

Summary

✅ 17 untouched

@LingyuCoder LingyuCoder enabled auto-merge (squash) December 10, 2025 06:39
@LingyuCoder LingyuCoder merged commit 4b73bc2 into main Dec 10, 2025
76 of 78 checks passed
@LingyuCoder LingyuCoder deleted the fix/runtime-globals-types branch December 10, 2025 06:39
@CPunisher CPunisher mentioned this pull request Dec 17, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release: bug fix release: bug related release(mr only) team The issue/pr is created by the member of Rspack.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants