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
In Vite Dev Mode, modules should be aliased when defined in resolve.alias in vite.config.ts.
Actual Behavior
Modules are not aliased when running dev. They are instead properly aliased when running build.
I have discovered after some investigation that the errors happens in the vite plugin, precisely when running await viteDevServer.ssrLoadModule(serverBuildId);.
The text was updated successfully, but these errors were encountered:
I have discovered after some investigation that the errors happens in the vite plugin, precisely when running await viteDevServer.ssrLoadModule(serverBuildId); - @emanueleperuffo
If the underlying root cause is with vite.ssrLoadModule (havent dug into code myself), another potential fix is to adopt the new vite runtime API which is meant to replace vite.ssrLoadModule + has more benefits
When you have genuine react-native in your dependency, resolve.alias: { "react-native": "..." } currently doesn't kick in during Vite SSR.
This behavior is probably a bug on Vite, but their general recommendation is to use package manager based alias such as "react-native": "npm:react-native-web@..." as explained in the documentation https://vitejs.dev/config/shared-options.html#resolve-alias
Reproduction
To setup:
yarn install
To see the error:
yarn run dev
To understand it's not aliasing:
react-native
withreact-native-web
yarn run dev
To see that aliasing works in build mode (not development):
react-native
instead ofreact-native-web
yarn run build
yarn run start
System Info
Stackblitz:
My machine:
Used Package Manager
yarn
Expected Behavior
In Vite Dev Mode, modules should be aliased when defined in
resolve.alias
invite.config.ts
.Actual Behavior
Modules are not aliased when running
dev
. They are instead properly aliased when runningbuild
.I have discovered after some investigation that the errors happens in the vite plugin, precisely when running
await viteDevServer.ssrLoadModule(serverBuildId);
.The text was updated successfully, but these errors were encountered: