Skip to content

Commit 9b53591

Browse files
motiz88facebook-github-bot
authored andcommitted
Add package name / bundle ID to bundle URL in development
Summary: Adds the package name (Android) / bundle ID (iOS) as a new URL parameter named `app` in the bundle URL. This currently has no effect on Metro, which will ignore it for bundling / caching purposes. Changelog: [General] - Add package name / bundle ID to bundle URL in development Reviewed By: cpojer Differential Revision: D21429764 fbshipit-source-id: 394fe50dba72219f7594ebeac9486a8264a836a6
1 parent 63099c4 commit 9b53591

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

RNTester/RNTesterUnitTests/RCTBundleURLProviderTests.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020

2121
static NSURL *localhostBundleURL()
2222
{
23-
return [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=ios&dev=true&minify=false", testFile]];
23+
return [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=ios&dev=true&minify=false&app=com.apple.dt.xctest.tool", testFile]];
2424
}
2525

2626
static NSURL *ipBundleURL()
2727
{
28-
return [NSURL URLWithString:[NSString stringWithFormat:@"http://192.168.1.1:8081/%@.bundle?platform=ios&dev=true&minify=false", testFile]];
28+
return [NSURL URLWithString:[NSString stringWithFormat:@"http://192.168.1.1:8081/%@.bundle?platform=ios&dev=true&minify=false&app=com.apple.dt.xctest.tool", testFile]];
2929
}
3030

3131
@implementation NSBundle (RCTBundleURLProviderTests)

React/Base/RCTBundleURLProvider.m

+4
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot
187187
NSString *query = [NSString stringWithFormat:@"platform=ios&dev=%@&minify=%@",
188188
enableDev ? @"true" : @"false",
189189
enableMinification ? @"true" : @"false"];
190+
NSString *bundleID = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleIdentifierKey];
191+
if (bundleID) {
192+
query = [NSString stringWithFormat:@"%@&app=%@", query, bundleID];
193+
}
190194
return [[self class] resourceURLForResourcePath:path packagerHost:packagerHost query:query];
191195
}
192196

ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -421,12 +421,13 @@ private boolean getJSMinifyMode() {
421421
private String createBundleURL(String mainModuleID, BundleType type, String host) {
422422
return String.format(
423423
Locale.US,
424-
"http://%s/%s.%s?platform=android&dev=%s&minify=%s",
424+
"http://%s/%s.%s?platform=android&dev=%s&minify=%s&app=%s",
425425
host,
426426
mainModuleID,
427427
type.typeID(),
428428
getDevMode(),
429-
getJSMinifyMode());
429+
getJSMinifyMode(),
430+
mPackageName);
430431
}
431432

432433
private String createBundleURL(String mainModuleID, BundleType type) {

0 commit comments

Comments
 (0)