Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolveExtensions not honoring .web.tsx when listed after .tsx for node_modules dependencies #4053

Open
Bram-dc opened this issue Jan 27, 2025 · 1 comment

Comments

@Bram-dc
Copy link

Bram-dc commented 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)

@Bram-dc 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
@Bram-dc
Copy link
Author

Bram-dc commented Jan 27, 2025

What is also imported to notice that it resolved Test.web.tsx correctly all the time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant