repack icon indicating copy to clipboard operation
repack copied to clipboard

Images are rendered incorrectly on the host app

Open syed-mustaqhim opened this issue 3 years ago • 1 comments

Environment

"@callstack/repack": "^2.5.2" "react-native": "0.68.1"

Description

I'm using Callstacks repack to build a bunch of widget apps which will be exposed as components and a rendered on the host app. The whole setup seems to be working well except that the images used in a widget are not rendered correctly on the host app; Instead it renders fallback images ( not sure where these are coming from ). I am using React Native's Image component to display the image. Here's what I mean:

Widgets app:

import {Text, View, StyleSheet, Image} from 'react-native';

<View style={[styles.container, styles.shadow]}>
      <Image source={require('./icons/leaf.png')} />
</View>

and so it renders:

Screenshot 2022-08-18 at 6 01 44 PM

Note: Used images as pngs of all sizes : 1x, 2x, 3x, 4x

But when The widget is loaded in the host app through webpack, it displays a completely different image:

Screenshot 2022-08-18 at 6 03 23 PM

Reproducible Demo

Webpack config is the same that comes out of the box. Adding the asset specific config here:

webpack.config.ts

 {
        test: ReactNative.getAssetExtensionsRegExp(
          ReactNative.ASSET_EXTENSIONS,
        ),
        use: {
          loader: '@callstack/repack/assets-loader',
          options: {
            platform,
            devServerEnabled: devServer.enabled,
            /**
             * Defines which assets are scalable - which assets can have
             * scale suffixes: `@1x`, `@2x` and so on.
             * By default all images are scalable.
             */
            scalableAssetExtensions: ReactNative.SCALABLE_ASSETS,
          },
        },
},

Any suggestions or ideas on this? Thanks

syed-mustaqhim avatar Aug 18 '22 12:08 syed-mustaqhim

Using any kind of static assets from remote chunks is a known limitation of repack, please see this comment for more context and possible workarounds.

RafikiTiki avatar Sep 06 '22 12:09 RafikiTiki

@syed-mustaqhim Any luck with what I've suggested in the comment above?

RafikiTiki avatar Jan 09 '23 16:01 RafikiTiki

@syed-mustaqhim – Good news, thanks to @jbroma great work (#331) we have first-class support for remote assets. Please check it out :)

RafikiTiki avatar Apr 07 '23 12:04 RafikiTiki