-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: Use ~/* import alias #1191
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
Conversation
🦋 Changeset detectedLatest commit: 9312177 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Running Lighthouse audit... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. We're gonna need a bit of time to think about this one. Import aliases are cool but there are still some issues related to them as well, and different users have different needs.
Here are the main possibilities:
- Keep on not using an alias at all.
- Use a hardcoded import alias. If so, do we want
@/
?~/
? something else? - Allow the user to define the alias, like
create-next-app
does. Is this worth the additional complexity? - Offer the choice of no alias vs alias in the cli (this feels like it would be very difficult to implement with our current scaffolding setup).
Thanks for feedback. My thinking was that ct3a is opinionated so it'd be fine to have one more opinion. I personally have no preference on whether it's I certainly would prefer not to "Allow the user to define the alias" since it'd add more mental overhead to everyone involved. |
It's not that much overhead, Next does this fairly straightforward: Allowing either with/without aliases would be difficult though |
Thanks @juliusmarminge, that looks pretty straightforward - happy to implement this if you think it's fine to have aliases used within ct3a 🙏🏼 |
I thought about this and I think I'm leaning towards "default to a sensible alias, and let the user override". I'm not a fan of |
@c-ehrlich I wanted to confirm with you something: been meaning to switch from Since I have no preference on the alias and you mentioned that "we're more closely related to create-next-app", I wanted to double-check with you that you're preferring |
Yes ~/* by default |
Alright, this seems to be working as expected. After packages are installed, I find-and-replace the default ( Could you please take a look? And apologies for a bit of commit spam, this is my first contribution to ct3a and I'm very likely doing something incorrectly 🙏🏼 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting up the alias works and the regexes fix all the incorrect input i could think of. Also tried a couple different apps, everything works great.
The only issue I have is that in VSCode, both before and after adding javascript.preferences.importModuleSpecifier": "non-relative"
to settings, autoimports still prefer relative paths. Anyone know what's up with that?
@c-ehrlich adding Note that there are two settings: |
oh yeah makes sense that it's not in nonetheless this is not great dx as we are now making everyone use absolute imports, but the default editor setting is to ignore this. i guess this brings us back to the debate of whether we want to ship a i just checked and create-next-app has the same issue, so at least we're not alone. let's get this merged, and we can think about the other stuff later |
Thanks for reviews and helping me ship this ❤️ Re |
* feat: Use @/* import alias * Allow users override import alias * Change default import alias to ~/ * Run setImportAliases at a later stage --------- Co-authored-by: Christopher Ehrlich <[email protected]>
✅ Checklist
Changelog
Use
~/*
import alias like the one recently added to Next.js.💯