-
Notifications
You must be signed in to change notification settings - Fork 155
feat: add maxInlineSize option for size-based asset inlining #1378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dannyhw
merged 6 commits into
callstack:main
from
bartekkrok:feat/size-limit-for-inline-assets
Apr 23, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
13d99a6
add maxInlineSize option for size-based asset inlining
bartekkrok 4521cff
Add changeset, refer to code review and add tests for maxInlineSize o…
bartekkrok b8ec49c
fix: correct snapshots for maxInlineSize inline tests and fix biome f…
bartekkrok e608304
fix: require inline: true for maxInlineSize to take effect
bartekkrok 808f306
fix: linting
dannyhw 455ed12
chore: add example of inline asset limit
dannyhw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@callstack/repack": minor | ||
| --- | ||
|
|
||
| Add `maxInlineSize` option to assets loader for size-based asset inlining. Use it together with `inline: true` — assets whose largest variant is within the threshold are inlined as base64 URIs; larger assets are extracted as separate files. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
168 changes: 168 additions & 0 deletions
168
apps/tester-federation-v2/src/host/screens/HostAssetsScreen.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| import { | ||
| FlatList, | ||
| Image, | ||
| type ImageRequireSource, | ||
| StyleSheet, | ||
| Text, | ||
| View, | ||
| } from 'react-native'; | ||
|
|
||
| const assets = [ | ||
| { | ||
| source: require('../assets/pic_1.jpg'), | ||
| status: 'Inlined', | ||
| size: '89,400 bytes', | ||
| }, | ||
| { | ||
| source: require('../assets/pic_2.jpg'), | ||
| status: 'Emitted', | ||
| size: '121,569 bytes', | ||
| }, | ||
| { | ||
| source: require('../assets/pic_3.jpg'), | ||
| status: 'Inlined', | ||
| size: '59,862 bytes', | ||
| }, | ||
| ]; | ||
|
|
||
| const data = assets.map((asset, index) => ({ | ||
| title: `Host asset ${index + 1}`, | ||
| ...asset, | ||
| })); | ||
|
|
||
| const AssetRow = ({ | ||
| title, | ||
| source, | ||
| status, | ||
| size, | ||
| }: { | ||
| title: string; | ||
| source: ImageRequireSource; | ||
| status: string; | ||
| size: string; | ||
| }) => ( | ||
| <View style={styles.row}> | ||
| <Image source={source} style={styles.image} /> | ||
| <View style={styles.titleContainer}> | ||
| <View style={styles.titleRow}> | ||
| <Text style={styles.title}>{title}</Text> | ||
| <View | ||
| style={[ | ||
| styles.badge, | ||
| status === 'Inlined' ? styles.inlineBadge : styles.emittedBadge, | ||
| ]} | ||
| > | ||
| <Text | ||
| style={[ | ||
| styles.badgeText, | ||
| status === 'Inlined' | ||
| ? styles.inlineBadgeText | ||
| : styles.emittedBadgeText, | ||
| ]} | ||
| > | ||
| {status} | ||
| </Text> | ||
| </View> | ||
| </View> | ||
| <Text style={styles.size}>{size}</Text> | ||
| <Text style={styles.subtitle}> | ||
| Loaded from the host app bundle to test inline asset size limits | ||
| </Text> | ||
| </View> | ||
| </View> | ||
| ); | ||
|
|
||
| const HostAssetsScreen = () => { | ||
| return ( | ||
| <FlatList | ||
| contentInsetAdjustmentBehavior="automatic" | ||
| contentContainerStyle={styles.contentContainer} | ||
| data={data} | ||
| keyExtractor={(item) => item.title} | ||
| renderItem={({ item }) => ( | ||
| <AssetRow | ||
| title={item.title} | ||
| source={item.source} | ||
| status={item.status} | ||
| size={item.size} | ||
| /> | ||
| )} | ||
| style={styles.container} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { | ||
| flex: 1, | ||
| backgroundColor: '#F5F9FF', | ||
| }, | ||
| contentContainer: { | ||
| paddingVertical: 20, | ||
| }, | ||
| row: { | ||
| marginBottom: 20, | ||
| marginHorizontal: 15, | ||
| backgroundColor: 'white', | ||
| borderRadius: 10, | ||
| overflow: 'hidden', | ||
| shadowColor: '#2C3E50', | ||
| shadowOffset: { width: 0, height: 2 }, | ||
| shadowOpacity: 0.1, | ||
| shadowRadius: 4, | ||
| elevation: 3, | ||
| }, | ||
| image: { | ||
| width: '100%', | ||
| height: 250, | ||
| resizeMode: 'cover', | ||
| }, | ||
| titleContainer: { | ||
| padding: 15, | ||
| }, | ||
| titleRow: { | ||
| alignItems: 'center', | ||
| flexDirection: 'row', | ||
| gap: 10, | ||
| marginBottom: 5, | ||
| }, | ||
| title: { | ||
| flex: 1, | ||
| fontSize: 18, | ||
| fontWeight: '600', | ||
| color: '#2C3E50', | ||
| }, | ||
| badge: { | ||
| borderRadius: 4, | ||
| paddingHorizontal: 8, | ||
| paddingVertical: 4, | ||
| }, | ||
| inlineBadge: { | ||
| backgroundColor: '#DFF5E7', | ||
| }, | ||
| emittedBadge: { | ||
| backgroundColor: '#FFF1D6', | ||
| }, | ||
| badgeText: { | ||
| fontSize: 12, | ||
| fontWeight: '700', | ||
| }, | ||
| inlineBadgeText: { | ||
| color: '#1E7F45', | ||
| }, | ||
| emittedBadgeText: { | ||
| color: '#9A5A00', | ||
| }, | ||
| size: { | ||
| color: '#7F8C8D', | ||
| fontSize: 13, | ||
| marginBottom: 5, | ||
| }, | ||
| subtitle: { | ||
| fontSize: 14, | ||
| color: '#3498DB', | ||
| fontWeight: '400', | ||
| }, | ||
| }); | ||
|
|
||
| export default HostAssetsScreen; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.