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

Fix tsconfig alias to paths in Web version #12

Open
mgonzalezg9 opened this issue Jan 30, 2024 · 2 comments
Open

Fix tsconfig alias to paths in Web version #12

mgonzalezg9 opened this issue Jan 30, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@mgonzalezg9
Copy link
Owner

Adding the alias is as easy as for normal React projects. The problem is that "Path aliases are only supported by Metro (including Metro web) and not by the deprecated @expo/webpack-config package." so a migration would be needed.

The problem comes with libraries like React Navigation, because they would be necessary changed.

@mgonzalezg9 mgonzalezg9 added the enhancement New feature or request label Jan 30, 2024
@mgonzalezg9 mgonzalezg9 added bug Something isn't working and removed enhancement New feature or request labels Apr 17, 2024
@mgonzalezg9
Copy link
Owner Author

Path aliases make the web version of the application not work.
This application does not aim to have a web version, but here is jotted down the error:

ERROR in ./src/navigation/index.tsx:6
Module not found: Can't resolve '@/screens/LocationDetails'
  4 |  *
  5 |  */
> 6 | import LocationDetailsScreen from "@/screens/LocationDetails";
  7 | import LocationRequestScreen from "@/screens/LocationRequest";
  8 | import NotFoundScreen from "@/screens/NotFoundScreen";
  9 | import {

ERROR in ./src/navigation/index.tsx:7
Module not found: Can't resolve '@/screens/LocationRequest'
   5 |  */
   6 | import LocationDetailsScreen from "@/screens/LocationDetails";
>  7 | import LocationRequestScreen from "@/screens/LocationRequest";
   8 | import NotFoundScreen from "@/screens/NotFoundScreen";
   9 | import {
  10 |   DarkTheme, DefaultTheme, NavigationContainer

ERROR in ./src/navigation/index.tsx:8
Module not found: Can't resolve '@/screens/NotFoundScreen'
   6 | import LocationDetailsScreen from "@/screens/LocationDetails";
   7 | import LocationRequestScreen from "@/screens/LocationRequest";
>  8 | import NotFoundScreen from "@/screens/NotFoundScreen";
   9 | import {
  10 |   DarkTheme, DefaultTheme, NavigationContainer
  11 | } from "@react-navigation/native";

web compiled with 4 errors
ERROR in ./node_modules/expo-modules-core/build/uuid/uuid.web.js:9:8
Module not found: Can't resolve 'crypto'
   7 |   const cryptoObject =
   8 |     typeof crypto === 'undefined' || typeof crypto.randomUUID === 'undefined'
>  9 |       ? require('crypto')
     |        ^
  10 |       : crypto;
  11 |
  12 |   if (!cryptoObject?.randomUUID) {

ERROR in ./src/navigation/index.tsx:6
Module not found: Can't resolve '@/screens/LocationDetails'
  4 |  *
  5 |  */
> 6 | import LocationDetailsScreen from "@/screens/LocationDetails";
  7 | import LocationRequestScreen from "@/screens/LocationRequest";
  8 | import NotFoundScreen from "@/screens/NotFoundScreen";
  9 | import {

ERROR in ./src/navigation/index.tsx:7
Module not found: Can't resolve '@/screens/LocationRequest'
   5 |  */
   6 | import LocationDetailsScreen from "@/screens/LocationDetails";
>  7 | import LocationRequestScreen from "@/screens/LocationRequest";
   8 | import NotFoundScreen from "@/screens/NotFoundScreen";
   9 | import {
  10 |   DarkTheme, DefaultTheme, NavigationContainer

ERROR in ./src/navigation/index.tsx:8
Module not found: Can't resolve '@/screens/NotFoundScreen'
   6 | import LocationDetailsScreen from "@/screens/LocationDetails";
   7 | import LocationRequestScreen from "@/screens/LocationRequest";
>  8 | import NotFoundScreen from "@/screens/NotFoundScreen";
   9 | import {
  10 |   DarkTheme, DefaultTheme, NavigationContainer
  11 | } from "@react-navigation/native";

Marked as bug.

@mgonzalezg9 mgonzalezg9 changed the title Add tsconfig alias to paths Fix tsconfig alias to paths in Web version Apr 17, 2024
@mgonzalezg9
Copy link
Owner Author

Used the following Expo SDK 50 tutorial: https://docs.expo.dev/guides/typescript/#path-aliases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant