fix(repack): pass inlined asset scales to pickScale in ascending order by RaphaelFakhri · Pull Request #1505 · callstack/repack · GitHub
Skip to content

fix(repack): pass inlined asset scales to pickScale in ascending order - #1505

Open
RaphaelFakhri wants to merge 2 commits into
callstack:mainfrom
RaphaelFakhri:fix/inline-assets-scale-order
Open

RaphaelFakhri wants to merge 2 commits into
callstack:mainfrom
RaphaelFakhri:fix/inline-assets-scale-order

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Summary

When inline: true is set on the assets loader, inlineAssets builds the list of scales passed to AssetSourceResolver.pickScale from Object.keys(sourceSet). JavaScript lists integer-like keys first, so the scales [0.75, 1, 1.5, 2, 3] come out as [1, 2, 3, 0.75, 1.5]. pickScale assumes ascending order and returns the first scale that is greater than or equal to the device pixel ratio, or the last one if none match. With the unsorted list, an asset that has a fractional variant resolves to the wrong image:

Pixel ratio Expected Before
0.75 @0.75x @1x
1.5 @1.5x @2x
3.5 @3x @1.5x (blurry)

Assets with only integer scales (@1x, @2x, @3x) are not affected.

This change builds the scales from assets, which the loader already sorts in ascending order. The inlined source set itself is unchanged.

Test plan

  • New unit test packages/repack/src/loaders/assetsLoader/__tests__/inlineAssets.test.ts evaluates the generated module with the same logic as React Native's pickScale for pixel ratios 0.75, 1, 1.5, 2.625 and 3.5.
    • Without the fix: 3 failed, 2 passed.
    • With the fix: 5 passed.
  • pnpm --filter @callstack/repack test: 42 suites, 364 tests passed.
  • pnpm vitest run src/loaders/assets-loader.test.ts in tests/integration: 76 passed, existing snapshots unchanged.
  • pnpm --filter @callstack/repack typecheck and biome check pass.
  • Added a patch changeset for @callstack/repack.

Fixes #1504

@vercel

vercel Bot commented Oct 20, 2026

Copy link
Copy Markdown

@RaphaelFakhri 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 Oct 20, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 9f83101

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 Patch
@callstack/repack-plugin-expo-modules Patch
@callstack/repack-plugin-nativewind Patch
@callstack/repack-plugin-reanimated Patch
@callstack/repack-dev-server Patch
@callstack/repack-init Patch

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.

Inlined assets with fractional scales resolve to the wrong variant

2 participants