Skip to content

feat(repack): add cacheKey to ScriptLocator - #1530

Open
Fl0p wants to merge 1 commit into
callstack:mainfrom
Fl0p:feat/script-locator-cache-key
Open

Fl0p wants to merge 1 commit into
callstack:mainfrom
Fl0p:feat/script-locator-cache-key

Conversation

@Fl0p

@Fl0p Fl0p commented Nov 10, 2026

Copy link
Copy Markdown

Summary

Closes #1529.

ScriptManager caches a script under <caller>_<scriptId>, and the native side uses the same id as the file name (RemoteScriptLoader.getScriptFilePath on Android, ScriptManager.mm on iOS). A new version of a script therefore replaces the previous one on the device, and an app cannot keep the previous version to load it again when the new one fails.

This PR adds an optional cacheKey to ScriptLocator. When it is set, Script.from appends it to the uniqueId (<caller>_<scriptId>@<cacheKey>), so each key gets its own cache entry and its own file. Without cacheKey, nothing changes.

  • ScriptLocator.cacheKey with its docs (types.ts)
  • Script.from builds the uniqueId with the key (Script.ts)
  • the in-flight deduplication in loadScript / prefetchScript still uses the base id, so one script id loads once at a time
  • invalidateScripts already works with the cache ids, so passing <caller>_<scriptId>@<cacheKey> removes one cached copy
  • a section in the ScriptManager docs and a minor changeset

No native change: both platforms already take the file name from uniqueId.

Test plan

  • should append cacheKey to uniqueId: the resolved locator has main_src_App_js@v1.
  • should keep a separate cache entry for each cacheKey: load v1, resolve and load v2 (fetch: true), resolve v1 again (fetch: false, its cache entry is still there). Without the change, the last step fetches again, because v2 replaced the entry.
  • The same change runs in an app as a local patch on 5.4.0.

🤖 Generated with Claude Code

A script is cached under `<caller>_<scriptId>`, and the native side uses
the same id as the file name. A new version of a script therefore
replaces the previous one on the device.

An optional `cacheKey` on the locator is appended to the `uniqueId`
(`<caller>_<scriptId>@<cacheKey>`), so each key gets its own cache entry
and its own file. Without `cacheKey`, nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 10, 2026

Copy link
Copy Markdown

@Fl0p is attempting to deploy a commit to the Callstack Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Nov 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 854ede5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@callstack/repack Minor
@callstack/repack-plugin-expo-modules Minor
@callstack/repack-plugin-nativewind Minor
@callstack/repack-plugin-reanimated Minor
@callstack/repack-dev-server Minor
@callstack/repack-init Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ScriptLocator: allow a cache key so several versions of one script can stay on the device

1 participant