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
I originally reported this issue to Vite, but the problem seems to originate in esbuild. (original issue)
When setting resolveExtensions to prioritize .web.tsx after .tsx, esbuild still picks up .tsx variants first in node_modules, even though it behaves correctly in local src code. Placing all .web entries before the non-web ones works around the issue, but it seems resolveExtensions is ignoring the intended ordering for packages in node_modules. It does work fine in files in the ./src directory for example.
Expected Behavior
Listing .web.tsx after .tsx in resolveExtensions should correctly pick up the .web.tsx variant for files in node_modules, just like it does for local src code.
Observed Behavior
When .web.tsx is listed after .tsx in resolveExtensions, esbuild still resolves to the .tsx file for dependencies in node_modules, rather than the .web.tsx variant.
Reproduction
Here is a minimal script demonstrating the behavior (see commented sections for the workaround). It uses expo-image from node_modules to illustrate the resolution bug. The github example has been narrowed down to exclude vite and uses esbuild only. https://github.com/Bram-dc/vite-react-native-web
You can switch around the commented resolveExtensions and also try the hotfix (lines 65-69)
The text was updated successfully, but these errors were encountered:
Bram-dc
changed the title
resolveExtensions not honoring .web.tsx when listed after .tsx, only for node_modules dependencies
resolveExtensions not honoring .web.tsx when listed after .tsx for node_modules dependencies
Jan 27, 2025
I originally reported this issue to Vite, but the problem seems to originate in esbuild. (original issue)
When setting resolveExtensions to prioritize .web.tsx after .tsx, esbuild still picks up .tsx variants first in node_modules, even though it behaves correctly in local src code. Placing all .web entries before the non-web ones works around the issue, but it seems resolveExtensions is ignoring the intended ordering for packages in node_modules. It does work fine in files in the ./src directory for example.
Expected Behavior
Listing .web.tsx after .tsx in resolveExtensions should correctly pick up the .web.tsx variant for files in node_modules, just like it does for local src code.
Observed Behavior
When .web.tsx is listed after .tsx in resolveExtensions, esbuild still resolves to the .tsx file for dependencies in node_modules, rather than the .web.tsx variant.
Reproduction
Here is a minimal script demonstrating the behavior (see commented sections for the workaround). It uses expo-image from node_modules to illustrate the resolution bug. The github example has been narrowed down to exclude vite and uses esbuild only. https://github.com/Bram-dc/vite-react-native-web
You can switch around the commented resolveExtensions and also try the hotfix (lines 65-69)
The text was updated successfully, but these errors were encountered: