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 (TODO: add PR number for OSS) that hasn't landed yet, but is a no-op until then.

Reviewed By: jacdebug

Differential Revision: D43600054

fbshipit-source-id: 924ef979a694eb3b1f6cd2796ca85687940ae2b6
  • Loading branch information
motiz88 authored and facebook-github-bot committed Apr 20, 2023
1 parent da71c40 commit 64ec7a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 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

0 comments on commit 64ec7a4

Please sign in to comment.