Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/NativeScript/GlobalObject.moduleLoader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
}

NSString* normalizePath(NSString* path) {
NSArray* pathComponents = [path componentsSeparatedByString:@"/"];
NSArray<NSString*>* pathComponents = [path componentsSeparatedByString:@"/"];
NSMutableArray* stack = [[NSMutableArray alloc] initWithCapacity:pathComponents.count];
for (NSString* pathComponent in pathComponents) {
if ([pathComponent isEqualToString:@".."]) {
Expand All @@ -113,6 +113,7 @@
if ([path hasPrefix:@"/"]) {
result = [@"/" stringByAppendingString:result];
}
[stack release];
return result;
}

Expand Down Expand Up @@ -247,7 +248,9 @@
return deferred->reject(execState, createTypeError(execState, WTF::String::format("Unexpected module source type '%s'.", NSStringFromClass([source class]).UTF8String)));
}

return deferred->resolve(execState, jsString(execState, contents));
JSC::JSString* contentsJs = jsString(execState, contents);
[contents release];
return deferred->resolve(execState, contentsJs);
}

static JSModuleRecord* parseModule(ExecState* execState, const SourceCode& sourceCode, const Identifier& moduleKey, ParserError& parserError) {
Expand Down Expand Up @@ -393,14 +396,14 @@
args.append(moduleKey);
JSValue entry = JSC::call(execState, function, callType, callData, moduleLoader, args);
record = jsCast<JSModuleRecord*>(entry.get(execState, Identifier::fromString(execState, "module")));

if (frame.check()) {
NSString* moduleName = (NSString*)moduleKey.toWTFString(execState).createCFString().get();
NSString* appPath = [TNSRuntime current].applicationPath;
if ([moduleName hasPrefix: appPath]) {
if ([moduleName hasPrefix:appPath]) {
moduleName = [moduleName substringFromIndex:appPath.length];
}
frame.log([@"require: " stringByAppendingString: moduleName].UTF8String);
frame.log([@"require: " stringByAppendingString:moduleName].UTF8String);
}

return JSValue::encode(jsUndefined());
Expand Down