Skip to content

Commit

Permalink
[TIMOB-24148] iOS: Add note for CommonJS modules colliding with Ti na…
Browse files Browse the repository at this point in the history
…mespaces
  • Loading branch information
sgtcoolguy committed Nov 29, 2016
1 parent 73c1686 commit a666748
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions iphone/Classes/KrollBridge.m
Expand Up @@ -862,6 +862,15 @@ - (TiModule *)loadCoreModule:(NSString *)path withContext:(KrollContext *)kroll
return nil;
}

// If there is a JS file that collides with the given path,
// warn the user of the collision, but prefer the native/core module
NSURL *jsPath = [NSURL URLWithString:[NSString stringWithFormat:@"%@/%@.js", [[NSURL fileURLWithPath:[TiHost resourcePath] isDirectory:YES] path], path]];
if ([[NSFileManager defaultManager] fileExistsAtPath:[jsPath absoluteString]]) {
NSLog(@"[WARN] The requested path '%@' has a collison betweeb a native Ti%@um API/module and a JS file.", path, @"tani");
NSLog(@"[WARN] The native Ti%@um API/module will be loaded in preference.", @"tani");
NSLog(@"[WARN] If you intended to address the JS file, please require the path using a prefixed string such as require('./%@') or require('/%@') instead.", path, path);
}

// Ok, we have a native module, make sure instantiate and cache it
TiModule *module = [modules objectForKey:moduleID];
if (module == nil) {
Expand Down

0 comments on commit a666748

Please sign in to comment.