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

fix alias match function #890

Merged
merged 1 commit into from
Aug 25, 2020
Merged

Conversation

MoonBall
Copy link
Contributor

@MoonBall MoonBall commented Aug 24, 2020

Changes

  1. support alias: { "@": "." } and alias: { "@": ".." }
  2. fix Aliases "mask" sequentially later aliases that they pattern match #888

Testing

Test added

@MoonBall MoonBall requested a review from a team as a code owner August 24, 2020 04:29
@vercel
Copy link

vercel bot commented Aug 24, 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/r5pugzmcl
✅ Preview: https://snowpack-git-fork-moonball-fix-alias-sequentially.pikapkg.vercel.app

Copy link
Collaborator

@drwpow drwpow left a comment

Choose a reason for hiding this comment

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

Awesome improvement. Thank you!

@drwpow drwpow merged commit 4d7b625 into FredKSchott:master Aug 25, 2020
@@ -261,6 +261,8 @@ export function findMatchingAliasEntry(
): {from: string; to: string; type: 'package' | 'path'} | undefined {
// Only match bare module specifiers. relative and absolute imports should not match
if (
spec === '.' ||
spec === '..' ||
Copy link
Owner

Choose a reason for hiding this comment

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

ha! is this supported in the browser? I'm not sure if I've ever used this myself, but I guess this is a valid path?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a case that is using import * from '.'; in utils/a.js to import some other function.

return undefined;

for (const [from, to] of Object.entries(config.alias)) {
let foundType: 'package' | 'path' | '' = '';
Copy link
Owner

Choose a reason for hiding this comment

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

/cc @drwpow '' = '' as a type seems fishy, I would have liked to have cleaned this up a bit before merging. Will create a quick PR to follow up.

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.

Aliases "mask" sequentially later aliases that they pattern match
3 participants