Skip to content

Commit 0afd84b

Browse files
longb1997inadev97
andauthored
fix: add file protocol support for script loading in ScriptManager (#1243)
Co-authored-by: inadev97 <inadev1997@gmail.com>
1 parent 1e7d43d commit 0afd84b

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

.changeset/rude-oranges-beg.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@callstack/repack": patch
3+
---
4+
5+
Fix support for file protocol in ScriptManager native module when loading scripts (Android) & prefetching scripts (iOS)

packages/repack/android/src/main/java/com/callstack/repack/ScriptManagerModule.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ class ScriptManagerModule(reactContext: ReactApplicationContext) : ScriptManager
6565
remoteLoader.prefetch(config, promise)
6666
}
6767

68+
config.url.protocol == "file" -> {
69+
fileSystemLoader.prefetch(config, promise)
70+
}
71+
6872
else -> {
6973
promise.reject(
7074
ScriptLoadingError.UnsupportedScheme.code,

packages/repack/ios/ScriptManager.mm

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ @implementation ScriptManager
114114
resolve(nil);
115115
}
116116
}];
117-
} else {
117+
} else if ([[config.url scheme] isEqualToString:@"file"]) {
118+
[self executeFromFilesystem:config resolve:resolve reject:reject];
119+
}
120+
else {
118121
reject(
119122
UnsupportedScheme,
120123
[NSString stringWithFormat:@"Scheme in URL '%@' is not supported", config.url.absoluteString],

0 commit comments

Comments
 (0)