Conversation
✅ Deploy Preview for rspack canceled.
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where enum values with dynamic expressions were being incorrectly mangled during code optimization. The change prevents mangling of enum values since their codegen is controlled by the loader rather than the bundler itself.
- Prevents mangling of enum values by setting
can_mangle: Some(false)for enum exports - Adds test case to verify that dynamic enum values (with expressions like
Math.random()) and static enum values are handled correctly during inlining
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/rspack_plugin_javascript/src/dependency/esm/esm_export_specifier_dependency.rs | Sets can_mangle: Some(false) for enum export specifications to prevent mangling |
| tests/rspack-test/configCases/inline-enum/enum-expression/rspack.config.js | Test configuration enabling TypeScript parsing and enum inlining |
| tests/rspack-test/configCases/inline-enum/enum-expression/index.js | Test case verifying enum inlining behavior for both dynamic and static values |
| tests/rspack-test/configCases/inline-enum/enum-expression/enum.ts | TypeScript enum definition with both dynamic and static values for testing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Contributor
📦 Binary Size-limit
🙈 Size remains the same at 47.23MB |
CodSpeed Performance ReportMerging #11629 will not alter performanceComparing Summary
|
SyMind
approved these changes
Sep 10, 2025
Member
|
LGTM 👍 |
2 tasks
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.
Summary
Because we don't control the codegen of enum value (just use the loader generated), so we can't mangle it.
Related links
Checklist