vike
vike copied to clipboard
Support any path alias
Description
As discussed here it seems that Nx expects monorepo package names to start with @
.
There is a Vike internal issue with path aliases that cannot be distinguished from npm package names. I've tried a workaround but couldn't make it work so far (but I'm fairly confident it's possible to make it work).
A warning should still be shown as defining indistinguishable path aliases is asking for trouble (as attested by Vike's internal issue with it). It also makes code less readable. In general, breaking implicit assumptions should be avoided as much as possible. Although Vike probably shouldn't show a warning for indistinguishable aliases set by Vite plugins the user has no control over with.
Does this mean we can safely ignore the deprecation warning: defines an invalid resolve.alias which will be deprecated in the next major release: a path alias cannot start with @, see https://vike.dev/path-aliases#vite?
If you want to be optimistic then yes go ahead. If you want to be conservative then wait until I find the solution (I'm fairly optimistic I will but I cannot guarantee it).
If I'm successful, there'll still be a warning (you should avoid breaking implicit conventions as much as possible) but you'll be able to suppress the warning and Vike will work just fine.
Hi, i have a similar question about tilde. In my config I am using regex:
{
resolve: {
alias: [{ find: /^~(.*)$/, replacement: "$1" }],
},
}
Although it would be possible to us string as pattern, I would like to ensure only aliases which begin with tilde should be processed.
So the question is what is the preferred way?
Thanks
@jurijzahn8019 That's a neat alias. I think it should be possible/easy to analyze and whitelist such regex pattern.
Another +1, vike shouldn't dictate what a path alias starts with.
To be clear: I agree Vike shouldn't be prescriptive, it's just isn't as easy as it seems. But, as said, I think it's doable. Let's see.
Another problematic library: https://github.com/vikejs/vike/discussions/1356.
I am facing the similar problem.
In my case we have to use several vue libraries within a monorepo project, and bring them into one app. It may happen, that these packages have their own vue/vuex dependency and it is not preferable, to later have several vue/vuex instances on the same bundle. So normally the following alias solved this problem:
{
find: 'vue',
replacement: fileURLToPath(new URL('node_modules/vue', import.meta.url)),
},
{
find: 'vuex',
replacement: fileURLToPath(new URL('node_modules/vuex', import.meta.url)),
},
but now vike tells me that this syntax will soon be deprecated, although it looks like a valid case for its own need. IMO as well, vike should not dictate how vite config should look like.
@dmytro-grablov I see, makes sense. FYI removing the warning (and resolving the issue beyond the warning) is high priority, which I'll implement as soon as all urgent tickets are implemented.
Vike now officially supports any path alias.
Pre-released in 0.4.166-commit-6a8acaa
. Release ETA this week.
Note that a warning (that you'll be able to suppress) will still be shown after https://github.com/vikejs/vike/issues/1567 is implemented.
Btw. Vike is looking for sponsors, any amount is appreciated!