aleclarson / vite-tsconfig-paths

Support for TypeScript's path mapping in Vite
MIT License
1.23k stars 44 forks source link

Does not work using slash as symbol alias #125

Closed elboletaire closed 8 months ago

elboletaire commented 8 months ago

I was trying to migrate my alias to use / instead of @, but using this plugin it just does not work. Here's the paths definition in my tsconfig file:

    "paths": {
      "/components/*": ["components/*"],
      "/constants": ["constants/index.ts"],
      "/constants/*": ["constants/*"],
      "/elements/*": ["elements/*"],
      "/i18n": ["i18n/index.ts"],
      "/i18n/*": ["i18n/*"],
      "/theme/*": ["theme/*"],
      "/src/*": ["./*"]
    }

I had to manually set the alias in resolve in order to get it working (making this plugin useless for this specific purpose):

  resolve: {
    alias: {
      '/components/': __dirname + '/src/components/',
      '/constants/': __dirname + '/src/constants/',
      '/constants': __dirname + '/src/constants/index.ts',
      '/elements/': __dirname + '/src/elements/',
      '/i18n/': __dirname + '/src/i18n/',
      '/i18n': __dirname + '/src/i18n/index.ts',
      '/theme/': __dirname + '/src/theme/',
      '/src/': __dirname + '/src/',
    },
  },

Am I missing something to make it work in this plugin?

If you're wondering why do I want to use a slash instead of an at, it's just because slash gets sorted after at, properly sorting external and internal modules in my code.

Edit: I ended up using tilde instead, since it's even better for sorting purposes, and that one works with this extension. Still, this may be an issue for other developers.

aleclarson commented 8 months ago

Duplicate of #101