refactor(interopDefault): simplify implementation#243
Conversation
| enumerable: key !== "default", | ||
| configurable: key !== "default", | ||
| get() { | ||
| return sourceModule[key]; |
There was a problem hiding this comment.
There is a small chance of behavior regression here.
In the current implementation, we were using the (cached) value of sourceModule.default via defaultValue now we dynamically access it.
There was a problem hiding this comment.
Unless the supplied module comes with interop code (which already defines default as a getter), I don't anticipate any changes in behavior here.
Furthermore, the appropriate behavior is either to cache all keys (getter) or not cache any at all, instead of caching default only.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #243 +/- ##
==========================================
- Coverage 88.04% 87.17% -0.87%
==========================================
Files 8 8
Lines 1062 1084 +22
Branches 188 196 +8
==========================================
+ Hits 935 945 +10
- Misses 127 139 +12 ☔ View full report in Codecov by Sentry. |
🔗 Linked issue
N/A
❓ Type of change
📚 Description
While crafting antfu-collective/unconfig#27, I stumbled upon the implementation of
interopDefault. Upon closer examination, I found out that the implementation could be simplified and redundant code could be merged.All tests passed on my machine locally.
📝 Checklist