-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Comments
What is also important to notice that it resolved Test.web.tsx correctly all the time. |
Some background: The behavior of TypeScript files in That said, this should be working as this package contains I'll fix the sorting comparison in the next release. Note to myself: I briefly investigated whether this behavior should be reconsidered given that node has started supporting running TypeScript files directly. However, it looks like they are not planning to support this for files inside of |
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: