Skip to content

Commit

Permalink
Request bundles with excludeSource=true and sourcePaths=url-server in…
Browse files Browse the repository at this point in the history
… Fusebox experiment (#44444)

Summary:

Changelog: [Internal] - Request bundles with `excludeSource=true` and `sourcePaths=url-server`.

Changes RN's bundle client to request more efficient source maps from Metro by relying on lazy-fetching of source contents.

NOTE: Requires a Metro version with D56952064 and D56952063 (not yet released on npm) to work properly.

Reviewed By: robhogan

Differential Revision: D56952065
  • Loading branch information
motiz88 authored and facebook-github-bot committed May 8, 2024
1 parent deee037 commit 982e1ed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
8 changes: 8 additions & 0 deletions packages/react-native/React/Base/RCTBundleURLProvider.mm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#import "RCTDefines.h"
#import "RCTLog.h"

#import <jsinspector-modern/InspectorFlags.h>

NSString *const RCTBundleURLProviderUpdatedNotification = @"RCTBundleURLProviderUpdatedNotification";

const NSUInteger kRCTBundleURLProviderDefaultPort = RCT_METRO_PORT;
Expand Down Expand Up @@ -281,6 +283,12 @@ + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot
[[NSURLQueryItem alloc] initWithName:@"modulesOnly" value:modulesOnly ? @"true" : @"false"],
[[NSURLQueryItem alloc] initWithName:@"runModule" value:runModule ? @"true" : @"false"],
];
auto &inspectorFlags = facebook::react::jsinspector_modern::InspectorFlags::getInstance();
if (inspectorFlags.getEnableModernCDPRegistry()) {
queryItems = [queryItems arrayByAddingObject:[[NSURLQueryItem alloc] initWithName:@"excludeSource" value:@"true"]];
queryItems = [queryItems arrayByAddingObject:[[NSURLQueryItem alloc] initWithName:@"sourcePaths"
value:@"url-server"]];
}

NSString *bundleID = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleIdentifierKey];
if (bundleID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,17 +382,20 @@ private String createBundleURL(
String mainModuleID, BundleType type, String host, boolean modulesOnly, boolean runModule) {
boolean dev = getDevMode();
return String.format(
Locale.US,
"http://%s/%s.%s?platform=android&dev=%s&lazy=%s&minify=%s&app=%s&modulesOnly=%s&runModule=%s",
host,
mainModuleID,
type.typeID(),
dev, // dev
dev, // lazy
getJSMinifyMode(),
mPackageName,
modulesOnly ? "true" : "false",
runModule ? "true" : "false");
Locale.US,
"http://%s/%s.%s?platform=android&dev=%s&lazy=%s&minify=%s&app=%s&modulesOnly=%s&runModule=%s",
host,
mainModuleID,
type.typeID(),
dev, // dev
dev, // lazy
getJSMinifyMode(),
mPackageName,
modulesOnly ? "true" : "false",
runModule ? "true" : "false")
+ (InspectorFlags.getEnableModernCDPRegistry()
? "&excludeSource=true&sourcePaths=url-server"
: "");
}

private String createBundleURL(String mainModuleID, BundleType type) {
Expand Down

0 comments on commit 982e1ed

Please sign in to comment.