Skip to content

Commit

Permalink
Enable lazy bundling in dev on iOS/Android (#37003)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #37003

Changelog: [General][Added] [3/n] Support lazy bundling in development

Enables [lazy bundling](https://github.com/react-native-community/discussions-and-proposals/blob/main/proposals/0605-lazy-bundling.md) when requesting a development bundle from Metro.

NOTE: This depends on a Metro diff (facebook/metro#971) that hasn't landed yet, but is a no-op until then.

Reviewed By: jacdebug

Differential Revision: D43600054

fbshipit-source-id: 515e2180a2130fd1a75e53677e789d31a367f7c2
  • Loading branch information
motiz88 authored and facebook-github-bot committed Apr 24, 2023
1 parent 28d5c15 commit e66bdf0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions packages/react-native/React/Base/RCTBundleURLProvider.mm
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,11 @@ + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot
runModule:(BOOL)runModule
{
NSString *path = [NSString stringWithFormat:@"/%@.bundle", bundleRoot];

BOOL lazy = enableDev;
// When we support only iOS 8 and above, use queryItems for a better API.
NSString *query = [NSString stringWithFormat:@"platform=ios&dev=%@&minify=%@&modulesOnly=%@&runModule=%@",
NSString *query = [NSString stringWithFormat:@"platform=ios&dev=%@&lazy=%@&minify=%@&modulesOnly=%@&runModule=%@",
enableDev ? @"true" : @"false",
lazy ? @"true" : @"false",
enableMinification ? @"true" : @"false",
modulesOnly ? @"true" : @"false",
runModule ? @"true" : @"false"];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,16 @@ private String createSplitBundleURL(String mainModuleID, String host) {

private String createBundleURL(
String mainModuleID, BundleType type, String host, boolean modulesOnly, boolean runModule) {
boolean dev = getDevMode();
boolean lazy = dev;
return String.format(
Locale.US,
"http://%s/%s.%s?platform=android&dev=%s&minify=%s&app=%s&modulesOnly=%s&runModule=%s",
"http://%s/%s.%s?platform=android&dev=%s&lazy=%s&minify=%s&app=%s&modulesOnly=%s&runModule=%s",
host,
mainModuleID,
type.typeID(),
getDevMode(),
dev,
lazy,
getJSMinifyMode(),
mPackageName,
modulesOnly ? "true" : "false",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
URLWithString:
[NSString
stringWithFormat:
@"http://localhost:8081/%@.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.apple.dt.xctest.tool",
@"http://localhost:8081/%@.bundle?platform=ios&dev=true&lazy=true&minify=false&modulesOnly=false&runModule=true&app=com.apple.dt.xctest.tool",
testFile]];
}

Expand All @@ -36,7 +36,7 @@
URLWithString:
[NSString
stringWithFormat:
@"http://192.168.1.1:8081/%@.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.apple.dt.xctest.tool",
@"http://192.168.1.1:8081/%@.bundle?platform=ios&dev=true&lazy=true&minify=false&modulesOnly=false&runModule=true&app=com.apple.dt.xctest.tool",
testFile]];
}

Expand Down

0 comments on commit e66bdf0

Please sign in to comment.