Skip to content
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

quick alias code cleanup #914

Merged
merged 1 commit into from Aug 27, 2020
Merged

quick alias code cleanup #914

merged 1 commit into from Aug 27, 2020

Conversation

FredKSchott
Copy link
Owner

@FredKSchott FredKSchott commented Aug 26, 2020

Changes

  • Followup to fix alias match function #890 to remove an unused TS type
  • Also, takes another look at path alias logic to simplify and fix a bug: "re" shouldn't match "react"

Testing

Covered by existing tests (and test added in #890)

@FredKSchott FredKSchott requested a review from a team as a code owner August 26, 2020 03:45
@vercel
Copy link

vercel bot commented Aug 26, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/pikapkg/snowpack/6vdrcsovq
✅ Preview: https://snowpack-git-quick-alias-cleanup.pikapkg.vercel.app

foundType = 'package';
}
} else {
if (spec.startsWith(from)) {
Copy link
Contributor

@MoonBall MoonBall Aug 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, I also think this is unnecessary since it lead to abc/aa match alias { ab: './src' }.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, the same logic now applies to both. I think the reason you weren't able to do this before was that path aliases end with / already, but package aliases do not, so this was a good chance to be explicit in this function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad,i forgot the from has added / for relative alias.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np! I forgot too, took me a few tries to get this right

let foundType: 'package' | 'path' = isPackageAliasEntry(to) ? 'package' : 'path';
const isExactMatch = spec === removeTrailingSlash(from);
const isDeepMatch = spec.startsWith(addTrailingSlash(from));
if (isExactMatch || isDeepMatch) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻 nice cleanup here. I’m finding this much easier to follow.

@FredKSchott FredKSchott merged commit d555a9d into master Aug 27, 2020
@FredKSchott FredKSchott deleted the quick-alias-cleanup branch August 27, 2020 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants