From b834be923ccf92bdbbd1d45a0d93145b63ea2a35 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Wed, 14 Jun 2023 04:13:46 -0700 Subject: [PATCH 1/6] [iOS] Inline the source map if we're using JSC --- .../React/Base/RCTBundleURLProvider.h | 6 +- .../React/Base/RCTBundleURLProvider.mm | 55 +++++++++++++------ packages/rn-tester/RNTester/AppDelegate.mm | 3 + 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/packages/react-native/React/Base/RCTBundleURLProvider.h b/packages/react-native/React/Base/RCTBundleURLProvider.h index cbf8132b1da907..76b3bc79825b9c 100644 --- a/packages/react-native/React/Base/RCTBundleURLProvider.h +++ b/packages/react-native/React/Base/RCTBundleURLProvider.h @@ -101,6 +101,7 @@ RCT_EXTERN void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed); @property (nonatomic, assign) BOOL enableMinification; @property (nonatomic, assign) BOOL enableDev; +@property (nonatomic, assign) BOOL inlineSourceMap; /** * The scheme/protocol used of the packager, the default is the http protocol @@ -133,7 +134,8 @@ RCT_EXTERN void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed); enableDev:(BOOL)enableDev enableMinification:(BOOL)enableMinification modulesOnly:(BOOL)modulesOnly - runModule:(BOOL)runModule; + runModule:(BOOL)runModule + inlineSourceMap:(BOOL)inlineSourceMap; /** * Given a hostname for the packager and a resource path (including "/"), return the URL to the resource. * In general, please use the instance method to decide if the packager is running and fallback to the pre-packaged @@ -142,6 +144,6 @@ RCT_EXTERN void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed); + (NSURL *)resourceURLForResourcePath:(NSString *)path packagerHost:(NSString *)packagerHost scheme:(NSString *)scheme - query:(NSString *)query; + queryItems:(NSArray *)queryItems; @end diff --git a/packages/react-native/React/Base/RCTBundleURLProvider.mm b/packages/react-native/React/Base/RCTBundleURLProvider.mm index f1dc797815c87d..46b2c0b1075191 100644 --- a/packages/react-native/React/Base/RCTBundleURLProvider.mm +++ b/packages/react-native/React/Base/RCTBundleURLProvider.mm @@ -26,6 +26,7 @@ void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed) static NSString *const kRCTJsLocationKey = @"RCT_jsLocation"; static NSString *const kRCTEnableDevKey = @"RCT_enableDev"; static NSString *const kRCTEnableMinificationKey = @"RCT_enableMinification"; +static NSString *const kRCTinlineSourceMapKey = @"RCT_inlineSourceMap"; @implementation RCTBundleURLProvider @@ -43,6 +44,9 @@ - (NSDictionary *)defaults return @{ kRCTEnableDevKey : @YES, kRCTEnableMinificationKey : @NO, +#if !USE_HERMES + kRCTinlineSourceMapKey: @YES, +#endif }; } @@ -188,7 +192,8 @@ - (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot fallbackURLProvider:( enableDev:[self enableDev] enableMinification:[self enableMinification] modulesOnly:NO - runModule:YES]; + runModule:YES + inlineSourceMap:[self inlineSourceMap]]; } } @@ -200,7 +205,8 @@ - (NSURL *)jsBundleURLForSplitBundleRoot:(NSString *)bundleRoot enableDev:[self enableDev] enableMinification:[self enableMinification] modulesOnly:YES - runModule:NO]; + runModule:NO + inlineSourceMap:NO]; } - (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot fallbackExtension:(NSString *)extension @@ -238,7 +244,7 @@ - (NSURL *)resourceURLForResourceRoot:(NSString *)root return [[self class] resourceURLForResourcePath:path packagerHost:packagerServerHostPort scheme:packagerServerScheme - query:nil]; + queryItems:nil]; } + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot @@ -253,7 +259,8 @@ + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot enableDev:enableDev enableMinification:enableMinification modulesOnly:NO - runModule:YES]; + runModule:YES + inlineSourceMap:NO]; } + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot @@ -263,34 +270,37 @@ + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot enableMinification:(BOOL)enableMinification modulesOnly:(BOOL)modulesOnly runModule:(BOOL)runModule + inlineSourceMap:(BOOL)inlineSourceMap; + { 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=%@&lazy=%@&minify=%@&modulesOnly=%@&runModule=%@", - enableDev ? @"true" : @"false", - lazy ? @"true" : @"false", - enableMinification ? @"true" : @"false", - modulesOnly ? @"true" : @"false", - runModule ? @"true" : @"false"]; + + NSArray *queryItems = @[ + [[NSURLQueryItem alloc] initWithName:@"dev" value:enableDev ? @"true" : @"false"], + [[NSURLQueryItem alloc] initWithName:@"lazy" value:enableMinification ? @"true" : @"false"], + [[NSURLQueryItem alloc] initWithName:@"minify" value:modulesOnly ? @"true" : @"false"], + [[NSURLQueryItem alloc] initWithName:@"modulesOnly" value:modulesOnly ? @"true" : @"false"], + [[NSURLQueryItem alloc] initWithName:@"runModule" value:runModule ? @"true" : @"false"], + [[NSURLQueryItem alloc] initWithName:@"inlineSourceMap" value:inlineSourceMap ? @"true" : @"false"], + ]; NSString *bundleID = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleIdentifierKey]; if (bundleID) { - query = [NSString stringWithFormat:@"%@&app=%@", query, bundleID]; + queryItems = [queryItems arrayByAddingObject:[[NSURLQueryItem alloc] initWithName:@"app" value:bundleID]]; } - return [[self class] resourceURLForResourcePath:path packagerHost:packagerHost scheme:scheme query:query]; + return [[self class] resourceURLForResourcePath:path packagerHost:packagerHost scheme:scheme queryItems:queryItems]; } + (NSURL *)resourceURLForResourcePath:(NSString *)path packagerHost:(NSString *)packagerHost scheme:(NSString *)scheme - query:(NSString *)query + queryItems:(NSArray *)queryItems { NSURLComponents *components = [NSURLComponents componentsWithURL:serverRootWithHostPort(packagerHost, scheme) resolvingAgainstBaseURL:NO]; components.path = path; - if (query != nil) { - components.query = query; + if (queryItems != nil) { + components.queryItems = queryItems; } return components.URL; } @@ -312,6 +322,11 @@ - (BOOL)enableMinification return [[NSUserDefaults standardUserDefaults] boolForKey:kRCTEnableMinificationKey]; } +- (BOOL)inlineSourceMap +{ + return [[NSUserDefaults standardUserDefaults] boolForKey:kRCTinlineSourceMapKey]; +} + - (NSString *)jsLocation { return [[NSUserDefaults standardUserDefaults] stringForKey:kRCTJsLocationKey]; @@ -341,6 +356,12 @@ - (void)setEnableMinification:(BOOL)enableMinification [self updateValue:@(enableMinification) forKey:kRCTEnableMinificationKey]; } +- (void)setInlineSourceMap:(BOOL)inlineSourceMap +{ + [self updateValue:@(inlineSourceMap) forKey:kRCTinlineSourceMapKey]; +} + + - (void)setPackagerScheme:(NSString *)packagerScheme { [self updateValue:packagerScheme forKey:kRCTPackagerSchemeKey]; diff --git a/packages/rn-tester/RNTester/AppDelegate.mm b/packages/rn-tester/RNTester/AppDelegate.mm index f4e8d4006c5416..4697f571c5aca4 100644 --- a/packages/rn-tester/RNTester/AppDelegate.mm +++ b/packages/rn-tester/RNTester/AppDelegate.mm @@ -47,6 +47,9 @@ - (NSDictionary *)prepareInitialProps - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { +#if !USE_HERMES + [[RCTBundleURLProvider sharedSettings] setInlineSourceMap:YES]; +#endif return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"js/RNTesterApp.ios"]; } From 7ef43f59381c5fea3cd0340fcc8f50a5cd1190cd Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Wed, 14 Jun 2023 14:16:04 -0700 Subject: [PATCH 2/6] Don't inline the source map by default --- .../React/Base/RCTBundleURLProvider.h | 8 +++-- .../React/Base/RCTBundleURLProvider.mm | 33 +++++++++---------- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/packages/react-native/React/Base/RCTBundleURLProvider.h b/packages/react-native/React/Base/RCTBundleURLProvider.h index 76b3bc79825b9c..cf2240e1d4ec6c 100644 --- a/packages/react-native/React/Base/RCTBundleURLProvider.h +++ b/packages/react-native/React/Base/RCTBundleURLProvider.h @@ -119,6 +119,7 @@ RCT_EXTERN void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed); * - enableDev: Whether to keep or remove `__DEV__` blocks from the bundle. * - enableMinification: Enables or disables minification. Usually production bundles are minified and development * bundles are not. + * - inlineSourceMap: Determines whether the source map is inline in the JS bundle. This is useful for debugging with Safari /JavascriptCore. * - modulesOnly: When true, will only send module definitions without polyfills and without the require-runtime. * - runModule: When true, will run the main module after defining all modules. This is used in the main bundle but not * in split bundles. @@ -126,16 +127,17 @@ RCT_EXTERN void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed); + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot packagerHost:(NSString *)packagerHost enableDev:(BOOL)enableDev - enableMinification:(BOOL)enableMinification; + enableMinification:(BOOL)enableMinification + inlineSourceMap:(BOOL)inlineSourceMap; + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot packagerHost:(NSString *)packagerHost packagerScheme:(NSString *)scheme enableDev:(BOOL)enableDev enableMinification:(BOOL)enableMinification + inlineSourceMap:(BOOL)inlineSourceMap modulesOnly:(BOOL)modulesOnly - runModule:(BOOL)runModule - inlineSourceMap:(BOOL)inlineSourceMap; + runModule:(BOOL)runModule; /** * Given a hostname for the packager and a resource path (including "/"), return the URL to the resource. * In general, please use the instance method to decide if the packager is running and fallback to the pre-packaged diff --git a/packages/react-native/React/Base/RCTBundleURLProvider.mm b/packages/react-native/React/Base/RCTBundleURLProvider.mm index 46b2c0b1075191..318cb2150850c8 100644 --- a/packages/react-native/React/Base/RCTBundleURLProvider.mm +++ b/packages/react-native/React/Base/RCTBundleURLProvider.mm @@ -26,7 +26,7 @@ void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed) static NSString *const kRCTJsLocationKey = @"RCT_jsLocation"; static NSString *const kRCTEnableDevKey = @"RCT_enableDev"; static NSString *const kRCTEnableMinificationKey = @"RCT_enableMinification"; -static NSString *const kRCTinlineSourceMapKey = @"RCT_inlineSourceMap"; +static NSString *const kRCTInlineSourceMapKey = @"RCT_inlineSourceMap"; @implementation RCTBundleURLProvider @@ -44,9 +44,6 @@ - (NSDictionary *)defaults return @{ kRCTEnableDevKey : @YES, kRCTEnableMinificationKey : @NO, -#if !USE_HERMES - kRCTinlineSourceMapKey: @YES, -#endif }; } @@ -191,9 +188,9 @@ - (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot fallbackURLProvider:( packagerScheme:[self packagerScheme] enableDev:[self enableDev] enableMinification:[self enableMinification] + inlineSourceMap:[self inlineSourceMap] modulesOnly:NO - runModule:YES - inlineSourceMap:[self inlineSourceMap]]; + runModule:YES]; } } @@ -204,9 +201,9 @@ - (NSURL *)jsBundleURLForSplitBundleRoot:(NSString *)bundleRoot packagerScheme:[self packagerScheme] enableDev:[self enableDev] enableMinification:[self enableMinification] + inlineSourceMap:[self inlineSourceMap] modulesOnly:YES - runModule:NO - inlineSourceMap:NO]; + runModule:NO]; } - (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot fallbackExtension:(NSString *)extension @@ -251,6 +248,7 @@ + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot packagerHost:(NSString *)packagerHost enableDev:(BOOL)enableDev enableMinification:(BOOL)enableMinification + inlineSourceMap:(BOOL)inlineSourceMap { return [self jsBundleURLForBundleRoot:bundleRoot @@ -258,9 +256,9 @@ + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot packagerScheme:nil enableDev:enableDev enableMinification:enableMinification + inlineSourceMap:inlineSourceMap modulesOnly:NO - runModule:YES - inlineSourceMap:NO]; + runModule:YES]; } + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot @@ -268,20 +266,19 @@ + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot packagerScheme:(NSString *)scheme enableDev:(BOOL)enableDev enableMinification:(BOOL)enableMinification + inlineSourceMap:(BOOL)inlineSourceMap modulesOnly:(BOOL)modulesOnly runModule:(BOOL)runModule - inlineSourceMap:(BOOL)inlineSourceMap; - { NSString *path = [NSString stringWithFormat:@"/%@.bundle", bundleRoot]; - + BOOL lazy = enableDev; NSArray *queryItems = @[ [[NSURLQueryItem alloc] initWithName:@"dev" value:enableDev ? @"true" : @"false"], - [[NSURLQueryItem alloc] initWithName:@"lazy" value:enableMinification ? @"true" : @"false"], - [[NSURLQueryItem alloc] initWithName:@"minify" value:modulesOnly ? @"true" : @"false"], + [[NSURLQueryItem alloc] initWithName:@"lazy" value:lazy ? @"true" : @"false"], + [[NSURLQueryItem alloc] initWithName:@"minify" value:enableMinification ? @"true" : @"false"], + [[NSURLQueryItem alloc] initWithName:@"inlineSourceMap" value:inlineSourceMap ? @"true" : @"false"], [[NSURLQueryItem alloc] initWithName:@"modulesOnly" value:modulesOnly ? @"true" : @"false"], [[NSURLQueryItem alloc] initWithName:@"runModule" value:runModule ? @"true" : @"false"], - [[NSURLQueryItem alloc] initWithName:@"inlineSourceMap" value:inlineSourceMap ? @"true" : @"false"], ]; NSString *bundleID = [[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *)kCFBundleIdentifierKey]; @@ -324,7 +321,7 @@ - (BOOL)enableMinification - (BOOL)inlineSourceMap { - return [[NSUserDefaults standardUserDefaults] boolForKey:kRCTinlineSourceMapKey]; + return [[NSUserDefaults standardUserDefaults] boolForKey:kRCTInlineSourceMapKey]; } - (NSString *)jsLocation @@ -358,7 +355,7 @@ - (void)setEnableMinification:(BOOL)enableMinification - (void)setInlineSourceMap:(BOOL)inlineSourceMap { - [self updateValue:@(inlineSourceMap) forKey:kRCTinlineSourceMapKey]; + [self updateValue:@(inlineSourceMap) forKey:kRCTInlineSourceMapKey]; } From a65abff2dd730f8539bcaffc57b5afda801c634b Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Thu, 15 Jun 2023 14:14:48 -0700 Subject: [PATCH 3/6] Don't break the public API --- .../React/Base/RCTBundleURLProvider.h | 26 ++++++++++ .../React/Base/RCTBundleURLProvider.mm | 50 ++++++++++++++++++- 2 files changed, 75 insertions(+), 1 deletion(-) diff --git a/packages/react-native/React/Base/RCTBundleURLProvider.h b/packages/react-native/React/Base/RCTBundleURLProvider.h index cf2240e1d4ec6c..d3c5fcee059a54 100644 --- a/packages/react-native/React/Base/RCTBundleURLProvider.h +++ b/packages/react-native/React/Base/RCTBundleURLProvider.h @@ -124,6 +124,21 @@ RCT_EXTERN void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed); * - runModule: When true, will run the main module after defining all modules. This is used in the main bundle but not * in split bundles. */ ++ (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot + packagerHost:(NSString *)packagerHost + enableDev:(BOOL)enableDev + enableMinification:(BOOL)enableMinification +__deprecated_msg("Use version with inlineSourceMap parameter instead"); + + + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot + packagerHost:(NSString *)packagerHost + packagerScheme:(NSString *)scheme + enableDev:(BOOL)enableDev + enableMinification:(BOOL)enableMinification + modulesOnly:(BOOL)modulesOnly + runModule:(BOOL)runModule +__deprecated_msg("Use version with inlineSourceMap parameter instead"); + + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot packagerHost:(NSString *)packagerHost enableDev:(BOOL)enableDev @@ -138,6 +153,17 @@ RCT_EXTERN void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed); inlineSourceMap:(BOOL)inlineSourceMap modulesOnly:(BOOL)modulesOnly runModule:(BOOL)runModule; +/** + * Given a hostname for the packager and a resource path (including "/"), return the URL to the resource. + * In general, please use the instance method to decide if the packager is running and fallback to the pre-packaged + * resource if it is not: -resourceURLForResourceRoot:resourceName:resourceExtension:offlineBundle: + */ ++ (NSURL *)resourceURLForResourcePath:(NSString *)path + packagerHost:(NSString *)packagerHost + scheme:(NSString *)scheme + query:(NSString *)query +__deprecated_msg("Use version with queryItems parameter instead"); + /** * Given a hostname for the packager and a resource path (including "/"), return the URL to the resource. * In general, please use the instance method to decide if the packager is running and fallback to the pre-packaged diff --git a/packages/react-native/React/Base/RCTBundleURLProvider.mm b/packages/react-native/React/Base/RCTBundleURLProvider.mm index 318cb2150850c8..622de761228ffc 100644 --- a/packages/react-native/React/Base/RCTBundleURLProvider.mm +++ b/packages/react-native/React/Base/RCTBundleURLProvider.mm @@ -22,6 +22,7 @@ void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed) kRCTAllowPackagerAccess = allowed; } #endif +static NSString *const kRCTPlatformName = @"ios"; static NSString *const kRCTPackagerSchemeKey = @"RCT_packager_scheme"; static NSString *const kRCTJsLocationKey = @"RCT_jsLocation"; static NSString *const kRCTEnableDevKey = @"RCT_enableDev"; @@ -244,6 +245,21 @@ - (NSURL *)resourceURLForResourceRoot:(NSString *)root queryItems:nil]; } ++ (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot + packagerHost:(NSString *)packagerHost + enableDev:(BOOL)enableDev + enableMinification:(BOOL)enableMinification +{ + return [self jsBundleURLForBundleRoot:bundleRoot + packagerHost:packagerHost + packagerScheme:nil + enableDev:enableDev + enableMinification:enableMinification + inlineSourceMap:NO + modulesOnly:NO + runModule:YES]; +} + + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot packagerHost:(NSString *)packagerHost enableDev:(BOOL)enableDev @@ -261,6 +277,24 @@ + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot runModule:YES]; } ++ (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot + packagerHost:(NSString *)packagerHost + packagerScheme:(NSString *)scheme + enableDev:(BOOL)enableDev + enableMinification:(BOOL)enableMinification + modulesOnly:(BOOL)modulesOnly + runModule:(BOOL)runModule +{ + return [self jsBundleURLForBundleRoot:bundleRoot + packagerHost:packagerHost + packagerScheme:nil + enableDev:enableDev + enableMinification:enableMinification + inlineSourceMap:NO + modulesOnly:modulesOnly + runModule:runModule]; +} + + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot packagerHost:(NSString *)packagerHost packagerScheme:(NSString *)scheme @@ -273,6 +307,7 @@ + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot NSString *path = [NSString stringWithFormat:@"/%@.bundle", bundleRoot]; BOOL lazy = enableDev; NSArray *queryItems = @[ + [[NSURLQueryItem alloc] initWithName:@"platform" value:kRCTPlatformName], [[NSURLQueryItem alloc] initWithName:@"dev" value:enableDev ? @"true" : @"false"], [[NSURLQueryItem alloc] initWithName:@"lazy" value:lazy ? @"true" : @"false"], [[NSURLQueryItem alloc] initWithName:@"minify" value:enableMinification ? @"true" : @"false"], @@ -288,6 +323,20 @@ + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot return [[self class] resourceURLForResourcePath:path packagerHost:packagerHost scheme:scheme queryItems:queryItems]; } ++ (NSURL *)resourceURLForResourcePath:(NSString *)path + packagerHost:(NSString *)packagerHost + scheme:(NSString *)scheme + query:(NSString *)query +{ + NSURLComponents *components = [NSURLComponents componentsWithURL:serverRootWithHostPort(packagerHost, scheme) + resolvingAgainstBaseURL:NO]; + components.path = path; + if (query != nil) { + components.query = query; + } + return components.URL; +} + + (NSURL *)resourceURLForResourcePath:(NSString *)path packagerHost:(NSString *)packagerHost scheme:(NSString *)scheme @@ -358,7 +407,6 @@ - (void)setInlineSourceMap:(BOOL)inlineSourceMap [self updateValue:@(inlineSourceMap) forKey:kRCTInlineSourceMapKey]; } - - (void)setPackagerScheme:(NSString *)packagerScheme { [self updateValue:packagerScheme forKey:kRCTPackagerSchemeKey]; From e9fb38e1e10a534ceba19a2d5618998f5c5aaa86 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Fri, 16 Jun 2023 10:41:06 -0700 Subject: [PATCH 4/6] nits --- packages/react-native/React/Base/RCTBundleURLProvider.h | 5 ++--- packages/rn-tester/RNTester/AppDelegate.mm | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/react-native/React/Base/RCTBundleURLProvider.h b/packages/react-native/React/Base/RCTBundleURLProvider.h index d3c5fcee059a54..9ee7c576c73c00 100644 --- a/packages/react-native/React/Base/RCTBundleURLProvider.h +++ b/packages/react-native/React/Base/RCTBundleURLProvider.h @@ -119,7 +119,6 @@ RCT_EXTERN void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed); * - enableDev: Whether to keep or remove `__DEV__` blocks from the bundle. * - enableMinification: Enables or disables minification. Usually production bundles are minified and development * bundles are not. - * - inlineSourceMap: Determines whether the source map is inline in the JS bundle. This is useful for debugging with Safari /JavascriptCore. * - modulesOnly: When true, will only send module definitions without polyfills and without the require-runtime. * - runModule: When true, will run the main module after defining all modules. This is used in the main bundle but not * in split bundles. @@ -128,7 +127,7 @@ RCT_EXTERN void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed); packagerHost:(NSString *)packagerHost enableDev:(BOOL)enableDev enableMinification:(BOOL)enableMinification -__deprecated_msg("Use version with inlineSourceMap parameter instead"); +__deprecated_msg("Use `jsBundleURLForBundleRoot:packagerHost:enableDev:enableMinification:inlineSourceMap:` instead"); + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot packagerHost:(NSString *)packagerHost @@ -137,7 +136,7 @@ __deprecated_msg("Use version with inlineSourceMap parameter instead"); enableMinification:(BOOL)enableMinification modulesOnly:(BOOL)modulesOnly runModule:(BOOL)runModule -__deprecated_msg("Use version with inlineSourceMap parameter instead"); +__deprecated_msg("Use jsBundleURLForBundleRoot:packagerHost:enableDev:enableMinification:inlineSourceMap:modulesOnly:runModule:` instead"); + (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot packagerHost:(NSString *)packagerHost diff --git a/packages/rn-tester/RNTester/AppDelegate.mm b/packages/rn-tester/RNTester/AppDelegate.mm index 4697f571c5aca4..fe6ef0514201c4 100644 --- a/packages/rn-tester/RNTester/AppDelegate.mm +++ b/packages/rn-tester/RNTester/AppDelegate.mm @@ -48,6 +48,8 @@ - (NSDictionary *)prepareInitialProps - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { #if !USE_HERMES + // With direct debugging via Safari Web Inspector, we need an + // inline source map in order it to be recognized [[RCTBundleURLProvider sharedSettings] setInlineSourceMap:YES]; #endif return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"js/RNTesterApp.ios"]; From 127f8fa0d96036d3abbd0dde960a1ff9d1ba0db1 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Fri, 16 Jun 2023 16:58:08 -0700 Subject: [PATCH 5/6] Fix tests --- .../rn-tester/RNTesterUnitTests/RCTBundleURLProviderTests.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/rn-tester/RNTesterUnitTests/RCTBundleURLProviderTests.m b/packages/rn-tester/RNTesterUnitTests/RCTBundleURLProviderTests.m index 4da7d3fa59d145..596dceb191be1f 100644 --- a/packages/rn-tester/RNTesterUnitTests/RCTBundleURLProviderTests.m +++ b/packages/rn-tester/RNTesterUnitTests/RCTBundleURLProviderTests.m @@ -26,7 +26,7 @@ URLWithString: [NSString stringWithFormat: - @"http://localhost:8081/%@.bundle?platform=ios&dev=true&lazy=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&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.apple.dt.xctest.tool", testFile]]; } @@ -36,7 +36,7 @@ URLWithString: [NSString stringWithFormat: - @"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", + @"http://192.168.1.1:8081/%@.bundle?platform=ios&dev=true&lazy=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.apple.dt.xctest.tool", testFile]]; } From 56a85f1640e1f2e3c85f70aea73414722216a001 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Wed, 21 Jun 2023 08:42:53 -0700 Subject: [PATCH 6/6] Update AppDelegate.mm --- packages/rn-tester/RNTester/AppDelegate.mm | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/rn-tester/RNTester/AppDelegate.mm b/packages/rn-tester/RNTester/AppDelegate.mm index fe6ef0514201c4..f4e8d4006c5416 100644 --- a/packages/rn-tester/RNTester/AppDelegate.mm +++ b/packages/rn-tester/RNTester/AppDelegate.mm @@ -47,11 +47,6 @@ - (NSDictionary *)prepareInitialProps - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge { -#if !USE_HERMES - // With direct debugging via Safari Web Inspector, we need an - // inline source map in order it to be recognized - [[RCTBundleURLProvider sharedSettings] setInlineSourceMap:YES]; -#endif return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"js/RNTesterApp.ios"]; }