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

@ alias does not work #2058

Closed
Aareksio opened this issue Jan 7, 2024 · 6 comments
Closed

@ alias does not work #2058

Aareksio opened this issue Jan 7, 2024 · 6 comments

Comments

@Aareksio
Copy link
Contributor

Aareksio commented Jan 7, 2024

Environment

nitropack@2.8.1
nitropack-nightly@2.9.0-28406650.c8e8549

Reproduction

https://stackblitz.com/edit/github-bjch62

Describe the bug

Aliases (~, @) are not working in new nitro project. Should not this code enable them? As per PR comment it should work. But it does not seem to.

Additional context

  • both @ and ~ do not provide types
  • ~ seems to work as alias, @ does not, see logs

Logs

"@/import-me" is imported by "routes/index.ts", but could not be resolved – treating it as an external dependency.
@manniL
Copy link
Contributor

manniL commented Jan 8, 2024

@Aareksio StackBlitz link is a 404

@manniL manniL changed the title Aliases not working @ alias does not work Jan 8, 2024
@manniL manniL added the bug Something isn't working label Jan 8, 2024
@manniL
Copy link
Contributor

manniL commented Jan 8, 2024

Repro: https://stackblitz.com/edit/nitro-issues-2058?file=routes%2Findex.ts

Apparently @//path-to-file.js works.

@Aareksio
Copy link
Contributor Author

Aareksio commented Jan 8, 2024

Sorry, cut one character from stackblitz link. Fixed.
Screenshot 2024-01-08 at 17 52 25

Apart from alias, tsconfig.json must be adjusted. ~/path-to-file.ts works, but is not recognized by typescript.

@pi0 pi0 removed the bug Something isn't working label Jan 8, 2024
@kspace-trk
Copy link
Contributor

Hi. Is this issue likely to be closed by this PR?
#2318

@Aareksio
Copy link
Contributor Author

Aareksio commented Apr 30, 2024

Seems to still be present in nightly build:
https://stackblitz.com/edit/github-bjch62-15nb1v

"@/import-me" is imported by "routes/index.ts", but could not be resolved – treating it as an external dependency.

To be precise:

  • 🟩 both @ and ~ provide types now, this has been fixed
  • 🟥 ~ seems to work as alias, @ does not, this is still broken

Env: nitropack-nightly@2.10.0-28574393.aabdc9c5

@pi0
Copy link
Member

pi0 commented Apr 30, 2024

Please always prefer ~ for aliases. @ can be always tricky and conflicting with node package namespaces and an unreliable alias method we kept for historical compatibility reasons.

We might find fixes for working @ but it won't be a permanent fix therefore I think we cannot track this issue.

If there are issues with ~ alias, please feel free to open new issue.

@pi0 pi0 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants