Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6581

Expo 54 How to read bundled assets directly without extraction to cache?

$
0
0

I'm building an app with React Native / Expo SDK 54.The app bundles ~42,000 compressed HTML files (.zst format, ~224 MB compressed) that need to be accessible without network access.


The Problem

My production iOS build is 325 MB, but on first launch it creates another 330 MB in “Documents and Data” - basically duplicating all the assets.

First launch also takes 1+ minute, which is unacceptable.


What I’ve Tried

Originally used Asset.fromModule() with imports for each doc file.

  • This causes Expo to automatically extract all imported assets to cache on first launch.
  • Hence the duplication and slow startup.

Tried accessing files via Paths.bundle with the new File API (SDK 54).

  • Files don’t exist there.
  • I think this is because I’m importing them, so they’re embedded in the JS bundle, not included as separate bundled assets.

Tested multiple asset access methods in production.

  • Only asset.localUri works, but it points to the extracted cache location (the duplication I’m trying to avoid).
  • Same with DownloadAsync - works, but duplicates the file and is slower.

What I Want

Files should be bundled in the app at build time, then read directly from the bundle on-demand when a user opens a doc page.

It shouldn’t need to copy anything - just open the bundled file and read its bytes.

This feels like it should be simple - the files are in the bundle (325 MB proves it).I just want to read them without Expo copying them to cache first.

It also works perfectly in development builds and on web - it’s just native production builds causing issues.


Current Architecture

  • Thousands of .zst compressed HTML files
  • Manifests with import statements for each file (auto-generated)
  • Files referenced by hash in the manifest, loaded on-demand when a user navigates to a page
  • zst filetype is added as external asset to the metro config
  • Currently not doing anything in app.json for these assets

Questions

  1. Should I use assetBundlePatterns instead of imports?Would that make them accessible via Paths.bundle?

  2. Is there a way to bundle files without imports so Expo doesn’t auto-extract them?

  3. Is the asset.localUri extraction unavoidable when using Asset.fromModule()?

  4. Should I be using a completely different approach for bundling this many files?Or not bundle them at all and access them another way?


Environment:

  • Expo SDK 54
  • React Native 0.81.5
  • EAS Build (production iOS builds)
  • New architecture enabled

Viewing all articles
Browse latest Browse all 6581

Latest Images

Trending Articles



Latest Images