vikejs / vike

🔨 Flexible, lean, community-driven, dependable, fast Vite-based frontend framework.
https://vike.dev
MIT License
4.34k stars 348 forks source link

Define path aliases only once #1547

Open brillout opened 8 months ago

brillout commented 8 months ago

Description

Instead of having to define path aliases up to two times (as described in https://vike.dev/path-aliases), it would be nice if users can define their path aliases only once.

JavaScript users would define aliases only once at their package.json#imports.

TypeScript users would define aliases only once at tsconfig.json#compilerOptions.paths.

We can then show a warning/error if the user attemps to define a path alias using vite.config.js. (I believe if Vike uses a config() hook instead of configResolved() it can apply the warning/error only to path aliases set by the user, and not to path aliases set by Vite plugins.)

brillout commented 7 months ago

A correct implement isn't trivial, see https://github.com/rolldown/rolldown/issues/637.

Instead, Vike could support this if and only if tsconfig.json#compilerOptions.paths/package.json#imports lives in the same directory than vite.config.js.

brillout commented 7 months ago

It's on Vite's radar: https://twitter.com/youyuxi/status/1770453125067149448.