WhoBuilt

Remote Assets in super apps with Re.Pack 3.2.0

Jun 10, 2023· 9 min· 536 views·Watch on YouTube

An unnamed Callstack presenter explains remote assets in Re.Pack 3.2.0 and how super apps can load assets from dynamically fetched modules.

Why remote assets were needed

Before Re.Pack 3.2.0, teams had to build their own solution or work around the tool to load assets from federated modules. The built-in feature aims to make this process maintainable.

Earlier ways to handle assets

One option was to convert assets such as images to Base64 and include them in the bundle, which increased bundle size. Another was to package mini-app assets in the host app with code changes, but this was not officially supported.

Benefits and trade-offs

During development, assets can be loaded locally; in production, they can be uploaded to a CDN and loaded remotely. Re.Pack records image dimensions during bundling, and keeping assets out of the bundle can reduce bundle size and improve startup time. Remote loading may need placeholders or loading states, and the CDN address must be known at build time.

Loading and scaling assets

The presenter describes using React Native Fast Image to prefetch assets for a mini-app’s first screen. Re.Pack can also choose the needed scale of a scaled asset at runtime, so the app downloads one appropriate version instead of every size.

Configuration and feedback

The presenter points viewers to Re.Pack’s remote-assets documentation for configuring the assets loader and Webpack asset loader. They encourage teams to tune the configuration for their use case and share feedback or issues on GitHub.

Takeaways

  • Move production assets to a CDN to keep them out of the JavaScript bundle and help improve startup time.
  • Set the CDN address at build time because remote asset URLs are written into the bundle.
  • Use placeholders or loading states for assets that arrive over the network.
  • Prefetch first-screen images and let runtime scale selection avoid downloading unused resolutions.

Mentioned in this talk

Search inside this talk

What was claimed 6

  • feature
    Re.Pack: Built-in remote asset support in version 3.2.0
    “we decided to implement a built-in way to address the remote assets problem”
    YouTube
    Unverified1 source· Talk
  • uses
    “in production ... you upload them to a CDN and then download them as remote assets”
    YouTube
    Unverified1 source· Talk
  • feature
    remote assets: Asset width and height are saved during bundling
    “We save the information during the bundling process”
    YouTube
    Unverified1 source· Talk
  • feature
    remote assets: Smaller bundle and better startup time by moving assets to a CDN
    “we have a smaller bundle with better startup time”
    YouTube
    Unverified1 source· Talk
  • feature
    remote assets: CDN address must be known at build time
    “we need to know the CDN address beforehand, at build time”
    YouTube
    Unverified1 source· Talk
  • feature
    Re.Pack: Resolves scaled remote asset variants at runtime and downloads the needed scale
    “It will check which scale it needs and use that URL to download the necessary asset”
    YouTube
    Unverified1 source· Talk

Related talks