Subwaytime / vite-aliases

Alias auto generation for Vite
https://www.npmjs.com/package/vite-aliases
MIT License
210 stars 12 forks source link

option for "index.js / index.ts" for components / modules path with index.ts / index.js #31

Closed tsanyqudsi closed 2 years ago

tsanyqudsi commented 3 years ago

let say we have a structure like this :

root
  src
    components
    libraries
  main.tsx

vite-aliases would generate

"@/*": [
  "./src/*"
],
"@components/*": [
  "./src/components/*"
],
"@libraries/*": [
  "./src/libraries/*"
]

The import works fine of course, but things got problems when you're adding index.ts / index.js for each structure. for example :

root
  src
    components
      component.tsx <-- importing Component
      index.ts
    libraries
      library.ts <-- importing lib()
      index.ts
  main.tsx

We can't import things like @components and / or @libraries because tsconfig / jsconfig demand the exact file name for the component / library we want to import. for example :

import { Component } from '@components/component' <-- works
import { Component } from '@components' <-- doesn't work
Subwaytime commented 3 years ago

Hey there!

So this Issue basically ties into the already requested feature here: https://github.com/Subwaytime/vite-aliases/pull/30.

I am currently rewriting the config generation in total and add some additional features that are missing from the configs. For Vue Users, i am working on integrating a better support for volar and vetur. As for other Frameworks, i am not sure if there is something similiar for react and svelte, as i have never used these frameworks.

TLDR: This Issue will be resolved in the upcoming Version and some other Config Issues that currently exist.

Subwaytime commented 2 years ago

fixed with v0.8.7. Note: its just a quick fix and will changed in v0.9.0!