Subwaytime / vite-aliases

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

add new option to add re-export paths #30

Closed davidohlin closed 3 years ago

davidohlin commented 3 years ago

Hi.

Just found this plugin and it works great! Unfortunately I normally re-export modules from the index file of a directory. For that to work you need a alias pointing to the directory itself. I added a option called addReExportPaths to support the use case.

// tsconfig.json
{
  "compilerOptions": {
    ...
    "paths": {
      "@components/": ["./src/components/*"],
      // this will be added for every directory when addReExportPaths: true is passed
      "@components": ["./src/components"] 
    }
  },
}

Which will allow you to do this:

// ../components/index.ts
export { Button } from './Button'
export { Card } from './Card'

// ../some-feature/View.ts
import { Button, Card } from '@components'

Hope this looks alright. Would love your thoughts on this, or things that I might have missed.

Thanks!

Subwaytime commented 3 years ago

Hey there! The Idea looks great, i will have a proper look at it in this Week and do some Tests! I wanted to flesh out the Config Generation anyways because right now it lacks some more complex Features, so ill probably include this feature here in the upcoming bigger Changes!

Subwaytime commented 3 years ago

Hey there again! Ive run some tests and overall it seems fine, i will adjust some specifics next week with some other changes to the config generation, then it should be good to go !

davidohlin commented 3 years ago

Great! 🥳

Subwaytime commented 3 years ago

Hey there! Sorry for the huge Delay, ive been discussing this Topic with various other Developers to find a better Solution then just adding more Paths. As it seems there are some other Ways around it and i am currently implementing these!

Will keep you updated here, soonish!

davidohlin commented 3 years ago

@Subwaytime Don't worry about it, I understand you have other things to do!

Yeah, I think my approach might have been a little bit naive. Looking forward to the new implementation! Feel free to close the issue.

Subwaytime commented 3 years ago

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

@davidohlin ill copied most of the changes as ive already started working on the rewrite!

davidohlin commented 3 years ago

@Subwaytime Tight, thanks! 👏🏼