fix: improve enum scanning loop exit logic and use unplugin transform…#9
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the plugin to use unplugin's native transform filter mechanism and improves the enum scanning loop exit logic by performing proper Set equality comparison instead of just checking size changes.
Key changes:
- Refactored transform filtering to use unplugin's native filter API instead of manual pattern matching
- Improved enum scanning loop exit logic to use Set equality comparison rather than size comparison
- Added Vite-specific configuration to apply only during build
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/index.ts | Refactored to use unplugin's transform filter API and added Vite build-only configuration |
| src/core/utils.ts | Added isEqualSet utility function for comparing Set equality |
| src/core/inline-const-enum.ts | Updated scanConstEnums to use Set equality comparison instead of size comparison for more accurate loop termination |
| package.json | Bumped version from 0.0.3 to 0.0.4 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export function isEqualSet<T>(a: Set<T>, b: Set<T>): boolean { | ||
| if (a.size !== b.size) { | ||
| return false; | ||
| } | ||
| for (const item of a) { | ||
| if (!b.has(item)) { | ||
| return false; | ||
| } | ||
| } | ||
| return true; | ||
| } |
There was a problem hiding this comment.
The new isEqualSet utility function lacks test coverage. Since the existing test file test/e2e.test.ts demonstrates this codebase uses comprehensive testing, this new utility function should have unit tests to verify its behavior, especially for edge cases like empty sets, sets with different sizes, and sets with identical elements.
… filter