GithubHelp home page GithubHelp logo

expo-loader-issue's Introduction

Overview

This project demonstrates the 'additional loader' issue with React Native/Expo & AWS Amplify. This problem only occurs when you build the application for the web. Android is fine.

Recreating

If you want to recreate this problem from scratch, you can apply the following steps. The App.tsx file from this project is already modified as needed.

# Create a new Expo application (in Typescript)
npx create-expo-app@latest -t expo-template-blank-typescript

# Change to your new project directory.

# Add development and application dependencies
npx expo install @expo/webpack-config -- --save-dev
npx expo install react-native-web react-dom
npx expo install @aws-amplify/ui-react-native react-native-get-random-values react-native-url-polyfill

# Set up Auth in Amplify.  Note: defaults are fine for this.
amplify init
amplify add auth
amplify push

If you just want to use this project as is and test it, all you need to do is perform the AWS Amplify steps.

Web Testing

First, just try to build the production web bundle.

npx expo export:web

You should receive the following error:

Failed to compile
CommandError: Module parse failed: Unexpected token (40:26)
File was processed with these loaders:
 * ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
|     const typedFields = getRouteTypedFields({ fields, route });
|     if (isAuthenticatedRoute(route)) {
>         return children ? <>{children}</> : null;
|     }
|     return (<SafeAreaProvider>

You can also just run the web build in development mode.

npm run web

This will launch the build and start a new browser tab. Once the transpilation is complete and the page loads in the browser, you will see the following in your terminal:

ERROR in ./node_modules/@aws-amplify/ui-react-native/dist/Authenticator/Authenticator.js 40:26
Module parse failed: Unexpected token (40:26)
File was processed with these loaders:
 * ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
|     const typedFields = getRouteTypedFields({ fields, route });
|     if (isAuthenticatedRoute(route)) {
>         return children ? <>{children}</> : null;
|     }
|     return (<SafeAreaProvider>

ERROR in ./node_modules/@aws-amplify/ui-react-native/dist/Authenticator/withAuthenticator.js 5:16
Module parse failed: Unexpected token (5:16)
File was processed with these loaders:
 * ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
| export default function withAuthenticator(Component, options = {}) {
|     return function WrappedWithAuthenticator(props) {
>         return (<Authenticator.Provider>
|         <Authenticator {...options}>
|           <Component {...props}/>

ERROR in ./node_modules/@aws-amplify/ui-react-native/dist/InAppMessaging/components/InAppMessageDisplay/InAppMessageDisplay.js 23:11
Module parse failed: Unexpected token (23:11)
File was processed with these loaders:
 * ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
|         onMessageAction,
|     });
>     return <Component {...props}/>;
| }
| InAppMessageDisplay.BannerMessage = BannerMessage;

ERROR in ./node_modules/@aws-amplify/ui-react-native/dist/InAppMessaging/components/withInAppMessaging/withInAppMessaging.js 6:16
Module parse failed: Unexpected token (6:16)
File was processed with these loaders:
 * ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
| export default function withInAppMessaging(Component, options) {
|     return function WrappedWithInAppMessaging(props) {
>         return (<InAppMessagingProvider>
|         <InAppMessageDisplay {...options}/>
|         <Component {...props}/>

ERROR in ./node_modules/@aws-amplify/ui-react-native/dist/theme/ThemeProvider.js 6:12
Module parse failed: Unexpected token (6:12)
File was processed with these loaders:
 * ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
| export const ThemeProvider = ({ children, theme, colorMode, }) => {
|     const value = React.useMemo(() => ({ theme: createTheme(theme, colorMode) }), [theme, colorMode]);
>     return (<ThemeContext.Provider value={value}>{children}</ThemeContext.Provider>);
| };
| 

web compiled with 5 errors

Android Testing

Launch the application in an Android emulator.

npm run android

Once the application loads, you should see the Sign In screen.

expo-loader-issue's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.