-
Notifications
You must be signed in to change notification settings - Fork 63
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
fix: toExports extension strip #291
Conversation
There are two tests that failed but I believe they may be incorrect tests. These tests actually should fail as the from may include a package name such as I have altered these tests and added some new tests for extensions stripping checks. |
@manniL sorry that was silly of me π. Fixed the double quote usage |
No biggie at all. AutoFix CI would've resolved that too I think π |
Codecov Report
@@ Coverage Diff @@
## main #291 +/- ##
==========================================
+ Coverage 97.41% 97.42% +0.01%
==========================================
Files 57 57
Lines 1507 1513 +6
Branches 308 311 +3
==========================================
+ Hits 1468 1474 +6
Misses 39 39
|
What about checking for existence of file? otherwise, even with the improvements here, it might be impossible to distinguish |
Checking for the FS could be inefficient and make unimport less portable. Maybe we could check if the import from is a path like (start with '.', '/', '\', '[\w+]://') and only strip on that? |
I suppose also checking for file existing could break workflows like using Prisma client where the client is only present after generate. @antfu this looks like a sensible approach to me. Regexes are not my forte π |
@danielroe I think this regex caters for this? Apologies if I am misunderstanding but I believe this regex only strips the last segments extension. I added to the unit tests some examples of this. |
sounds like a good idea to me π edge cases can be avoided by making sure to fully resolve absolute/relative paths. |
π Linked issue
#290
β Type of change
π Description
This resolves issue #290 by allowing package names with
.
in the name to be left unchanged.This change alters the regex used to match the extension to ensure that it only changes the last segment of the path and when no preceeding
/
or./
is present in the segment then do not alter the path.I include some outputs of the testing I have done with this Regex in my browser console.
I do not believe this will be a breaking change as the only change in behaviour here, I believe, is to ensure that only the extension is dropped other segments of the path are unchanged.
π Checklist