You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently alias option works in several situations:
Inside source code
For import calls, if module is inlined, using deps.inline
For import calls, if registerNodeLoader is enabled
Unfortunately there is no way to make it work for require calls inside source code or external libraries code. This might be useful for aliasing react with preact, for example.
We cannot reuse resolveId function from Vite for this, because it is asynchronous. We should only use resolve.alias and test.alias for this, not resolveId hook of plugins.
Clear and concise description of the problem
Currently
alias
option works in several situations:import
calls, if module is inlined, usingdeps.inline
Forimport
calls, ifregisterNodeLoader
is enabledUnfortunately there is no way to make it work for
require
calls inside source code or external libraries code. This might be useful for aliasingreact
withpreact
, for example.Suggested solution
Use
Module
to allow aliasingrequire
calls. Example: https://github.com/ilearnio/module-alias/blob/dev/index.jsWe cannot reuse
resolveId
function from Vite for this, because it is asynchronous. We should only useresolve.alias
andtest.alias
for this, notresolveId
hook of plugins.Alternative
No response
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: